source: spec/index.html @ e45219a

Revision e45219a, 17.8 KB checked in by Eric van der Vlist <vdv@…>, 8 years ago (diff)

Version 0.2 of the spec

  • Property mode set to 100644
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<html xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <title>χίμαιραλ (chimeral) - the Chimera Language</title>
5    <link href="xrd.css" type="text/css" rel="stylesheet" />
6  </head>
7  <body>
8    <h1>χίμαιραλ (chimeral) - the Chimera Language</h1>
9    <div>
10      <p>This Version: <a href="http://χίμαιραλ.com/0/2">V 0.2 (TBD)</a></p>
11      <p>Previous Version: <a href="http://χίμαιραλ.com/0/1">http://χίμαιραλ.com/0/1</a></p>
12      <p>Latest Version: <a href="http://χίμαιραλ.com">http://χίμαιραλ.com</a></p>
13      <p>This namespace: <a href="http://χίμαιραλ.com#">http://χίμαιραλ.com#</a></p>
14      <p>Editor:</p>
15      <ul>
16        <li><a href="mailto:vdv@dyomedea.com">Eric van der Vlist</a>, <a href="http://dyomedea.com">Dyomedea</a></li>
17      </ul>
18    </div>
19    <div>
20      <h2>About this page</h2>
21      <p>This page is the home page of the χίμαιραλ (chimeral) project and the documentation of the <a href="http://χίμαιραλ.com#">http://χίμαιραλ.com#</a> XML namespace.</p>
22      <p>The goal of χίμαιραλ (chimeral) is to facilitate the use of the XPath/XQuery/XSLT 3.0 data model aka <a href="http://www.w3.org/TR/xpath-datamodel-30/">XDM 3.0</a>.</p>
23      <p>The <a href="http://χίμαιραλ.com#">http://χίμαιραλ.com#</a> XML namespace defines a XML serialization format for XDM 3.0.</p>
24      <p>The name and the idea of this project comes from the <a href="http://www.xmlprague.cz/2012/sessions.html#Opening-Keynote-%E2%80%93-Collisions-Chimera-and-Consonance-in-Web-Content"
25          >presentation</a> given by Jeni Tennison at XML Prague 2012: I was going to show that XDM is a foundation on which the whole XML ecosystem is built and Jeni, giving her opening keynote just
26        before my presentation explained why we should take care of chimeras, “ugly, foolish or impossible fantasies”. This made me realize that XDM, a data model that aggregates the XML infoset and
27        informations items borrowed to XML Schema and now JSON is a chimera and that some efforts are needed to make it viable!</p>
28      <p>The <a href="http://χίμαιραλ.com#">http://χίμαιραλ.com#</a> XML namespace is a first step in that direction. By providing a serialization format it gives some reality to the XDM that has been
29        a perfectly abstract concept so far. This serialization format is also useful to manipulate the XDM: the items recently imported into the model such as maps are not always considered as first
30        class citizens by XPath/XQuery/XSLT (you can't apply templates on map items for instance) and this serialization can help do that.</p>
31      <p>The namespace URI itself (<a href="http://χίμαιραλ.com#">http://χίμαιραλ.com#</a>) is a chimera, composed of letters from two different alphabets and merging concepts from two different
32        civilizations.</p>
33    </div>
34    <div>
35      <h2>Examples</h2>
36      <div><h3>JSON objects</h3><p>The following JSON
37          object:</p><pre>{
38     "firstName": "John",
39     "lastName" : "Smith",
40     "age"      : 25,
41     "address"  :
42     {
43         "streetAddress": "21 2nd Street",
44         "city"         : "New York",
45         "state"        : "NY",
46         "postalCode"   : "10021"
47     },
48     "phoneNumber":
49     [
50         {
51           "type"  : "home",
52           "number": "212 555-1234"
53         },
54         {
55           "type"  : "fax",
56           "number": "646 555-4567"
57         }
58     ]
59 }</pre><p>imported
60          into XDM with the parse-json() function gives the following χίμαιραλ
61        serialization:</p><pre>&lt;?xml version="1.0" encoding="UTF-8"?>
62&lt;χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
63   &lt;χ:entry key="lastName" keyType="string">
64      &lt;χ:atomic-value type="string">Smith&lt;/χ:atomic-value>
65   &lt;/χ:entry>
66   &lt;χ:entry key="phoneNumber" keyType="string">
67      &lt;χ:map>
68         &lt;χ:entry key="1" keyType="number">
69            &lt;χ:map>
70               &lt;χ:entry key="number" keyType="string">
71                  &lt;χ:atomic-value type="string">212 555-1234&lt;/χ:atomic-value>
72               &lt;/χ:entry>
73               &lt;χ:entry key="type" keyType="string">
74                  &lt;χ:atomic-value type="string">home&lt;/χ:atomic-value>
75               &lt;/χ:entry>
76            &lt;/χ:map>
77         &lt;/χ:entry>
78         &lt;χ:entry key="2" keyType="number">
79            &lt;χ:map>
80               &lt;χ:entry key="number" keyType="string">
81                  &lt;χ:atomic-value type="string">646 555-4567&lt;/χ:atomic-value>
82               &lt;/χ:entry>
83               &lt;χ:entry key="type" keyType="string">
84                  &lt;χ:atomic-value type="string">fax&lt;/χ:atomic-value>
85               &lt;/χ:entry>
86            &lt;/χ:map>
87         &lt;/χ:entry>
88      &lt;/χ:map>
89   &lt;/χ:entry>
90   &lt;χ:entry key="address" keyType="string">
91      &lt;χ:map>
92         &lt;χ:entry key="streetAddress" keyType="string">
93            &lt;χ:atomic-value type="string">21 2nd Street&lt;/χ:atomic-value>
94         &lt;/χ:entry>
95         &lt;χ:entry key="postalCode" keyType="string">
96            &lt;χ:atomic-value type="string">10021&lt;/χ:atomic-value>
97         &lt;/χ:entry>
98         &lt;χ:entry key="state" keyType="string">
99            &lt;χ:atomic-value type="string">NY&lt;/χ:atomic-value>
100         &lt;/χ:entry>
101         &lt;χ:entry key="city" keyType="string">
102            &lt;χ:atomic-value type="string">New York&lt;/χ:atomic-value>
103         &lt;/χ:entry>
104      &lt;/χ:map>
105   &lt;/χ:entry>
106   &lt;χ:entry key="age" keyType="string">
107      &lt;χ:atomic-value type="number">25&lt;/χ:atomic-value>
108   &lt;/χ:entry>
109   &lt;χ:entry key="firstName" keyType="string">
110      &lt;χ:atomic-value type="string">John&lt;/χ:atomic-value>
111   &lt;/χ:entry>
112&lt;/χ:map>
113</pre>
114      </div>
115      <div><h3>Map with two references to the same node</h3><p>The map defined in XSLT as:</p>
116        <pre>        &lt;xsl:variable name="node">
117            &lt;node>
118                &lt;foo/>
119                &lt;bar/>
120            &lt;/node>
121        &lt;/xsl:variable>
122        &lt;xsl:variable name="json" select="map:new(
123               (map:entry(5, 'foo'),
124               map:entry('bar', $node),
125               map:entry('bat', $node)))"/>
126</pre>
127        <p>gives the following χίμαιραλ
128        serialization:</p><pre>&lt;?xml version="1.0" encoding="UTF-8"?>
129&lt;χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
130   &lt;χ:entry key="5" keyType="number">
131      &lt;χ:atomic-value type="string">foo&lt;/χ:atomic-value>
132   &lt;/χ:entry>
133   &lt;χ:entry key="bat" keyType="string">
134      &lt;χ:node type="document" χ:id="d3">
135         &lt;node1>
136            &lt;foo/>
137            &lt;bar/>
138         &lt;/node1>
139         &lt;node2/>
140      &lt;/χ:node>
141   &lt;/χ:entry>
142   &lt;χ:entry key="bar" keyType="string">
143      &lt;χ:node χ:idref="d3" type="document"/>
144   &lt;/χ:entry>
145&lt;/χ:map>
146</pre></div>
147      <div><h3>Map representing a RDF triple</h3><p>The map defined in XSLT
148          as:</p><pre>        &lt;xsl:variable name="json" select="
149            map {
150                xs:QName('rdf:subject')   := xs:anyURI('http://www.example.org/index.html'),
151                xs:QName('rdf:predicate') := xs:anyURI('http://purl.org/dc/elements/1.1/creator'),
152                xs:QName('rdf:object')    := xs:anyURI('http://www.example.org/staffid/85740')
153            }
154           
155            "
156            xmlns:rdf="http://example.com/rdf/"/>
157</pre><p>gives
158          the following χίμαιραλ
159        serialization:</p><pre>&lt;?xml version="1.0" encoding="UTF-8"?>
160&lt;χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
161   &lt;χ:entry xmlns:rdf="http://example.com/rdf/"
162            key="rdf:subject"
163            keyType="xs:QName">
164      &lt;χ:atomic-value type="xs:anyURI">http://www.example.org/index.html&lt;/χ:atomic-value>
165   &lt;/χ:entry>
166   &lt;χ:entry xmlns:rdf="http://example.com/rdf/"
167            key="rdf:predicate"
168            keyType="xs:QName">
169      &lt;χ:atomic-value type="xs:anyURI">http://purl.org/dc/elements/1.1/creator&lt;/χ:atomic-value>
170   &lt;/χ:entry>
171   &lt;χ:entry xmlns:rdf="http://example.com/rdf/" key="rdf:object" keyType="xs:QName">
172      &lt;χ:atomic-value type="xs:anyURI">http://www.example.org/staffid/85740&lt;/χ:atomic-value>
173   &lt;/χ:entry>
174&lt;/χ:map>
175</pre></div>
176      <div><h3>Map with two instances of the same node, atomic values and other types of keys</h3><p>The map defined in XSLT
177          as:</p><pre>       &lt;xsl:variable name="node">
178            &lt;node1>
179                &lt;foo/>
180                &lt;bar/>
181            &lt;/node1>
182            &lt;node2/>
183        &lt;/xsl:variable>
184        &lt;xsl:variable name="json"
185            select="map:new((
186                map:entry(5, ('foo', 'bar')),
187                map:entry(true(), false()),
188                map:entry('sequence', ($node, $node, 2))))"/>
189</pre><p>gives
190          the following χίμαιραλ
191        serialization:</p><pre>&lt;?xml version="1.0" encoding="UTF-8"?>
192&lt;χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
193   &lt;χ:entry key="true" keyType="boolean">
194      &lt;χ:atomic-value type="boolean">false&lt;/χ:atomic-value>
195   &lt;/χ:entry>
196   &lt;χ:entry key="5" keyType="number">
197      &lt;χ:atomic-value type="string">foo&lt;/χ:atomic-value>
198      &lt;χ:atomic-value type="string">bar&lt;/χ:atomic-value>
199   &lt;/χ:entry>
200   &lt;χ:entry key="sequence" keyType="string">
201      &lt;χ:node type="document" χ:id="d3">
202         &lt;node1>
203            &lt;foo/>
204            &lt;bar/>
205         &lt;/node1>
206         &lt;node2/>
207      &lt;/χ:node>
208      &lt;χ:node χ:idref="d3" type="document"/>
209      &lt;χ:atomic-value type="number">2&lt;/χ:atomic-value>
210   &lt;/χ:entry>
211&lt;/χ:map>
212</pre></div>
213      <div><h3>Map with different types of nodes</h3><p>The map defined in XSLT
214          as:</p><pre>        &lt;xsl:variable name="nodes">
215            &lt;my-element xmlns:ns="http:example.com" ns:my-attribute="foo">
216                &lt;xsl:comment>A comment&lt;/xsl:comment>
217                &lt;xsl:processing-instruction name="A">processing instruction&lt;/xsl:processing-instruction>
218                &lt;ns:a-sub-element>bar&lt;/ns:a-sub-element>
219                &lt;![CDATA[Some text]]&gt;
220            &lt;/my-element>
221        &lt;/xsl:variable>
222        &lt;xsl:variable name="json"
223            select="map:new((
224            map:entry('doc',  $nodes),
225            map:entry('elt',  $nodes/my-element),
226            map:entry('att',  $nodes/my-element/@* ),
227            map:entry('text', $nodes/my-element/text() ),
228            map:entry('pi',   $nodes/my-element/processing-instruction() ),
229            map:entry('comment', $nodes/my-element/comment() ),
230            map:entry('ns', $nodes/my-element/namespace::* )
231            ))"/>
232</pre><p>gives
233          the following χίμαιραλ
234          serialization:</p><pre>&lt;?xml version="1.0" encoding="UTF-8"?>
235&lt;χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
236   &lt;χ:entry key="ns" keyType="string">
237      &lt;χ:node type="namespace" name="ns">http:example.com&lt;/χ:node>
238      &lt;χ:node type="namespace" name="xs">http://www.w3.org/2001/XMLSchema&lt;/χ:node>
239      &lt;χ:node type="namespace" name="χ">http://χίμαιραλ.com#&lt;/χ:node>
240      &lt;χ:node type="namespace" name="xml">http://www.w3.org/XML/1998/namespace&lt;/χ:node>
241   &lt;/χ:entry>
242   &lt;χ:entry key="text" keyType="string">
243      &lt;χ:node type="attribute">
244                Some text
245            &lt;/χ:node>
246   &lt;/χ:entry>
247   &lt;χ:entry key="doc" keyType="string">
248      &lt;χ:node type="document">
249         &lt;my-element xmlns:ns="http:example.com" χ:id="d3e1" ns:my-attribute="foo">&lt;!--A comment-->&lt;?A processing instruction?>&lt;ns:a-sub-element>bar&lt;/ns:a-sub-element>
250                Some text
251            &lt;/my-element>
252      &lt;/χ:node>
253   &lt;/χ:entry>
254   &lt;χ:entry key="att" keyType="string">
255      &lt;χ:node xmlns:ns="http:example.com" type="attribute" name="ns:my-attribute">foo&lt;/χ:node>
256   &lt;/χ:entry>
257   &lt;χ:entry key="comment" keyType="string">
258      &lt;χ:node type="comment">A comment&lt;/χ:node>
259   &lt;/χ:entry>
260   &lt;χ:entry key="pi" keyType="string">
261      &lt;χ:node type="processing-instruction" name="A">processing instruction&lt;/χ:node>
262   &lt;/χ:entry>
263   &lt;χ:entry key="elt" keyType="string">
264      &lt;χ:node χ:idref="d3e1" type="element" name="my-element"/>
265   &lt;/χ:entry>
266&lt;/χ:map>
267</pre><p>This
268          last example is a good illustration of the issues we have when we want to mix items such as maps that have no identity nor context and nodes. To some extent it is possible to use
269            <code>id/idref</code> to avoid to duplicate nodes (like we've done here with the element with <code>χ:id="d3e1"</code>) but when we need the same feature for non element nodes that becomes
270          much tickier since these nodes can't carry attributes.</p></div>
271    </div>
272   
273    <div>
274      <h2>The <a href="http://χίμαιραλ.com#">http://χίμαιραλ.com#</a> XML namespace</h2>
275      <p>The preferred prefix for this namespace is the greek letter "χ".The namespace is composed of the following elements:</p>
276      <div id="map">
277        <h3>χ:map</h3>
278        <p>An XDM 3.0 map.</p>
279        <div>
280          <h4>Attributes</h4>
281          <p>None</p>
282        </div>
283        <div>
284          <h4>Content</h4>
285          <p>χ:entry *</p>
286        </div>
287      </div>
288      <div id="item">
289        <h3>χ:entry</h3>
290        <p>An XDM 3.0 map entry.</p>
291        <div>
292          <h4>Attributes</h4>
293          <ul>
294            <li>key (mandatory for map items): the value of the item key.</li>
295            <li>keyType (mandatory for map items): the type of the item key.</li>
296            <li>valueType (mandatory for atomic values): the type of the item value.</li>
297          </ul>
298        </div>
299        <div>
300          <h4>Content</h4>
301          <p>(χ:map | χ:node | χ:atomic-value) *</p>
302          <p>One of these elements are mandatory when the valueType attribute is omitted.</p>
303        </div>
304      </div>
305      <div id="atomic-value">
306        <h3>χ:atomic-value</h3>
307        <p>An XDM atomic value</p>
308        <div>
309          <h4>Attributes</h4>
310          <ul>
311            <li>type: the type of the atomic value</li>
312          </ul>
313         </div>
314        <div>
315          <h4>Content</h4>
316          <p>The value</p>
317        </div>
318      </div>
319      <div id="node">
320        <h3>χ:node</h3>
321        <p>An XDM nodeset</p>
322        <div>
323          <h4>Attributes</h4>
324          <ul>
325            <li>χ:id: an identifier for the node</li>
326            <li>χ:idref: a reference to a node identifier</li>
327          </ul>
328          <p>These attributes are mutually exclusive.</p>
329          <ul>
330            <li>type (mandatory): node type</li>
331            <li>name (when applicable): name of the node</li>
332          </ul>
333        </div>
334        <div>
335          <h4>Content</h4>
336          <p>Depending on the node type: a value or a sequence of nodes.</p>
337        </div>
338      </div>
339    </div>
340    <div id="changelog">
341      <h2>Changelog</h2>
342      <p>This version (0.2) tries to bring the serialization closer to the terms and concepts as they have been defined in the W3C XPath specifications.</p>
343      <p>Main changes:</p>
344      <ul>
345        <li><code>χ:item</code> has been renamed <code>χ:entry</code> to match the terminology used by W3C XPath specifications.</li>
346        <li><code>χ:sequence</code> did not match any item type in XDM. It has been suppressed and as a consequence, a new element have been added: <code>χ:atomic-value</code>.</li>
347        <li>There is no such thing as a node-set in XDM 3.0. The <code>χ:nodeset</code> element has been removed and replaced by a <code>χ:node</code> element.</li>
348        <li>Replacement of <code>xml:id</code> attributes by <code>χ:id</code> attributes to avoid possible conflicts with existing xml:id in XML fragments. To be coherent, <code>idref</code> have
349          also been renamed <code>χ:idref</code>.</li>
350      </ul>
351      <p>A detailed changelog is available at <a href="http://χίμαιραλ.com/trac/log/spec/index.html">http://χίμαιραλ.com/trac/log/spec/index.html</a> as a web page and as a <a
352        href="http://χίμαιραλ.com/trac/log/spec/index.html?format=rss&amp;limit=100&amp;mode=stop_on_copy">RSS feed</a>.</p>
353    </div>
354    <div>
355      <h2>Legal Statement</h2>
356      <p>Copyright (c) 2012 Eric van der Vlist</p>
357      <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without
358        restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
359        Software is furnished to do so, subject to the following conditions:</p>
360      <ol>
361        <li>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. </li>
362        <li>The name of the authors when specified in the source files shall be kept unmodified.</li>
363      </ol>
364      <p>THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
365        NONINFRINGEMENT. IN NO EVENT SHALL ERIC VAN DER VLIST BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
366        CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
367    </div>
368  </body>
369</html>
Note: See TracBrowser for help on using the repository browser.