χίμαιραλ (chimeral) - the Chimera Language

This Version: V 0.1 (18th February 2012)

Latest Version: http://χίμαιραλ.com

This namespace: http://χίμαιραλ.com#

Editor:

About this page

This page is the home page of the χίμαιραλ (chimeral) project and the documentation of the http://χίμαιραλ.com# XML namespace.

The goal of χίμαιραλ (chimeral) is to facilitate the use of the XPath/XQuery/XSLT 3.0 data model aka XDM 3.0.

The http://χίμαιραλ.com# XML namespace defines a XML serialization format for XDM 3.0.

The name and the idea of this project comes from the presentation 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 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 informations items borrowed to XML Schema and now JSON is a chimera and that some efforts are needed to make it viable!

The http://χίμαιραλ.com# XML namespace is a first step in that direction. By providing a serialization format it gives some reality to the XDM that has been 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 class citizens by XPath/XQuery/XSLT (you can't apply templates on map items for instance) and this serialization can help do that.

The namespace URI itself (http://χίμαιραλ.com#) is a chimera, composed of letters from two different alphabets and merging concepts from two different civilizations.

Examples

The following JSON object:

{
     "firstName": "John",
     "lastName" : "Smith",
     "age"      : 25,
     "address"  :
     {
         "streetAddress": "21 2nd Street",
         "city"         : "New York",
         "state"        : "NY",
         "postalCode"   : "10021"
     },
     "phoneNumber":
     [
         {
           "type"  : "home",
           "number": "212 555-1234"
         },
         {
           "type"  : "fax",
           "number": "646 555-4567"
         }
     ]
 }

imported into XDM with the parse-json() function gives the following χίμαιραλ serialization:

<?xml version="1.0" encoding="UTF-8"?>
<χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
   <χ:item key="lastName" keyType="string" valueType="string">Smith</χ:item>
   <χ:item key="phoneNumber" keyType="string">
      <χ:map>
         <χ:item key="1" keyType="number">
            <χ:map>
               <χ:item key="number" keyType="string" valueType="string">212 555-1234</χ:item>
               <χ:item key="type" keyType="string" valueType="string">home</χ:item>
            </χ:map>
         </χ:item>
         <χ:item key="2" keyType="number">
            <χ:map>
               <χ:item key="number" keyType="string" valueType="string">646 555-4567</χ:item>
               <χ:item key="type" keyType="string" valueType="string">fax</χ:item>
            </χ:map>
         </χ:item>
      </χ:map>
   </χ:item>
   <χ:item key="address" keyType="string">
      <χ:map>
         <χ:item key="streetAddress" keyType="string" valueType="string">21 2nd Street</χ:item>
         <χ:item key="postalCode" keyType="string" valueType="string">10021</χ:item>
         <χ:item key="state" keyType="string" valueType="string">NY</χ:item>
         <χ:item key="city" keyType="string" valueType="string">New York</χ:item>
      </χ:map>
   </χ:item>
   <χ:item key="age" keyType="string" valueType="number">25</χ:item>
   <χ:item key="firstName" keyType="string" valueType="string">John</χ:item>
</χ:map>

The map defined in XSLT as:

        <xsl:variable name="node">
            <node>
                <foo/>
                <bar/>
            </node>
        </xsl:variable>
        <xsl:variable name="json" select="map:new(
               (map:entry(5, 'foo'), 
               map:entry('bar', $node), 
               map:entry('bat', $node)))"/>

gives the following χίμαιραλ serialization:

<?xml version="1.0" encoding="UTF-8"?>
<χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
   <χ:item key="5" keyType="number" valueType="string">foo</χ:item>
   <χ:item key="bat" keyType="string">
      <χ:nodeset xml:id="d3">
         <node>
            <foo/>
            <bar/>
         </node>
      </χ:nodeset>
   </χ:item>
   <χ:item key="bar" keyType="string">
      <χ:nodeset idref="d3"/>
   </χ:item>
</χ:map>

The map defined in XSLT as:

        <xsl:variable name="json" select="
            map {
                xs:QName('rdf:subject')   := xs:anyURI('http://www.example.org/index.html'),
                xs:QName('rdf:predicate') := xs:anyURI('http://purl.org/dc/elements/1.1/creator'),
                xs:QName('rdf:object')    := xs:anyURI('http://www.example.org/staffid/85740')
            }
            
            "
            xmlns:rdf="http://example.com/rdf/"/>

gives the following χίμαιραλ serialization:

<?xml version="1.0" encoding="UTF-8"?>
<χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
   <χ:item xmlns:rdf="http://example.com/rdf/"
           key="rdf:subject"
           keyType="xs:QName"
           valueType="xs:anyURI">http://www.example.org/index.html</χ:item>
   <χ:item xmlns:rdf="http://example.com/rdf/"
           key="rdf:predicate"
           keyType="xs:QName"
           valueType="xs:anyURI">http://purl.org/dc/elements/1.1/creator</χ:item>
   <χ:item xmlns:rdf="http://example.com/rdf/"
           key="rdf:object"
           keyType="xs:QName"
           valueType="xs:anyURI">http://www.example.org/staffid/85740</χ:item>
</χ:map>

The map defined in XSLT as:

       <xsl:variable name="node">
            <node1>
                <foo/>
                <bar/>
            </node1>
            <node2/>
        </xsl:variable>
        <xsl:variable name="json"
            select="map:new((
                map:entry(5, ('foo', 'bar')), 
                map:entry(true(), false()),
                map:entry('sequence', ($node, $node, 2))))"/>

gives the following χίμαιραλ serialization:

?xml version="1.0" encoding="UTF-8"?>
<χ:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:χ="http://χίμαιραλ.com#">
   <χ:item key="true" keyType="boolean" valueType="boolean">false</χ:item>
   <χ:item key="5" keyType="number">
      <χ:sequence>
         <χ:item valueType="string">foo</χ:item>
         <χ:item valueType="string">bar</χ:item>
      </χ:sequence>
   </χ:item>
   <χ:item key="sequence" keyType="string">
      <χ:sequence>
         <χ:item>
            <χ:nodeset xml:id="d3">
               <node1>
                  <foo/>
                  <bar/>
               </node1>
               <node2/>
            </χ:nodeset>
         </χ:item>
         <χ:item>
            <χ:nodeset idref="d3"/>
         </χ:item>
         <χ:item valueType="number">2</χ:item>
      </χ:sequence>
   </χ:item>
</χ:map>

The http://χίμαιραλ.com# XML namespace

The preferred prefix for this namespace is the greek letter "χ".The namespace is composed of the following elements:

χ:map

An XDM 3.0 map.

Attributes

None

Content

χ:item *

χ:sequence

An XDM 3.0 sequence.

Attributes

None

Content

χ:item *

χ:item

An XDM 3.0 map or sequence item.

Attributes

  • key (mandatory for map items): the value of the item key.
  • keyType (mandatory for map items): the type of the item key.
  • valueType (mandatory for atomic values): the type of the item value.

Content

(χ:map | χ:sequence | χ:nodeset) ?

One of these elements are mandatory when the valueType attribute is omitted.

χ:nodeset

An XDM nodeset

Attributes

  • xml:id: an identifier for the nodeset
  • idref: a reference to a nodeset identifier.

These attributes are mutually exclusive.

Content

Any element from foreign namespaces

Legal Statement

Copyright (c) 2012 Eric van der Vlist

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 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 Software is furnished to do so, subject to the following conditions:

  1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  2. The name of the authors when specified in the source files shall be kept unmodified.

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 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 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.