OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Best options for converting JSON to XML

> { "a json name" : 1 }                ->
> <object>
>    <member name="a json name">< value type="Number">123</value></<member>
> </object>
> "For every member element with an attribute named 'name' with a value "a json name" it must have a single child 
> element "value" with a "type" attribute  with the value "Number" and its text contents must follow the constraints of xs:decimal
> This is difficult or impossible to express in common XML schema languages 
> (I think you could do it in schematron though ... painfully,  maybe WC3 schema 1.1 with assertions ?)

I don't think it's that painful in XSD 1.1 with conditional type assignment (well, no more painful than anything else in XSD, anyway):

<xs:element name="member">
    <xs:alternative test="@name='a json name'" type="jsonNumber"/>
    <xs:alternative test="@name='another json name'" type="jsonBoolean"/>

<xs:complexType name="jsonNumber">
   <xs:element name="Value">
         <xs:extension base="xs:double">
           <xs:attribute name="type" fixed="Number"/>

Michael Kay

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS