repost-.Net XmlValidatingReader should fail on complextypes withwhitespace?

Larry (archive)

Usenet Archive
Joined
Jan 13, 2000
Messages
241
Reaction score
0
Reposting due to lack of response - I believe the .Net
XmlValidatingReader should fail when validating XML that contains a ComplexType element with white space when the ComplexType element has the mixed attribute set to false in the XSD used for validation.

XSD fragment:

<xs:element name="TRSellerBuyerData">
<xs:complexType mixed="false">
<xs:sequence>
<xs:element ref="BuyerSellerReferrorFlag" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element>

XML fragment:

<TRSellerBuyerData>
</TRSellerBuyerData>

XML Spy will catch the valdation error and report: "Text not allowed inside element 'TRSellerBuyerData'

But the following code does not catch the validation error. Is this a bug in XmlValidatingReader - or am I missing code to catch this? I assume by XSD is correct since XmlSpy catches the error.

XmlTextReader textReader = new XmlTextReader(reader);

textReader.WhitespaceHandling = WhitespaceHandling.All; //this is the default

textReader.Normalization = false; //this is the default

XmlValidatingReader validatingReader = new XmlValidatingReader(textReader);

validatingReader.ValidationType = ValidationType.Schema;

validatingReader.Schemas.Add(schemaCollection);

try
{
while(validatingReader.Read);
}
catch(Exception ex)
{
Debug.WriteLine(ex.Message);
}

-Larry
 

Yan Leshinsky

Usenet Archive
Joined
Jun 10, 2004
Messages
1
Reaction score
0
I think this is a bug in XML Spy - non-significant whitespace should be ignored. Following instance will give you an error:
<TRSellerBuyerData xml:space="preserve">
</TRSellerBuyerData>

Yan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top