You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2004/02/19 02:17:21 UTC

DO NOT REPLY [Bug 27055] New: - DOM level 3 : Cannot import 2 XSD within the same namespace

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=27055>.
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=27055

DOM level 3 : Cannot import 2 XSD within the same namespace

           Summary: DOM level 3 : Cannot import 2 XSD within the same
                    namespace
           Product: Xerces2-J
           Version: 2.6.1
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Other
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: franck.schmidlin@anite.com


In a XSD schema such as:

<xs:schema targetNamespace="ABC" xmlns:abc="ABC" xmlns:b="B" xmlns:c="B" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" 
attributeFormDefault="unqualified">
  <xs:import namespace="B" schemaLocation="B.xsd"/>
  <xs:import namespace="B" schemaLocation="C.xsd"/>
  <xs:element name="A">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="B" type="b:BType"/>
        <xs:element name="C" type="c:CType"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

The second <import/> is ignored, along side the declaration for CType

Using the following code:

String strXml = "<A xmlns='ABC'><B>b</B><C>c</C></A>");
javax.xml.parsers.DocumentBuilderFactory dbf= 
javax.xml.parsers.DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setAttribute("http://xml.org/sax/features/validation",Boolean.FALSE);
dbf.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-
dtd", Boolean.FALSE);
javax.xml.parsers.DocumentBuilder parser = dbf.newDocumentBuilder();
// Load XML without validating it
Document dom = parser.parse(new org.xml.sax.InputSource(new java.io.StringReader
(strXml)));

// Now validate against arbitrary schema
org.w3c.dom.DOMConfiguration config = Document.getDomConfig();
config.setParameter("error-handler", myErrorHandler);
config.setParameter("validate", Boolean.TRUE);
config.setParameter("schema-type", "http://www.w3.org/2001/XMLSchema");
config.setParameter("schema-location", "ABC A.xsd");
Document.normalizeDocument();

I get the following parsing error:
error at (9, 46)! src-resolve: Cannot resolve the name 'c:CType' to a(n) 'type 
definition' component.

======================================
For completeness:

B.XSD

<xs:schema targetNamespace="B" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:simpleType name="BType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[bB]*"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

C.XSD

<xs:schema targetNamespace="B" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:simpleType name="CType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[cC]*"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

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

Also, everything works perfectly when importing elements from different 
namespaces:

A.XSD

<xs:schema targetNamespace="ABC" xmlns:abc="ABC" xmlns:b="B" xmlns:c="C" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" 
attributeFormDefault="unqualified">
  <xs:import namespace="B" schemaLocation="B.xsd"/>
  <xs:import namespace="B" schemaLocation="C.xsd"/>

[... as before]

C.XSD

<xs:schema targetNamespace="C"
[... as before]

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