XML Flashcards
Features of XML tags - 6 things
- case sensitive i.e <H1> and <h1> are different
- in XML you can never omit an end tag
- XML elements that have a single tag without a matching end tag must end in a / e.g <img=src=”coffeecup.png”/>
- XML attributes must be enclosed in quotation “ marks
- XML - all attributes should have values
- <input></input>. is wrong as checked has no value
Horstmann, Cay S.. Core Java (p. 156). Pearson Education. Kindle Edition.
XML documents - two features
- start with a header - <?xml version=”1.0” encoding=”UTF-8”?>
- schema is defined in an xsd document
character references in XML in hex or decimal
e.g. é ( decimal)
or é (hex)
What is a DTD (document type definition)
DTDs are NOT required but are used to ensure the correctness of the document
What is the root element of an XML file ?
It is essentially the highest level node that contains all of the other XML data
What is an Entity Reference ?
entity references have the form
< - for less than
> - for greater than
& - for ampersand
&apo - apostrophe
etc…
What is CDATA ?
CDATA sections are delimeted by
[CDATA[ and ]]>
used to include strings of data that contains the < > & symbols
What is the syntax for XML processing instructions ?
delimeted by <? and ?>
e.g. <?xml version=”1.0” encoding=”UTF-8”?>
What is XML Parsing ?
To process an XML doc you need to Parse it using a Parser.
There are two kinds
DOM Parser - reads an XML file into a Tree Structure
SAX Parser - reads an XML file and generates events
What is a DOM Parser ?
Simply put, a DOM parser works on the entire XML document, loads it into memory and constructs a tree representation of the document.
What is XSD ?
XML Schema Definition (XSD) is currently the de facto standard for describing XML document
How would an XML element be described in an XSD ?
<xs:element></xs:element>
e.g. <xs:element></xs:element>
What are the predefined simple types in the XSD standard ?
xs:string, xs:integer, xs:boolean and xs:date are examples
What is attribute “default” for ?
To provide a value if none given
<xs:element></xs:element>
What is attribute “fixed” for ?
This means the value in the XML can only have this value
<xs:element></xs:element>