[Home] [By Thread] [By Date] [Recent Entries]

  • From: Michael Kay <mike@s...>
  • To: David Lee <dlee@c...>
  • Date: Sun, 10 Nov 2013 18:33:55 +0000

> 
> { "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:element>

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

Michael Kay
Saxonica



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


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member