Validate XSD with XML .
Posted
by munish
on Stack Overflow
See other posts from Stack Overflow
or by munish
Published on 2010-06-11T10:27:09Z
Indexed on
2010/06/11
10:33 UTC
Read the original article
Hit count: 354
I want to know how to validate XML with XSD . XML is not of an element type but a complex type . Since validator class's validate method compare only element type.
So basically I want to valide XSD's complex type with an XML.
e.g.
Basic XSD below
xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="Dob" type="xs:date" />
<xs:element name="Address">
<xs:complexType>
<xs:sequence>
<xs:element name="Line1" type="xs:string" />
<xs:element name="Line2" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
We can assume we have multiple complex type in the Customer element.
MY XML is
<Address>
<Line1>34 thingy street, someplace</Line1>
<Line2>sometown, w1w8uu </Line2>
</Address>
How I validate my XML with XSD. Kindly post your suggestions in java
© Stack Overflow or respective owner