W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2010

RE: Recursive XSD Design

From: Michael Kay <mike@saxonica.com>
Date: Mon, 22 Mar 2010 15:16:14 -0000
To: <nickle@gmail.com>, <xmlschema-dev@w3.org>
Message-ID: <03D19612906B478289AC5008E1D12581@Sealion>
The interesting thing is that the usual reason people do
 
<field name="N" value="V"/>
 
rather than
 
<N>V</N>
 
is that they DON'T want to be constrained a schema; they somehow feel that
the "generic" (verbose) form is more extensible than the concise form.
 
You can use the generic design if you like. Personally I really don't see
the point of it. XSD 1.0 doesn't support it, in the sense that it doesn't
allow the type of V to depend on the value of N. XSD 1.1 has a feature
called "conditional type assignment" that fills this gap. But I still think
it's a curious way to design your XML.
 
Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


  _____  

From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of nickle@gmail.com
Sent: 22 March 2010 11:42
To: xmlschema-dev@w3.org
Subject: Recursive XSD Design


I'm having trouble creating an XSD for some xml.

A bit of background might help. The xml is for messaging. In particular, the
message
is designed to be simple, and designed to be cross referenced easily. At its
heart
is a recursive key value set up. 

Simple Key values are like this.

<key name="quantity">5</key>
<key name="price" representation="percentage">99.78</key>

There is an optional representation attribute where the infromation
could be represented in two different forms.

Reference Key Values are like this

<key name="currency" reference="instrument">
<id name=" INSID" system="XXXX" instance="PROD">DEM</id>
<id name=" EXTERN_ID1" system="XXXX" instance="PROD"> ext128k</id>
</key>

This form is used for foreign key references or for references to
enumerations.
The cross reference service will select out all keys with an attribute of
reference.
It will then get all possible ids for that reference, and add in additional
id
fields, and replace that sub element with the new version.

ie ".//key[@reference]" as an Xpath can get all the enumerations and
references
from the xml

Lastly there is a the recursive structure. Here the value part of the key
value,
can be a key value itself.

<key name="trade" type="trade">
<key name="value_day">1999-03-12</key>
<key name="quantity">5</key>
<key name="leg" type="leg">
<key name="rate">5.00</key>
<key name="period">3m</key>
<key name="cashflows" type="cashflows">
<key name="cashflow">10</key>
<key name="cashflow">20</key>
</key>
</key>
</key>

Now, I'm having real trouble creating an XSD for this structure.

Can anyone help?

Thanks

Nick
Received on Monday, 22 March 2010 15:16:43 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:19 GMT