|
12 | 12 | attributes and processing rules defined in XHTML+RDFa in order to |
13 | 13 | support extracting RDF from HTML documents. |
14 | 14 | </p> |
| 15 | + <p> |
| 16 | + The requirements and rules, as specified in XHTML+RDFa and further |
| 17 | + modified in this document, apply to all HTML5 documents. The RDFa Processor |
| 18 | + operating on HTML and XHTML documents, specifically the resulting DOMs, |
| 19 | + must apply the same processing rules for both types of serializations an |
| 20 | + DOMs. |
| 21 | + </p> |
15 | 22 |
|
16 | 23 | <h3>Specifying the language for a literal</h3> |
17 | 24 | <p> |
18 | | - The <code>lang</code> attribute must be supported in the same manner |
19 | | - as the <code>xml:lang</code> attribute is in the XHTML+RDFa specification. |
20 | | - The precedence rules for selecting which value overrides the other is |
21 | | - outlined in the section titled "The lang and xml:lang attributes" in |
22 | | - the HTML5 specification. |
| 25 | + The <code>lang</code> attribute must be processed in the same manner |
| 26 | + as the <code>xml:lang</code> attribute is in the XHTML+RDFa specification, |
| 27 | + <a href="http://www.w3.org/TR/rdfa-syntax/#sec_5.5.">Section 5.5</a>, |
| 28 | + step #3. |
| 29 | + </p> |
| 30 | + The rules for determining the language of a node are specified in the |
| 31 | + section titled |
| 32 | + <a href="http://www.w3.org/TR/html5/Overview.html#the-lang-and-xml:lang-attributes">The lang and xml:lang attributes</a> in the HTML5 specification. |
23 | 33 | </p> |
24 | 34 | <p> |
25 | | - If an author is unsure of the final encapsulating DOCTYPE for their |
26 | | - markup, such as HTML5 vs. XHTML5, it is suggested that the author specify |
27 | | - both <code>lang</code> and <code>xml:lang</code> where the value in |
28 | | - both attributes is exactly the same. |
| 35 | + If an author is editing an HTML fragment and is unsure of the final |
| 36 | + encapsulating MIME type for their markup, it is suggested that the |
| 37 | + author specify both <code>lang</code> and <code>xml:lang</code> where the |
| 38 | + value in both attributes is exactly the same. |
29 | 39 | </p> |
30 | 40 |
|
31 | 41 | <h3>Invalid XMLLiteral values</h3> |
32 | 42 | <p> |
33 | 43 | When generating literals of type XMLLiteral, the processor must ensure that |
34 | | - the output XMLLiteral is |
35 | | - <a href="http://www.w3.org/TR/xml/#dt-wellformed">well-formed XML</a>. |
36 | | - If the input is not well-formed XML</a>, the processor must transform |
37 | | - the input text in a way that generates well-formed XML. An RDFa Processor |
38 | | - that is transforming not well-formed XML to well-formed XML must use the |
39 | | - algorithm for serializing a DOM subtree into XHTML5 as specified in the |
40 | | - HTML5 specification. |
| 44 | + the output XMLLiteral is a namespace well-formed XML fragment. A namespace |
| 45 | + well-formed XML fragment has the following properties: |
| 46 | + <ul> |
| 47 | + <li> |
| 48 | + The XML fragment, when placed inside of a single root element, must |
| 49 | + validate as well-formed XML. The normative language that describes a |
| 50 | + well-formed XML document is specified in |
| 51 | + <a href="http://www.w3.org/TR/REC-xml/#sec-well-formed">Section 2.1 "Well-Formed XML Documents"</a> |
| 52 | + of the XML specification. |
| 53 | + </li> |
| 54 | + <li> |
| 55 | + A case-insensitive match for the currently active <code>xmlns</code> |
| 56 | + attribute as well as all currently active attributes starting with |
| 57 | + <code>xmlns:</code> must be preserved in the generated XMLLiteral. |
| 58 | + This preservation must be accomplished by placing all active namespaces |
| 59 | + in each top-level element in the generated XMLLiteral, taking care to |
| 60 | + not over-write pre-existing namespace values. |
| 61 | + </li> |
| 62 | + </ul> |
| 63 | + If the input is not a namespace well-formed XML fragment, the processor |
| 64 | + must transform the input text in a way that ensures the well-formedness |
| 65 | + rules described in this section. If a sequence of characters cannot be |
| 66 | + transformed into a namespace well-formed XML fragment, the triple |
| 67 | + containing the XMLLiteral must not be generated. |
41 | 68 | </p> |
42 | 69 | <p> |
43 | | - Transformation to well-formed XML is required because an application |
44 | | - that consumes XMLLiteral data expects that data to be well-formed. |
| 70 | + An RDFa Processor that transforms the XML fragment must use the |
| 71 | + <a href="http://www.w3.org/TR/html5/Overview.html#coercing-an-html-dom-into-an-infoset">Coercing an HTML DOM into an Infoset</a> |
| 72 | + rules, as specified in the HTML5 specification, prior to generating the |
| 73 | + triple containing the XMLLiteral. The serialization algorithm that must |
| 74 | + be used for generating the XMLLiteral is normatively defined in the |
| 75 | + <a href="http://www.w3.org/TR/html5/Overview.html#serializing-xhtml-fragments">Serializing XHTML Fragments</a> |
| 76 | + section of the HTML5 specification. |
| 77 | + </p> |
| 78 | + <p> |
| 79 | + Transformation to a namespace well-formed XML fragment is required |
| 80 | + because an application that consumes XMLLiteral data expects that |
| 81 | + data to be a namespace well-formed XML fragment. |
45 | 82 | </p> |
46 | 83 | <p> |
47 | 84 | The transformation requirement does not apply to input data that are |
48 | 85 | text-only, such as literals that contain a <code>datatype</code> attribute |
49 | 86 | with an empty value (<code>""</code>), or input data that that contain |
50 | 87 | only text nodes. |
51 | 88 | </p> |
| 89 | + <p> |
| 90 | + An example transformation demonstrating the preservation of namespace values is provided below. The → symbol is used to denote that the line is a continuation of the previous line and is included purely for the purposes of readability: |
| 91 | + |
| 92 | + <pre> |
| 93 | +<p xmlns:ex="http://example.org/vocab#" |
| 94 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> |
| 95 | + Two rectangles (the example markup for them are stored in a triple): |
| 96 | + <svg xmlns="http://www.w3.org/2000/svg" property="ex:markup" datatype="rdf:XMLLiteral"> |
| 97 | +→ <rect width="300" height="100" |
| 98 | +→ style="fill:rgb(0,0,255);stroke-width:1; stroke:rgb(0,0,0)"/> |
| 99 | +→ <rect width="50" height="50" |
| 100 | +→ style="fill:rgb(255,0,0);stroke-width:2; |
| 101 | +→ stroke:rgb(0,0,0)"/></svg> |
| 102 | +</p> |
| 103 | + </pre> |
| 104 | + |
| 105 | + The markup above should produce the following triple: |
| 106 | + |
| 107 | + <pre> |
| 108 | +<> |
| 109 | + <http://example.org/vocab#markup> |
| 110 | + "<rect xmlns=\"http://www.w3.org/2000/svg\" xmlns:ex=\"http://example.org/vocab#\" |
| 111 | +→ xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" width=\"300\" |
| 112 | +→ height=\"100\" style=\"fill:rgb(0,0,255);stroke-width:1; stroke:rgb(0,0,0)\"/> |
| 113 | +→ <rect xmlns=\"http://www.w3.org/2000/svg\" xmlns:ex=\"http://example.org/vocab#\" |
| 114 | +→ xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" width=\"50\" |
| 115 | +→ height=\"50\" style=\"fill:rgb(255,0,0);stroke-width:2; |
| 116 | +→ stroke:rgb(0,0,0)\"/>"^^http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral |
| 117 | + </pre> |
| 118 | + |
| 119 | + Note the preservation of the namespaces by injecting a new |
| 120 | + <code>xmlns</code> attribute, as well as the attributes starting |
| 121 | + with the character sequence <code>xmlns:</code>, into each <code>rect</code> |
| 122 | + element. |
| 123 | + </p> |
52 | 124 |
|
53 | 125 | <h3>The <code>xmlns:</code> attribute</h3> |
54 | 126 | <p> |
|
0 commit comments