|
HTML clipboard 1. Example 1 An XML document must contain one or more elements. * Well trained <text> This is an XML document </ text> XML document with a well-trained element * Well trained This is a <text> <doctype> XML document </ doctype> </ text> Document XML trained with several elements * Poorly trained ? This is an XML document? An XML document must contain at least one element 2. Example 2 There is exactly one element called root element or element document, which neither side appears in the content of another element. * Well trained <book> This is a book </ book> <book> is the root element * Well trained <list> 1 <item> Item </ item> <item> Item 2 </ item> <item> Item 3 </ item> </ list> <list> is the root element Poorly trained ??? <item>Item 1</item> <item>Item 2</item> <item>Item 3</item> ??? * Only a root element is allowed 3. Example 3 The name of the tag end of an element must match that of the starting tag. The names reflect the upper and lower * Well trained <book> This is a book </ book> The end tag </ book> is the starting tag <book> * Well trained <list> <item>Car</item> <ITEM>Plane</ITEM> <Item>Train</Item> </list> This document includes well-trained 4 different elements <list>, <item>, <ITEM> and <Item> * Poorly trained <list> <item>Car</item> <item>Plane</ITEM> <item>Train</item> </list> <item> - </ item> and <item> - </ ITEM> do not match 4. Example 4 If the starting tag appears in the content of another element, the end tag must also be included in the content of the same element. More simply, the elements demarcated by the tags beginning and end are s'imbriquer properly with each other. * These elements are properly intertwined. Well trained <Weight> <number>12</number> <unit>gramme</unit> </Weight> * Another example of material well-trained Well trained <book> <chapter> <title>Introduction</title> </chapter> <chapter> <title>Story</title> <subChapter> <title>Part 1</title> </subChapter> <subChapter> <title>Part 2</title> </subChapter> </chapter> <chapter> <title>Index</title> </chapter> </book> * The <italic> is not properly nested Poorly trained <text> <bold><italic>XML</bold></italic> </text> 5. Example 5 The end of each element starting with a starting tag must be indicated by an end tag bearing the same name as that used in the starting tag. The text between the tag beginning and end tag is called the contents of the element. An element without content takes the form special follows: <nom/>. The slash to the character> replaces the end tag. *Each element has an end tag or adopts the special form. There is no difference between <AAA> </ AAA> and <AAA/> XML. Well trained <listOfTags> <AAA></AAA> <BBB></BBB> <CCC/> <DDD/> </listOfTags> * A very common mistake is to forget the slash Poorly trained <description> ago apples<color> yellow and red <color> </ color>. </ description>
6. Example 6 The names of elements may include letters, numbers, dashes, underscores, colon or points. The colon (:) may be used only in the specific case where it is used to separate namespaces. The names of elements beginning with xml, XML or another combination of the breakage of these letters are reserved for the XML standard.
* Document containing characters Well trained <permittedNames> <name/> <xsl:copy-of/> <A_long_element_name/> <A.name.separated.with.full.stops/> <a123323123-231-231/> <_12/> </permittedNames> * This document contains several errors. Poorly trained <forbiddenNames> <A;name/> <last@name> <@#$%^()%+?=/> <A*2/> <1ex/> </forbiddenNames> * The names can not start with xml Poorly trained <forbiddenNames> <xmlTag/> <XMLTag/> <XmLTag/> <xMlTag/> <xmLTag/> </forbiddenNames> 7. Example 7 A component may include any one or more attributes. The characters are the same as for the names of elements. The name of an attribute is separated from its value by the =. The value of the attribute must be given in single quotes'...' or double "..." . If a single or double quote is used in the value of an attribute, delimiter contrary must be used.
*Document attributes with well-trained Well trained <elements-with-attributes> <el _ok = "yes" /> <one attr = "value"/> <several first="1" second = '2' third= "333"/> <apos_quote case1=" Today "case2='It began:" Hi, everyone! "'/> </elements-with-attributes>
* Document containing attributes invalid Poorly trained <errors> <wrong_char a*b = "23432"/> <mismatched_separator value = "12'/> <wrong_separator_type value="aa"aa"/> <wrong_separator_type value='bb'bb'/> <wrong_start XML-ID = "xml234"/> </errors> 8. Example 8
The characters <& and can not be used in the text because they are used in the markup. If you must use these characters, use <to replace <and & to replace &
* Substitution & and < Well trained <example> <isLower> 23 < 46 </isLower> <ampersand> Smith & son </ampersand> </example> * Characters & and <can not be used in the text Poorly trained <example> <isLower> 23 < 46 </isLower> <ampersand> Smith & son </ampersand> </example> 9. Example 9
The characters> ", and" may also be replaced by>, "and" respectively
* Substitutions possible Well trained <example> <right-bracket>At the time>> are allowed</right-bracket> <double-quote>At the same time "and" are authorized</double-quote> <apostrophe>At the time ' and 'are allowed</apostrophe> This is useful in: <el value="' " '"/> </example> 10. Example 10
Comments may appear anywhere in a document apart from other tags. A processor XML could allow an application, unless it is an obligation, to extract the text comments. The string "-" (two dashes) should not be included inside comments.
* Comments can include any character with the exception of characters -- Well trained <example>
<! - Characteristics </example> * The comments should not include the string -- Poorly trained <example> </example> 11. Example 11
The treatment instructions (PI - Processing instruction in English) allow XML documents contain instructions for applications.
* Instructions treatment Well trained <example> <?perl lower-to-upper-case ?> <?web-server add-header = "university" ?> <text>vscht</text> </example> * An instruction treatment must be completed by?> Poorly trained <example> <?perl run _> </example> 12. Example 12
The CDATA sections can not deal with blocks of text with characters that would normally be identified as markup. The CDATA sections start with the string "<[CDATA [" and end with the chain "]]>". The chain']]>' should not be included inside a CDATA.
* Section CDATA Well trained <example> <![CDATA[ <aaa>bb&cc<<<]]> </example> * A CDATA does not include the string']]>' Poorly trained <example> <![CDATA[ <aaa>bb ]]>cc<<<]]> </example>
13. Example 13
XML documents can and indeed must begin with a statement specifying the XML version of the XML standard used.
* Specifying the XML version Well trained <?xml version="1.0"?> <text>This document meets the XML 1.0 specification.</text>
* Specifications coding Well trained <?xml version="1.0" encoding="ISO-8859-2"?> <text>If no coding is indicated, UTF-8 is the default</text>
|