150 likes | 335 Views
XML. XML. XML – A tool that can be used to create markup languages Developers can create application specific markup languages Open standard. Benefits of XML. create “self describing” data create type rules style is separate from data. An XML Document. Runners profile.
E N D
XML • XML – A tool that can be used to create markup languages • Developers can create application specific markup languages • Open standard
Benefits of XML • create “self describing” data • create type rules • style is separate from data
An XML Document • Runners profile <?xml version = "1.0"?> <runner-profile> <name>Fred Bloggs</name> <club>Napier Road Runners</club> <description>Fred took up racing when he was ....</description> <pb-list> <distance>10 K</distance> <time>39:00</time> <distance>Half Marathon</distance> <time>1:32:00</time> <distance>Marathon</distance> <time>2:59:59</time> </pb-list> </runner-profile>
XML – Content Entities • Similar idea to variables <?xml version = "1.0"?> <runner-profile> <name>Fred Bloggs</name> <club>Napier Road Runners</club> <description>Fred took up racing when he was ....</description> <pb-list> <distance>10 K</distance> <time>39:00</time> <distance>Half Marathon</distance> <time>1:32:00</time> <distance>Marathon</distance> <time>2:59:59</time> </pb-list> <favourite-event> <distance> Marathon </distance> <time> 2:59:59</time> </favourite-event> </runner-profile>
<?xml version = "1.0"?> <!DOCTYPE runner-profile [ <!ENTITY marathonPB "2:59:59"> <!ENTITY bio SYSTEM "biography.txt"> ]> <runner-profile> <name> Fred Bloggs </name> <club> Napier Road Runners </club> <description> &bio; </description> <pb-list> <distance> 10 K </distance> <time> 39:00 </time> <distance> Half Marathon </distance> <time> 1:32:00 </time> <distance> Marathon </distance> <time> &marathonPB; </time> </pb-list> <favourite-event> <distance> Marathon </distance> <time> &marathonPB; </time> </favourite-event> </runner-profile>
An XML Document • Entered as a plain text file • Save a .xml
An XML Document • Can be viewed in a web browser
XML Docs – The Declaration • Declaration always appears on the first line • Begins with … <?xml • … and ends with ?> • To give … <?xml ?>
XML Docs – The Declaration • The XML declaration … <?xml ?> • Can take three optional parameters • version – only 1 at the moment • encoding – defines the character set • standalone – value is “yes” or “no”. Determines whether all of the information required for validation is contained in this document or whether external document type definitions are required
XML - Adding Style • Link to a style sheet … <?xml-stylesheet type = "text/css" href = "runner.css" ?> • … and then specify the styles * { font-family: arial; } name { font-size: 16pt; color: red; display: block; } club { font-size: 12pt; color: green; display: block; }
XML – Adding Style • Instead of this …
XML – Adding Style • You get this …
Lecture Slides • www.dcs.napier.ac.uk/~owens/wpt/lectures/wptlecture7.ppt