Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - Are two schemas different content models? >Thread Next - Re: References to a value of an element in another element? Re: References to a value of an element in another element?To: <ccodere@----.--->, <xmlschema-dev@--.---> Date: 1/23/2007 7:03:00 PM 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) ============================================= From noah_mendelsohn@u... Tue Jan 23 19:49:52 2007 Received: from lisa.w3.o | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
