Frank,
this looks the same error reported as jira# 1533 (http://issues.apache.org/jira/browse/XERCESC-1533): you can get the diff from http://svn.apache.org/viewcvs.cgi?rev=359081&view=rev

Hope this helps,
Alberto

At 11:24 AM 2/22/2006 -0800, Xiaofan Zhou wrote:
Hi, All,

I am using the SAX parser from xerces-c (version 2.7) to parse XML file. I have one case related to an attribtue with default value defined in the schema (I pasted the instance document and the schema in this message). When I parse the instance document, I noticed the following:

If I turn on parser validation (for which I use loadGrammar to give the parser the test.xsd), for the two elements <image>, from the SAX startElement event, I got one attribtue for each, and have the following values:

 For the first <image> element:

URI QName LocalName Value

=========================================================================================

<http://www.attribute-examples.org>http://www.attribute-examples.org src src <http://www.xfront.com>http://www.xfront.com

 For the second <image> element

URI QName LocalName Value

==================================================================================

<http://www.attribute-examples.org>http://www.attribute-examples.org i:src src <http://www.xfront.com/BestPractices.html>http://www.xfront.com/BestPractices.html However, if I turn off parser validation, I got two attributes for the second <image> element from the SAX startElement event as below:

URI QName LocalName Value

==================================================================================

<http://www.attribute-examples.org>http://www.attribute-examples.org i:src src <http://www.xfront.com/BestPractices.html>http://www.xfront.com/BestPractices.html http://www.attribute-examples.org src src <http://www.xfront.com>http://www.xfront.com
I would expect consistence between the two senarios, am I right?

Thanks much.
Frank

instance XML doc
=========
<?xml version="1.0"?>
<AttributeExamples xmlns="<http://www.attribute-examples.org>http://www.attribute-examples.org"; xmlns:i="<http://www.attribute-examples.org>http://www.attribute-examples.org"; xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="<http://www.attribute-examples.org test.xsd>http://www.attribute-examples.org test<http://www.attribute-examples.org test.xsd>.xsd"> <image/> <!-- Using the default value --> <image i:src="<http://www.xfront.com/BestPractices.html"/>http://www.xfront.com/BestPractices.html"/> <!-- Not using the default value -->
</AttributeExamples>

schema test.xsd
============
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="<http://www.w3.org/2001/XMLSchema>http://www.w3.org/2001/XMLSchema"; targetNamespace="<http://www.attribute-examples.org>http://www.attribute-examples.org"; xmlns="<http://www.attribute-examples.org>http://www.attribute-examples.org";
            elementFormDefault="qualified">

    <xsd:element name="image">
        <xsd:complexType>
<xsd:attribute ref="src" default="<http://www.xfront.com"/>http://www.xfront.com"/>
        </xsd:complexType>
    </xsd:element>

    <xsd:attribute name="src" type="xsd:anyURI"/>

    <xsd:element name="AttributeExamples">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="image" maxOccurs="2"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

</xsd:schema>


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

Reply via email to