Solved

XSD schema and CALS table

Posted on 2004-10-20
4
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

632 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