.Net XmlValidatingReader should fail on complextypes with whitespace?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Larry

    #1

    .Net XmlValidatingReader should fail on complextypes with whitespace?

    I believe the .Net XmlValidatingRe ader 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="TRSellerB uyerData">
    <xs:complexTy pe mixed="false">
    <xs:sequence>
    <xs:element ref="BuyerSelle rReferrorFlag" minOccurs="0"
    maxOccurs="unbo unded"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    XML fragment:

    <TRSellerBuyerD ata>
    </TRSellerBuyerDa ta>

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

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


    XmlTextReader textReader = new XmlTextReader(r eader);

    textReader.Whit espaceHandling = WhitespaceHandl ing.All; //this is the
    default

    textReader.Norm alization = false; //this is the default

    XmlValidatingRe ader validatingReade r = new XmlValidatingRe ader(textReader );

    validatingReade r.ValidationTyp e = ValidationType. Schema;

    validatingReade r.Schemas.Add(s chemaCollection );

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


    -Larry
Working...