conditional validation based on an attribute
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 2
- Joined: Mon Mar 27, 2006 11:34 pm
conditional validation based on an attribute
Hi,
Does anybody know of an easy way in a XSD to have a validation based on an attribute from the parent node ?
My XML:
....
<product no="218">
<part type="é" />
</product>
<product no="205">
<participant>N</participant>
<part type="é">
<nb>1</nb>
</part>
</product>
...
In the XSD:
...
<xs:element name="participant" minOccurs="0" maxOccurs="1">
...
<xs:element name="part" minOccurs="1" maxOccurs="12">
The tag participant can only occur if the product no is 205, and the maxOccurs of product no 218 is 12 where is really is 10 for product no 205.
How can I do this ? I really need both to be under the "product tag", so I cannot change its name.
Thank's for help !
Does anybody know of an easy way in a XSD to have a validation based on an attribute from the parent node ?
My XML:
....
<product no="218">
<part type="é" />
</product>
<product no="205">
<participant>N</participant>
<part type="é">
<nb>1</nb>
</part>
</product>
...
In the XSD:
...
<xs:element name="participant" minOccurs="0" maxOccurs="1">
...
<xs:element name="part" minOccurs="1" maxOccurs="12">
The tag participant can only occur if the product no is 205, and the maxOccurs of product no 218 is 12 where is really is 10 for product no 205.
How can I do this ? I really need both to be under the "product tag", so I cannot change its name.
Thank's for help !
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Robert,
What you want is called cooccurence constraint and XML Schema does not support this. You can use Schematron embedded rules inside XML Schema that oXygen supports to check for your constraints or check them at application level.
See http://www.oxygenxml.com/forum/ftopic1664.html#5297 for a similar example, you have there an XML Schema with schematron embedded rules.
Best Regards,
George
What you want is called cooccurence constraint and XML Schema does not support this. You can use Schematron embedded rules inside XML Schema that oXygen supports to check for your constraints or check them at application level.
See http://www.oxygenxml.com/forum/ftopic1664.html#5297 for a similar example, you have there an XML Schema with schematron embedded rules.
Best Regards,
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service