DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7297>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7297

validation of schema included in document fails with improper error

           Summary: validation of schema included in document fails with
                    improper error
           Product: Xerces-C++
           Version: 1.7.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: Validating Parser (Schema) (Xerces 1.5 or up only)
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


A validating parse of a document that includes schemas yields a bogus error in 
the second schema.  Here's the schema for my test document:

---
<schema targetNamespace='http://www.fred.com'
    xmlns='http://www.w3.org/2001/XMLSchema'
    xmlns:root='http://www.fred.com'
    elementFormDefault='qualified'
    version='1.0.0'>

    <element name='root'>
        <complexType>
            <sequence maxOccurs='unbounded'>
                <element name='schema-content'>
                    <complexType>
                        <sequence>
                            <any namespace='http://www.w3.org/2001/XMLSchema' 
processContents='lax'/>
                        </sequence>
                    </complexType>
                </element>
            </sequence>
        </complexType>
    </element>
</schema>
---

And here's the test document:

---
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xsi:schemaLocation='http://www.fred.com ./Root.xsd'
    xmlns:root='http://www.fred.com'
    xmlns='http://www.fred.com'>
    <schema-content>
        <schema targetNamespace='http://www.fred.com/barney'
            xmlns='http://www.w3.org/2001/XMLSchema'
            xmlns:barney='http://www.fred.com/barney'
            elementFormDefault='qualified'
            version='1.0.0'>

            <simpleType name='TestValue'>
                <restriction base='normalizedString'>
                    <enumeration value='value-1'/>
                    <enumeration value='value-2'/>
                    <enumeration value='value-3'/>
                    <enumeration value='empty-value'/>
                </restriction>
            </simpleType>
        </schema>
    </schema-content>
    <schema-content>
        <schema targetNamespace='http://www.fred.com/fred'
            xmlns='http://www.w3.org/2001/XMLSchema'
            xmlns:fred='http://www.fred.com/fred'
            elementFormDefault='qualified'
            version='1.0'>

            <complexType name='TestType'>
                <sequence>
                    <element name='child' type='string' minOccurs='0' 
maxOccurs='unbounded'/>
                </sequence>
            </complexType>

            <element name='root' type='fred:TestType'/>
        </schema>
    </schema-content>
</root>
---

I parse it with this code:

---
int wmain(int argc, wchar_t* argv[])
{
    int nResult = 0;

    if (argc != 2)
    {
        std::wcout << L"Usage is:  XmlParse <filename>" << std::endl;
    }
    else
    {
        try
        {
            DOMParser parser;
            CMySaxErrorHandler myErrHandler;

            // Configure parser for a validating parse.
            parser.setDoSchema(true);
            parser.setValidationScheme(DOMParser::Val_Auto);
            parser.setDoNamespaces(true);
            parser.setErrorHandler(&myErrHandler);

            std::wcout << L"Parsing file " << argv[1] << L"..." << std::endl;

            parser.parse(LocalFileInputSource(argv[1]));
        }
        catch (const CMyException& e)
        {
            std::wcout << e << std::endl;
            nResult = e.GetCode();
        }
    }

        return nResult;
}
---

With the test document and this code, I land in the catch block, and generate 
this error:

---
Parse operation:  Error parsing file "C:\tim\dev\Playground\XmlStuff\test.xml",
line 28, column 27
   Message: Attribute '{}targetNamespace' is not declared for element 'schema';
error = 0x2
---

It doesn't matter which schema is second.  Whatever schema you insert in the 
document after the first one will yield an error referencing the first 
attribute of the <schema> element.  If you remove the second schema from the 
document, it will parse without errors.

I get this same behavior in Xerces C++ 1.6.0.

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

Reply via email to