Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XSD schema and CALS table

Posted on 2004-10-20
4
Medium Priority
?
504 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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:

730 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