XSD combining 2 elements
Are you missing a feature? Request its implementation here.
XSD combining 2 elements
Hi,
I've got al list of possible combinations of brands and models
I want to use xsd to verify if the combination is ok
can I do this using XSD?
thanks
example:
xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="CAR">
<xs:complexType>
<xs:all>
<xs:element name="BRAND" />
<xs:element name="MODEL" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
xml:
<CAR>
<BRAND>MASERATI</BRAND>
<MODEL>DB9</BRAND>
</CAR>
I've got al list of possible combinations of brands and models
I want to use xsd to verify if the combination is ok
can I do this using XSD?
thanks
example:
xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="CAR">
<xs:complexType>
<xs:all>
<xs:element name="BRAND" />
<xs:element name="MODEL" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
xml:
<CAR>
<BRAND>MASERATI</BRAND>
<MODEL>DB9</BRAND>
</CAR>
Hi,
AFAIK you cannot do that with XML Schema. You can check only that an element contains values in a specified set if you restrict the values using enumeration for instance:
Oxygen also supports Relax NG schemas. Relax NG should allow you to check brands/models. Also as an alternative you may consider writting an XSLT to check this.
Best Regards,
George
AFAIK you cannot do that with XML Schema. You can check only that an element contains values in a specified set if you restrict the values using enumeration for instance:
Code: Select all
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="CAR">
<xs:complexType>
<xs:all>
<xs:element name="BRAND">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="MASERATI"/>
<!-- add all your possible values here -->
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="MODEL">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="DB9"/>
<!-- add all your possible values here -->
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
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