Solved

XSD schema and CALS table

Posted on 2004-10-20
4
475 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now