[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-c-dev
Subject:    [jira] Created: (XERCESC-1838) Unexpected validation result when
From:       "Alexey Miroshnichenko (JIRA)" <xerces-c-dev () xml ! apache ! org>
Date:       2008-11-04 19:18:44
Message-ID: 1284503767.1225826324505.JavaMail.jira () brutus
[Download RAW message or body]

Unexpected validation result when comment is present
----------------------------------------------------

                 Key: XERCESC-1838
                 URL: https://issues.apache.org/jira/browse/XERCESC-1838
             Project: Xerces-C++
          Issue Type: Bug
          Components: Validating Parser (XML Schema)
    Affects Versions: 2.7.0
            Reporter: Alexey Miroshnichenko


Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.openuri.org/mySchema" \
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.openuri.org/mySchema" \
elementFormDefault="qualified" version="1.0">  <xsd:element name="root">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="test" type="MyType" maxOccurs="unbounded"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:complexType name="MyType">
		<xsd:simpleContent>
			<xsd:extension base="xsd:byte">
			</xsd:extension>
		</xsd:simpleContent>
	</xsd:complexType>
</xsd:schema>

document:
<?xml version="1.0" encoding="UTF-8"?>
<p1:root xmlns:p1="http://www.openuri.org/mySchema" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
             xsi:schemaLocation="http://www.openuri.org/mySchema schema.xsd">
	<p1:test><!-- text -->34</p1:test>
	<p1:test>
<!-- text -->34</p1:test>
	<p1:test>
34</p1:test>
	<p1:test>34</p1:test>
	<p1:test>
			34
</p1:test>
</p1:root>

SAX2Print output:
<?xml version="1.0" encoding="LATIN1"?>
<p1:root xsi:schemaLocation="http://www.openuri.org/mySchema schema.xsd">
        <p1:test>34</p1:test>
        <p1:test> 34
Error at file Z:\eTools\bin\Debug/instance-1.xml, line 7, char 26
  Message: Datatype error: Type:InvalidDatatypeValueException, Message:Value ' 34' \
does not match re gular expression facet '[+\-]?[0-9]+'.
</p1:test>
        <p1:test>34</p1:test>
        <p1:test>34</p1:test>
        <p1:test>34</p1:test>
</p1:root>

Note the difference between second and third 'test' element in the document: second \
has comment.

Suggested fix - in SchemaValidator::normalizeWhiteSpace function last lines:
was
    if (fCurReader->isWhitespace(*(srcPtr-1)))
        fTrailing = true;
    else
        fTrailing = false;

now
...
    if (0 != *(srcPtr) && fCurReader->isWhitespace(*(srcPtr-1)))
        fTrailing = true;
    else
        fTrailing = false;
}

Idea: isWhitespace returns 'true' for empty string, but here 'empty string' does not \
mean whitepace. Please, review.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic