I'm not sure if this is a bug or a feature, so decided to discuss this
matter here.

It appears that XML scanner does not pass data from CDATA section to
schema validator and thus it can not perform any sort of validation on the
corresponding element's value.

Here's an example:

************** sample.xml ****************
<?xml version="1.0"?>
<xscRoot
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:noNamespaceSchemaLocation="sample.xsd">
        <ExternallyVisible>yes</ExternallyVisible>
        <ListeningStates>
                <state>a-state-1</state>
                <hello><![CDATA[unsl]]></hello>
                <state>a-state-2</state>
        </ListeningStates>
</xscRoot>
******************************************
*************** sample.xsd ***************
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>

<xsd:element name="xscRoot">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="ExternallyVisible" type="xsd:string"/>
      <xsd:element name="ListeningStates">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="state" type="xsd:string"/>
            <xsd:element name="hello">
              <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                  <xsd:minLength value="3"/>
                  <xsd:maxLength value="6"/>
                </xsd:restriction>
              </xsd:simpleType>
            </xsd:element>
            <xsd:element name="state" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

</xsd:schema>
***********************************


my expectation was that "unsl" would be determined as a content of "hello"
element and the XML document would be found to confrom to the XML schema
by the xerces, but the schema validation actually failed, saying that
length of '0' violates minLength restriction of '3'.

I think this happens because in scanCDSection() (in XMLScanner2.cpp) data
collected from CDATA section is not passed to validator.
I've tried to search through W3 XML documentation and on the Internet in
general, but couldn't find any special considerations for validation of
CDATA content. So my assumption is that it should be given as-is to the
validator and should be validated as a regular element content.

BTW, I am using xerces-c 1.7, but it looks like the corresponding code is
pretty much the same in 2.1.


-- 
Andriy Gapon
*
"...the last thing we need is a new production strategy for cats."
Wayne Pacelle, senior vice president, The Humane Society of the United States

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to