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 "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2005/06/24 01:48:12 UTC

[jira] Resolved: (XERCESJ-893) DOM level 3 : Cannot import 2 XSD within the same namespace

     [ http://issues.apache.org/jira/browse/XERCESJ-893?page=all ]
     
Michael Glavassevich resolved XERCESJ-893:
------------------------------------------

    Resolution: Fixed
     Assign To:     (was: Xerces-J Developers Mailing List)

In Xerces 2.7.0 we defined a new feature called http://apache.org/xml/features/honour-all-schemaLocations. When this feature is set to true, all schema location hints will be used to locate the components for a given target namespace, so if there are multiple imports for the same namespace Xerces will access all of the schema locations provided.

> DOM level 3 : Cannot import 2 XSD within the same namespace
> -----------------------------------------------------------
>
>          Key: XERCESJ-893
>          URL: http://issues.apache.org/jira/browse/XERCESJ-893
>      Project: Xerces2-J
>         Type: Bug
>   Components: Other
>     Versions: 2.6.1
>  Environment: Operating System: Windows NT/2K
> Platform: PC
>     Reporter: Franck Schmidlin
>  Attachments: A.xsd, B.xsd, C.xsd
>
> 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]

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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