|René Nyffenegger's collection of things on the web|
René Nyffenegger on Oracle - Most wanted - Feedback
<?xml version="1.0"?> <email> <sent timezone="UTC">12:54</sent> <from> <name>James Bond</name> <email-address>firstname.lastname@example.org</email-address> </from> <to> <email-address>email@example.com</email-address> </to> <body> I'd like to take you out for a coffee. </body> </email>
The document prolog
The XML declaration states some general properties about the document.
The document prolog can set three properties:
Document type declaration
Document type declaration is different from document type definition. The document type definition is embedded in the document type declaration.
The DOCTYPE 'statement' links an XML Document to a DTD.
The document type declaration names the root element type.
Additionally, it can point to a document type definition (DTD) (that governs the markup structure)
Document type definition
Document type definitions (or DTDs) define the structure of an XML Application.
Set of declarations
The all enclosing element (here: email) is called the Root element.
Also called the Document Element.
Document root is the very first (and essentially a virtual) element of the XML tree. This is DOM's representation. Document root is the parent of Document Element. Document element is the root element of the xml document. This is very first element of a xml document.
The root node can have other children besides the document element, e.g. comments and processing instructions.
Tags are delimitted by < and > (for example <from> is a tag or <email-address> is a tag.
Empty Element Tag
A tag might contain attributes. Each attribute name must be unique.
<tag-name attribute-one="value-one" further-attribute="further-value">
Attributes are used to
Types of Attributes:
Special attributes: actuate
Attribute values are subject to attribute-value normalization.
Elements are enclosed between an opening and closing tag. That means, Tags divide the document's content into Elements. Elements might contain other Elements.
There are four types of elements:
An entity has a name and a value. The entity's name is a placeholder for content (determined by said value).
<!DOCTYPE some_root_elem SYSTEM "/home/ego/some.dtd" [ <!ENTITY entity-name "Some value to be inserted at the entity"> ]
Character entities are predefined.
& < > ' "
Numbered character are predefined.
Æ © ­
Is: Æ ©
The hexadecimal representation (&#x) is useful for Unicode as well.
CDATA is character data, that is markup free data.
<![ CDATA [ some text, possibly having < and > here ]]>
Processing Instructions (PI)
<?processing-instruction-name data for the processing instruction ?>
Not incidentally, a XML declaration looks like a processing instruction.
A use for processing instructions is to reference a stylesheet from within an XML document.
<!-- here is some comment further line -->