Hojoformo
asked on
How to validate an XML Fragment against a Schema using the XMLReader
Using the XMLReader, can someone show me an example of validating an XML Fragment against an XML schema? I want to ensure that the value of this field is valid according the schema. If this can be done, can you please demonstrate.
My Xml fragment that I want to validate.
<Weights UOM="PG">
<Weight>5.50</Weight>
<DimensionalWeight>7.192</ Dimensiona lWeight>
</Weights>
Portion of MYSchema.xsd
<xs:element name="Width">
<xs:annotation>
<xs:documentation>5.9.8 (Ref H30)</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minExclusive value="0"/>
<xs:totalDigits value="8"/>
<xs:fractionDigits value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
My Xml fragment that I want to validate.
<Weights UOM="PG">
<Weight>5.50</Weight>
<DimensionalWeight>7.192</
</Weights>
Portion of MYSchema.xsd
<xs:element name="Width">
<xs:annotation>
<xs:documentation>5.9.8 (Ref H30)</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minExclusive value="0"/>
<xs:totalDigits value="8"/>
<xs:fractionDigits value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.