XSD1.1 validation
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 1
- Joined: Thu Mar 15, 2018 9:44 am
XSD1.1 validation
Hi,
I am new to XML and XSD validations
Below is my input xml
<ApplicationDetail>
<AppControlNumber>123</AppControlNumber>
<SourceCode>123</SourceCode>
<FormCode>254</FormCode>
</ApplicationDetail>
I need to validate this but the condition is as follows
------VALID CASES----
Condition1: If value in AppControlNumber tag is present then it should be valid
Condition2: If value in AppControlNumber tag & SourceCode is present then it should be valid
Condition3: If value in AppControlNumber tag & FormCode is present then it should be valid
Condition4: If value in AppControlNumber tag,SourceCode & FormCodeis present then it should be valid
Condition5: If value in SourceCode tag & FormCode is present then it should be valid
** i am not able to implement condition5
i have validated 4 conditions with xsd
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="xml">
<xs:complexType>
<xs:sequence>
<xs:element name="ApplicationDetail">
<xs:complexType>
<xs:sequence>
<xs:element name="AppControlNumber" minOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:short"/>
</xs:simpleType>
</xs:element>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="SourceCode" minOccurs="1">
<xs:simpleType>
<xs:restriction base='xs:string'>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FormCode" minOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I tried XSD 1.1 to validate condition 5 but the solution isn't proper.Can someone help me preparing a schema which validates all the above rules.
Thanks
Gunjan
I am new to XML and XSD validations
Below is my input xml
<ApplicationDetail>
<AppControlNumber>123</AppControlNumber>
<SourceCode>123</SourceCode>
<FormCode>254</FormCode>
</ApplicationDetail>
I need to validate this but the condition is as follows
------VALID CASES----
Condition1: If value in AppControlNumber tag is present then it should be valid
Condition2: If value in AppControlNumber tag & SourceCode is present then it should be valid
Condition3: If value in AppControlNumber tag & FormCode is present then it should be valid
Condition4: If value in AppControlNumber tag,SourceCode & FormCodeis present then it should be valid
Condition5: If value in SourceCode tag & FormCode is present then it should be valid
** i am not able to implement condition5
i have validated 4 conditions with xsd
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="xml">
<xs:complexType>
<xs:sequence>
<xs:element name="ApplicationDetail">
<xs:complexType>
<xs:sequence>
<xs:element name="AppControlNumber" minOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:short"/>
</xs:simpleType>
</xs:element>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="SourceCode" minOccurs="1">
<xs:simpleType>
<xs:restriction base='xs:string'>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FormCode" minOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I tried XSD 1.1 to validate condition 5 but the solution isn't proper.Can someone help me preparing a schema which validates all the above rules.
Thanks
Gunjan
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: XSD1.1 validation
Hello Gunjan,
A solution can be to make the AppControlNumber, SourceCode, FormCode elements optional (minOccurs="0") in a sequence, as in the example below. I don't know all the invalid/valid cases for you XML instance, so it is hard to create a schema. Also I suggest you to ask this questions on Stackoverflow or on the XML Schema mailing list (xmlschema-dev at w3 dot org), there are more experienced people there.
You can use also our Generate/Convert Schema tool to generate an XSD schema from an XML file, or from multiple XML files.
Best Regards,
Octavian
A solution can be to make the AppControlNumber, SourceCode, FormCode elements optional (minOccurs="0") in a sequence, as in the example below. I don't know all the invalid/valid cases for you XML instance, so it is hard to create a schema. Also I suggest you to ask this questions on Stackoverflow or on the XML Schema mailing list (xmlschema-dev at w3 dot org), there are more experienced people there.
You can use also our Generate/Convert Schema tool to generate an XSD schema from an XML file, or from multiple XML files.
Code: Select all
<xs:sequence>
<xs:element name="AppControlNumber" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:short"/>
</xs:simpleType>
</xs:element>
<xs:element name="SourceCode" minOccurs="0">
<xs:simpleType>
<xs:restriction base='xs:string'>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FormCode" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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