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 "Scott Renner (JIRA)" <xe...@xml.apache.org> on 2019/01/03 16:07:00 UTC

[jira] [Commented] (XERCESJ-1613) Import with namespace is not resolved corectly

    [ https://issues.apache.org/jira/browse/XERCESJ-1613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16733179#comment-16733179 ] 

Scott Renner commented on XERCESJ-1613:
---------------------------------------

I have found the same issue in v2.12.0. I believe this is caused by a bug in org.apache.xerces.util.XMLCatalogResolver.resolveIdentifier:

{{    // The namespace is useful for resolving namespace aware}}
{{    // grammars such as XML schema. Let it take precedence over}}
{{    // the external identifier if one exists.}}
{{    String namespace = resourceIdentifier.getNamespace();}}
{{    if (namespace != null) {}}
{{        resolvedId = resolveURI(namespace);}}
{{    }}}

That is not the correct action when processing an xs:include element. We should resolve the schemaLocation hint in the xs:include element, not the namespace URI of the schema document containing the xs:include.

One possible patch is as follows:

{{    // The namespace is useful for resolving namespace aware}}
{{    // grammars such as XML schema. Let it take precedence over}}
{{    // the external identifier if one exists (except for include)}}
{{    String namespace = resourceIdentifier.getNamespace();}}
{{    XSDDescription desc = (XSDDescription)resourceIdentifier; }}
{{    if (namespace != null && desc.getContextType() != XSDDescription.CONTEXT_INCLUDE) {}}
{{        resolvedId = resolveURI(namespace);}}
{{    }}}

A workaround is to change the _uri_ element in the catalog file into a _system_ element. This is arguably incorrect – the schemaLocation hint in an xs:include element is not an external identifier – but it does work.

> Import with namespace is not resolved corectly 
> -----------------------------------------------
>
>                 Key: XERCESJ-1613
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1613
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.1 Structures
>    Affects Versions: 2.11.0
>            Reporter: Octavian Nadolu
>            Priority: Major
>
> I have a "master.xsd" schema which imports with namespace "importedSchema.xsd" schema. Then the  "importedSchema.xsd" includes a "includedSchema.xsd" schema. The import with namespace is resolved through catalog, for this I have a "catalog.xml".
> If I validate the "master.xsd" schema an error is displayed:
> src-resolve: Cannot resolve the name 'is:failureType' to a(n) 'type definition' component
> The type is defined in the included schema "includedSchema.xsd" and can be referred from the "master.xsd" schema. So there should be no error reported.
> You can reproduce the issue on the xml-schema-1.1-dev branch with the XML Schema 1.1 enabled.
> -------------------master.xsd---------------------------
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:is="imported:schema">
>     <xs:import namespace="imported:schema"/>
>     <xs:element name="elem" type="is:failureType"/>
> </xs:schema>
> -----------------------------------------------------------------
> ---------------- importedSchema.xsd ---------------
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="imported:schema">
>   <xs:include schemaLocation="includedSchema.xsd"/>
> </xs:schema>
> -----------------------------------------------------------------
> ------------------ includedSchema.xsd-----------------
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>     <xs:simpleType name="failureType">
>         <xs:restriction base="xs:integer">
>             <xs:maxExclusive value="100"/>
>             <xs:minExclusive value="0"/>
>         </xs:restriction>
>     </xs:simpleType>
> </xs:schema>
> --------------------------------------------------------------------
> ---------------------catalog.xml-------------------------------------
> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
>     <uri name="imported:schema" uri="importedSchema.xsd"/>
> </catalog>
> ---------------------------------------------------------------------------



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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