Question

I have xml with a tag name that contains '&' like D&G . This xml is being validated against a XSD that has element definition for nm as below

<xs:element maxOccurs="1" minOccurs="0" name="nm" type="Max70Text"/>


<xs:simpleType name="Max70Text">
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="70"/>
        </xs:restriction>
    </xs:simpleType>

in the code ....

InputStream is  = new FileInputStream(l_file);
InputStreamReader isr = new InputStreamReader(is,"UTF-8");
Source source = new StreamSource(isr);
schemaValidator.validate(source);

... i get SAX Error after the validate method is executed. How can i avoid this exception and make ampersand skip the validation.

Thanks in advance.

Was it helpful?

Solution

According to "Extensible Markup Language (XML) 1.1" (http://www.w3.org/TR/xml11/#NT-Name) '&' character is not a valid character for the element name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top