xml - 1 XML Document Type Definitions XML Schema 2...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 XML Document Type Definitions XML Schema 2 Well-Formed and Valid XML Well-Formed XML allows you to invent your own tags. Valid XML conforms to a certain DTD. 3 Well-Formed XML Start the document with a declaration , surrounded by <?xml ?> . Normal declaration is: <?xml version = 1.0 standalone = yes ?> standalone = no DTD provided. Balance of document is a root tag surrounding nested tags. 4 Tags Tags are normally matched pairs, as <FOO> </FOO>. Unmatched tags also allowed, as <FOO/> Tags may be nested arbitrarily. XML tags are case-sensitive. 5 Example : Well-Formed XML <?xml version = 1.0 standalone = yes ?> <BARS> <BAR><NAME>Joes Bar</NAME> <BEER><NAME>Bud</NAME> <PRICE>2.50</PRICE></BEER> <BEER><NAME>Miller</NAME> <PRICE>3.00</PRICE></BEER> </BAR> <BAR> </BARS> A NAME subelement A BEER subelement Root tag Tags surrounding a BEER element 6 DTD Structure <!DOCTYPE <root tag> [ <!ELEMENT <name> ( <components> )> . . . more elements . . . ]> 7 DTD Elements The description of an element consists of its name (tag), and a parenthesized description of any nested tags. Includes order of subtags and their multiplicity. Leaves (text elements) have #PCDATA ( Parsed Character DATA ) in place of nested tags. 8 Example : DTD <!DOCTYPE BARS [ <!ELEMENT BARS (BAR*)> <!ELEMENT BAR (NAME, BEER+)> <!ELEMENT NAME (#PCDATA)> <!ELEMENT BEER (NAME, PRICE)> <!ELEMENT PRICE (#PCDATA)> ]> A BARS object has zero or more BARs nested within. A BAR has one NAME and one or more BEER subobjects. A BEER has a NAME and a PRICE. NAME and PRICE are text. 9 Element Descriptions Subtags must appear in order shown. A tag may be followed by a symbol to indicate its multiplicity. * = zero or more. + = one or more. ? = zero or one. Symbol | can connect alternative sequences of tags. 10 Example : Element Description A name is an optional title (e.g., Prof.), a first name, and a last name, in that order, or it is an IP address: <!ELEMENT NAME ( (TITLE?, FIRST, LAST) | IPADDR )> 11 Use of DTDs 1. Set standalone = no. 2. Either: a) Include the DTD as a preamble of the XML document, or b) Follow DOCTYPE and the <root tag> by SYSTEM and a path to the file where the DTD can be found. 12 Example : (a) <?xml version = 1.0 standalone = no ?> <!DOCTYPE BARS [ <!ELEMENT BARS (BAR*)> <!ELEMENT BAR (NAME, BEER+)> <!ELEMENT NAME (#PCDATA)> <!ELEMENT BEER (NAME, PRICE)> <!ELEMENT PRICE (#PCDATA)> ]> <BARS> <BAR><NAME>Joes Bar</NAME> <BEER><NAME>Bud</NAME> <PRICE>2.50</PRICE></BEER> <BEER><NAME>Miller</NAME> <PRICE>3.00</PRICE></BEER> </BAR> <BAR> </BARS> The DTD The document 13...
View Full Document

Page1 / 44

xml - 1 XML Document Type Definitions XML Schema 2...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online