Solved

XSD schema and CALS table

Posted on 2004-10-20
4
482 Views
Last Modified: 2013-11-19
Hi

Is it possible to have an XSD schema validate an XML document and check whether attributes of some elements are in a list of attributes defined in another set of elements in the same XML file.

For example:

Defined list

<tgroup cols="6">
      <colspec colnum="1" colname="col1"/>
      <colspec colnum="2" colname="col2"/>
      <colspec colnum="3" colname="col3"/>
      <colspec colnum="4" colname="col4"/>
      <colspec colnum="5" colname="col5"/>
      <colspec colnum="6" colname="col6"/>

.....the rest of the file...

Part of a table
      <entry colname="col3">4 &amp; 7</entry>
      <entry colname="col4"/>
      <entry colname="col5">1500-1600 &#8486; approx.</entry>

I want the schema to only allow entry elements to have colname attributes with values defined in the colname attributes of the colspec elements.

The number of colspec elements varies form one XML file to another so it is not really possible to use enumeration values based on restriction type NMTOKEN

Can anyone help please?

Thanks

John
0
Comment
Question by:nhoj
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
rdcpro earned 500 total points
ID: 12362185
This is called a co-occurance constraint, and it's not possible in W3C XML Schema.  You can do this with Schematron or RelaxNG, which uses XSLT internally to provide this functionality.  Most of the time, when we want to use W3C XML Schema with this type of constraint, we enforce this externally with some sort of business rule validation.  So you validate the document with the Schema to check the types, then check the co-occurance constraints using a second step.  

Regards,
Mike Sharp
0
 
LVL 26

Expert Comment

by:rdcpro
ID: 12362212
BTW, I meant Schematron uses an internal XSLT for this...Frankly I don't know how RelaxNG does it, but I wouldn't be surprised if it did it the same way.  

Regards,
Mike Sharp
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create associate webpages / websites 3 80
Problem to event 3 97
Excel file not created as expected 7 72
what are list of ebay api errors 1 19
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question