XML (eXtensible Markup Language) in one page | ||||||||||||||
Contents: Review: Well-Formed Document (well formedness), Valid XML document, Structure of XML Document; Components: XML Declaration, DOCTYPE Declaration & DTDs, DTD (DocType Declaration) in one page, Comments, Processing Instruction, CDATA Section; Other: Related References (Review, Documentation, etc.), Tools (Validators, etc.), Related themes, Miscellaneous. |
||||||||||||||
Structure of XML Document | ||||||||||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> | XML Declaration | |||||||||||||
White space characters (space, carriage return, line feed, tab, etc) | ||||||||||||||
<!-- Comments --> | Comments | |||||||||||||
<?xml-stylesheet type="text/css" href="your_documents_css.css" ?> | External style sheet for browse your xml document | |||||||||||||
<?word document="test.doc" ?> | Processing Instruction | |||||||||||||
<!DOCTYPE root_element [ <!ELEMENT root_element (#PCDATA)> ]> | Internal DOCTYPE Declaration, and/or | |||||||||||||
<!DOCTYPE root_element SYSTEM "your_documents_dtd.dtd"> | External DOCTYPE Declaration | |||||||||||||
<root_element> | Open tag of "root_element" | |||||||||||||
<subElement> | Open tag of "subElement" | |||||||||||||
...text... | Data | |||||||||||||
<subSubElement attr_name="attr_value"> | Open tag of "subSubElement" with attribute "attr_name" equal "attr_value" | |||||||||||||
<![CDATA[ ...any characters (including markup)... ]]> | CDATA Section | |||||||||||||
</subSubElement> | Close tag of "subSubElement" | |||||||||||||
</subElement> | Close tag of "subElement" | |||||||||||||
Well-Formed Document (well formedness) | <emptyElement/> | Tag of empty element | ||||||||||||
Has a single root element | <anotherSubElement xmlns="http://www.xml.su/shema1"> | Open tag of "anotherSubElement" with namespace "http://www.xml.su/shema1" as default | ||||||||||||
All other element are correctly nested: | ||||||||||||||
- all other elements are children of the root element | <element1> | Open tag of "element1" from namespace "http://www.xml.su/shema1" | ||||||||||||
- all elements are correctly paired | </element1> | Close tag of "element1" | ||||||||||||
- the element name in a start-tag and an end-tag are exactly the same | <element2 xmlns:sh="http://www.xml.su/shema2"> | Open tag of "element2" with namespace "http://www.xml.su/shema2" for sh preffix | ||||||||||||
- attribute names are used only once within the same element | <sh:emptyElement/> | Empty tag of "sh:emptyElement" from namespace "http://www.xml.su/shema2" | ||||||||||||
Valid XML document | </element2> | Close tag of "element2" | ||||||||||||
Abide by the constraints placed on each element's position in the document | </anotherSubElemen> | Close tag of "anotherSubElemen" | ||||||||||||
Abide by the constaints placed on the attributes of each element | ... | Any supperposition of elements (corrected nested), empty elements, text data, CDATA, comments and white space | ||||||||||||
Require a Document Type Definition or XML Schema to specify the constraints | ... | |||||||||||||
</root_element> | Close tag of "root_element" | |||||||||||||
XML Declaration | Comments | |||||||||||||
<?xml version="version_number" encoding="encoding_declaration" standalone="standalone_status" ?> |
The XML declaration is a processing instruction that identifies the document as being XML. All XML documents should begin with an XML declaration. Rules:
|
<!-- Comments --> |
Comments are used to hide text from the end user when the output document is displayed. They are useful as notes to the author of the document, or other authors who may modify the document. Rules:
|
|||||||||||
Processing Instruction | ||||||||||||||
Processing instructions are used to embed information intended for proprietary applications. The XML declaration is an example of a processing instruction. Processing instructions beginning with 'xml' or 'XML' have been reserved for standardization in the XML Version 1.0 specification and onwards. |
||||||||||||||
<?PI-target ?> |
PI-target: any name that does not contain the letters 'X' or 'x', 'M' or 'm', or 'L' or 'l' in that order. Rules:
|
|||||||||||||
|
||||||||||||||
CDATA Section | ||||||||||||||
CDATA sections are used to display markup without the XML processor trying to interpret that markup. They are particularly useful when you want to display sections of XML code. | ||||||||||||||
<![CDATA[ ...any characters (including markup)... ]]> |
Rules:
|
|||||||||||||
DOCTYPE Declaration & DTDs | Related References | Tools | ||||||||||||
The document type (DOCTYPE) declaration consists of an internal, or references an external Document Type Definition (DTD). It can also have a combination of both internal and external DTDs. The DTD defines the constraints on the structure of an XML document. It declares all of the document's element typesglossary, children element types, and the order and number of each element type. It also declares any attributes, entities, notations, processing instructions, comments, and PE references in the document. A document can use both internal and external DTD subsets. The internal DTD subset is specified between the square brackets of the DOCTYPE declaration. The declaration for the external DTD subset is placed before the square brackets immediately after the SYSTEM keyword. |
Important:
|
Validators:
|
||||||||||||
The Internal DTD: <!DOCTYPE root_element [ Document Type Definition (DTD): elements/attributes/entities/notations/processing instructions/comments/PE references ]> |
Rules:
|
|||||||||||||
"Private" External DTDs: <!DOCTYPE root_element SYSTEM "DTD_location"> |
External DTDs are useful for creating a common DTD that can be shared between multiple documents. Any changes that are made to the external DTD automatically updates all the documents that reference it. There are two types of external DTDs: private, and public. Private external DTDs are identified by the keyword SYSTEM, and are intended for use by a single author or group of authors. Public external DTDs are identified by the keyword PUBLIC and are intended for broad use. The "DTD_location" is used to find the public DTD if it cannot be located by the "DTD_name". Rules:
DTD_location: relative or absolute URL
|
|||||||||||||
"Public" External DTDs: <!DOCTYPE root_element PUBLIC "DTD_name" "DTD_location"> |
||||||||||||||
Related themes | Miscellaneous | |||||||||||||
DTD HTML CSS |
|
|||||||||||||
More about DOCTYPE Declaration & DTDs | ||||||||||||||