I need to generate a XSD from XML DataFile. My Data looks like
I am trying to generate a XSD where I don't want to specify about the elements other than T2 and T4.I need only to verify if T2 and T4 exists and the schema validation should fail if any of them does not exist. Because the data file may change tomorrow and I can add a new element <T6></T6> and I don't want to update the XSD. And also the elements can occur in any order. The elements T2 and T4 should occur only once and they are mandatory.
I am trying to use <xs:any> attribute, but I am not able to use it along with <xs:all>..
Any help is apprieciated
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
1 reply Latest Post - 2011-10-24T09:34:49Z by mukulg
Pinned topic XML Schema creation with optional elements
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2011-10-24T09:34:49Z at 2011-10-24T09:34:49Z by mukulg
mukulg 060001WFFW22 PostsACCEPTED ANSWER
Re: XML Schema creation with optional elements2011-10-24T09:34:49Z in response to nidabpWith XSD 1.0, you can't specify wild-card within <all>. With XSD 1.1 this is allowed. Here's a 1.1 schema which may solve your use case,
<xs:schema xmlns:xs= "http://www.w3.org/2001/XMLSchema"> <xs:element name= "DOCUMENTS"> <xs:complexType> <xs:sequence> <xs:element name= "DOCUMENT"> <xs:complexType> <xs:all> <xs:element name= "T2"/> <xs:element name= "T4"/> <xs:any processContents= "skip" maxOccurs= "unbounded"/> </xs:all> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>