Site Tools


notes:xml_cheat_sheet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
notes:xml_cheat_sheet [2026/06/05 05:21]
47.79.51.22 old revision restored (2007/10/04 02:01)
notes:xml_cheat_sheet [2026/06/07 07:31] (current)
8.209.74.18 old revision restored (2007/10/05 18:53)
Line 1: Line 1:
 ===== XML Cheat Sheet ===== ===== XML Cheat Sheet =====
  
-I stumble across XML documents intermittently and every time I need to review the basics again. This is a cheat sheet so that I can review it whenever I need to. Information here is a summarized form of the [[http://www.w3schools.com/xml/default.asp | XML Tutorial]]+I stumble across XML documents intermittently and every time I need to review the basics again. This is a cheat sheet so that I can review it whenever I need to. This is a summarized form of the [[http://www.w3schools.com/xml/default.asp | XML Tutorial]]
 + 
 +Also see the following related cheat sheets : 
 +  * [[DTD Cheat Sheet]] 
 +  * [[XML Schema Cheat Sheet]] 
 + 
 +For reference this is the [[http://www.w3.org/TR/REC-xml/  | XML Specification]] and the [[http://www.xml.com/axml/testaxml.htm | version annotated by Tim Gray]].
  
 ==== What is XML ==== ==== What is XML ====
Line 16: Line 22:
  
   * XML files are completely platform-independent and portable (EBCDIC platforms ?).   * XML files are completely platform-independent and portable (EBCDIC platforms ?).
 +
  
 ==== XML Syntax ==== ==== XML Syntax ====
Line 34: Line 41:
   * The first line is an XML declaration which defines the XML version and the character encoding used in the document.   * The first line is an XML declaration which defines the XML version and the character encoding used in the document.
  
-  * XML tags are case-sensitive and must have a corresponding closing tag. Tags must be properly nested.+  * XML tags are case-sensitive and must have a corresponding closing tag. Empty elements can combine the start and closing tag e.g. <br />. 
 + 
 +  * XML tags must be properly nested.
  
   * An XML document must have a root element (note in the above). All elements may have child elements.   * An XML document must have a root element (note in the above). All elements may have child elements.
Line 53: Line 62:
  
   * A DTD or XML Schema defines the document structure with a list of legal elements and attributes.   * A DTD or XML Schema defines the document structure with a list of legal elements and attributes.
 +
  
 ==== XML Elements ==== ==== XML Elements ====
Line 76: Line 86:
   * A CDATA section starts with "<![CDATA[" and ends with "]]>":   * A CDATA section starts with "<![CDATA[" and ends with "]]>":
  
-  * Everything inside a CDATA section except for [[> is permitted.+  * Everything inside a CDATA section except for ]]> is permitted.
  
 ==== XML Attributes ==== ==== XML Attributes ====
Line 85: Line 95:
  
   * Although data can be stored either in child elements and attributes, attributes should really be used for metadata i.e. data about the data which is not part of the data itself. For example an element id is best stored in an attribute.   * Although data can be stored either in child elements and attributes, attributes should really be used for metadata i.e. data about the data which is not part of the data itself. For example an element id is best stored in an attribute.
 +
  
 ==== XML Namespaces ==== ==== XML Namespaces ====
 +
 +  * XML Namespaces is covered as a [[http://www.w3.org/TR/REC-xml-names/ | separate XML recommendation]] .
  
   * XML namespaces allow element names from XML documents not to conflict if they mean something different.   * XML namespaces allow element names from XML documents not to conflict if they mean something different.
Line 103: Line 116:
  
   * If the form xmlns="namespaceURI" is used instead then all child elements are automatically in that default namespace.   * If the form xmlns="namespaceURI" is used instead then all child elements are automatically in that default namespace.
- 
-==== Document Type Definition (DTD) ==== 
- 
-  * A **D**ocument **T**ype **D**efinition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list of legal elements and attributes. 
- 
-  * A DTD can be internally defined e.g. <code> 
-<!DOCTYPE root-element [ 
-  element-declarations 
-]> 
-</code> or externally defined e.g. <code> 
-<!DOCTYPE root-element SYSTEM "filename.dtd"> 
-</code> where the element-declarations are in filename.dtd 
- 
-  * A simple example of DTD element-declarations <code> 
-  <!ELEMENT note (to,from)> 
-  <!ELEMENT to      (#PCDATA)> 
-  <!ELEMENT from    (#PCDATA)> 
-</code> This says that note contains 2 child elements and to and from are of type #PCDATA 
- 
-  * A DTD for an XML document may contain the following building blocks 
-    * elements 
-    * attributes 
-    * entities (e.g. character entities) 
-    * PCDATA (parsed character data parsed for entities and markup) 
-    * CDATA (character data that is not parsed) 
  
 ==== XML Stylesheets ==== ==== XML Stylesheets ====
notes/xml_cheat_sheet.1780662107.txt.gz · Last modified: 2026/06/05 05:21 by 47.79.51.22