W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2009

different whitespace-collapse behaviour of parsers

From: Dieter Guthmann <mailing-deg@bup-nbg.de>
Date: Thu, 12 Mar 2009 17:35:04 +0100
Message-ID: <49B939B8.1080906@bup-nbg.de>
To: xmlschema-dev@w3.org

I've tested a few XML-Parsers/Validators and discovered that the
restriction "whiteSpace=collapse" [1] is interpreted in two different ways.

"Liquid XML Studio 2009" treats a whitespace-only string within a tag
not as trailing/leading whitespace [1]:
"<tag>    \n   </tag>" will be transformed in "<tag> </tag>" before
validation (or it seems so),
whereas the other parsers I've tested (Altova XML Spy, XMLmind XML
Editor, W3C XSV) will transform
"<tag>    \n   </tag>" to "<tag></tag>"

Which behaviour is the correct one? See below for a schema example.

Best Regards,
Dieter Guthmann

[1] <http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#rf-whiteSpace>

Below an Example:
------- begin mysschema.xsd -------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema elementFormDefault="qualified"
  <xs:simpleType name="nocontent">
    <xs:restriction base="xs:string">
      <xs:whiteSpace value="collapse" />
      <xs:pattern value="" />
      <!-- This line above will not work in  Liquid XML... replace
"value" with "[ ]" and it will work -->
  <xs:element name="customerdatabase">
        <xs:element ref="customer" />
  <xs:element name="customer">
        <xs:extension base="nocontent">
          <xs:attribute name="name" type="xs:string" />
------- end myschema.xsd -------

------- begin myxmlfile.xml -------
<?xml version="1.0" encoding="UTF-8"?>
<customerdatabase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  <customer name="test">
------- end myxmlfile.xml -------
Received on Friday, 13 March 2009 01:00:41 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:15 UTC