I have a web app that has been running happily for months, and on
Saturday it suddenly decided that it no longer wanted to validate my
XML. Here is my code and sample schema, and example XML :
public void ValidateAgainst Schema(object sender, ValidationEvent Args
args)
{
blnInvalidXML = true;
}
//in page load :
XmlTextReader tr = new XmlTextReader(n ew
StringReader(st rReceivedXmlDoc ));
XmlValidatingRe ader trv = new XmlValidatingRe ader(tr);
trv.ValidationT ype = ValidationType. Schema;
trv.ValidationE ventHandler +=
new ValidationEvent Handler(this.Va lidateAgainstSc hema);
while (trv.Read())
{
}
if (blnInvalidXML == false)
{
//do stuff
}
Schema :
<?xml version="1.0" encoding="iso-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="rsp-vcn">
<xs:complexType >
<xs:sequence>
<xs:element name="auth">
<xs:complexType >
<xs:sequence>
<xs:element name="cug" type="xs:long" />
<xs:element name="pasw" type="xs:string " />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="service">
<xs:complexType >
<xs:sequence>
<xs:element name="countryco de" type="xs:string " minOccurs="1" />
<xs:element name="number" type="xs:string " minOccurs="1" />
</xs:sequence>
<xs:attribute name="type" use="required">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:enumerati on value="query" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="message_i d" type="xs:byte" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>
XML :
<?xml version="1.0" encoding="iso-8859-1" ?>
<rsp-vcn message_id="0"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "https://www.calluk.com/vcn/query.xsd">
<auth>
<cug>5790</cug>
<pasw>****</pasw>
</auth>
<service type="query">
<countrycode> 1</countrycode>
<number>7813941 801</number>
</service>
</rsp-vcn>
I can navigate to the schema in IE, and when I send through XML that the
schema should validate, it doesn't. I am stumped as this code has
worked fine for months.
Can anybody please shed any light on this?
Cheers,
Mike
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!