[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: References to a value of an element in another element?

From: Pete Cordell <petexmldev@tech-know-ware.com>
Date: Tue, 23 Jan 2007 19:02:54 -0000
Message-ID: <000f01c73f21$19d61680$8f00a8c0@Codalogic>
To: <ccodere@ieee.org>, <xmlschema-dev@w3.org>
Re: References to a value of an element in another element?

Original Message From: "Carl Eric Codere"
> Greetings,
>         I have a simple question, but i am not sure it is possible to
> represent  it in XMLSchema, if so any help would be really appreciated.
>
> I have variable-length structure and the length of the 2nd element depends 
> on
> the value of the first element. How is it possible to specify this in
> XMLSchema?
>
> <xsd:complexType name="Chunk">
>    <xsd:sequence>
>      <xsd:element name="size"   type="xsd:integer"/>
>      <xsd:element name="data"  type="xsd:hexBinary" ?????/>
>    </xsd:sequence>
>  </xsd:complexType>
>
> The problem is with element "data", how do i specify that its length is 
> the
> value "size"???

I'm afraid this is not possible in XML Schema alone.  Including additional 
Schematron constraints may be able to help.

(FWIW - XSD 1.1, that is currently being developed, supports co-constraints 
such as this.  But I'm not sure it would support the type of co-constraint 
that you require here.)

HTH,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================
Received on Tuesday, 23 January 2007 19:05:02 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.