[xml] Whitespace handling with schema


I have an XML document with a schema defined in it. I try to make libxml2 apply whitespace normalization as specified in the schema, but it doesn't seem to work. Here is an example:

   <contact xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'>
       <xsd:element name='contact' type='ContactType'>
          <xsd:complexType name='ContactType'>
             <xsd:element name='customer' type='collString'/>
             <xsd:element name='comment' type='collString'/>
         <xsd:simpleType name='collString'>
           <xsd:restriction base='xsd:string'>
             <xsd:whiteSpace value='collapse'/>
      <customer>Name  </customer>

The whitespace is preserved when I call xmlTextReaderConstValue(...), even though <xsd:whiteSpace value='collapse'/> is specified.

Do I need to do something more to make this work, or can my application ask whether the string can be collapsed?

PS: I did add a schema valid context created with a null pointer, like I read somewhere:
       xmlSchemaValidCtxtPtr validator = xmlSchemaNewValidCtxt(0);
xmlSchemaSetValidErrors(validator, SchemaValidityErrorFunc, SchemaValidityErrorFunc, reader);
       int rv = xmlTextReaderSchemaValidateCtxt(reader, validator, 0);
and rv is 0.


 When you get lemons, you make lemonade.
 When you get hardware, you make software.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]