Solved

XSD schema and CALS table

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
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…

911 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