You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Bill Yan (JIRA)" <xe...@xml.apache.org> on 2007/08/02 05:09:53 UTC

[jira] Created: (XERCESC-1728) Element defined in the imported schema file can not be correctly referred to

Element defined in the imported schema file can not be correctly referred to
----------------------------------------------------------------------------

                 Key: XERCESC-1728
                 URL: https://issues.apache.org/jira/browse/XERCESC-1728
             Project: Xerces-C++
          Issue Type: Bug
          Components: Validating Parser (Schema) (Xerces 1.5 or up only)
    Affects Versions: 2.7.0
         Environment: Windows XP
            Reporter: Bill Yan


There are there schema files in the following:
testelemref.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="ns2" xmlns:nm1="ns1" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:import namespace="ns1" schemaLocation="testelemref1.xsd"/>
	<xs:element name="elem3">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="nm1:elem1"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>

testelemref1.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n0="ns1" xmlns:n1="ns2" targetNamespace="ns1" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:import namespace="ns2" schemaLocation="testelemref2.xsd"/> 
	<xs:element name="elem1">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="n0:elem2" minOccurs="0"/>
				<xs:element ref="n1:elem4" minOccurs="0"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="elem2" type="xs:string"/>
</xs:schema>

testelemref2.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:nm1="ns2">
	<xs:element name="elem4" type="xs:string"/>
</xs:schema>

When I use XercesDOMParser::loadGrammar() to check the validity of testelemref.xsd, the following error is reported:
"Type not found in ns2:elem4 - Line 8, Col 47"
but when I use XMLSpy to check, it's valid, no error is found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1728) Element defined in the imported schema file can not be correctly referred to

Posted by "Boris Kolpackov (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517206 ] 

Boris Kolpackov commented on XERCESC-1728:
------------------------------------------

XMLSpy is well-known for its non-conforming schema processor. As such it cannot be used as a reference. I am not sure whether it is legal or not to reference a type from a namespace without an explicit import directive for that namespace. I suggest that you at least check it with a schema processor other than XMLSpy and better yet post your example to the xmlschema-dev@w3.org mailing list.

> Element defined in the imported schema file can not be correctly referred to
> ----------------------------------------------------------------------------
>
>                 Key: XERCESC-1728
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1728
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP
>            Reporter: Bill Yan
>
> There are there schema files in the following:
> testelemref.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="ns2" xmlns:nm1="ns1" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns1" schemaLocation="testelemref1.xsd"/>
> 	<xs:element name="elem3">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="nm1:elem1"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> testelemref1.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n0="ns1" xmlns:n1="ns2" targetNamespace="ns1" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns2" schemaLocation="testelemref2.xsd"/> 
> 	<xs:element name="elem1">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="n0:elem2" minOccurs="0"/>
> 				<xs:element ref="n1:elem4" minOccurs="0"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> 	<xs:element name="elem2" type="xs:string"/>
> </xs:schema>
> testelemref2.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:nm1="ns2">
> 	<xs:element name="elem4" type="xs:string"/>
> </xs:schema>
> When I use XercesDOMParser::loadGrammar() to check the validity of testelemref.xsd, the following error is reported:
> "Type not found in ns2:elem4 - Line 8, Col 47"
> but when I use XMLSpy to check, it's valid, no error is found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1728) Element defined in the imported schema file can not be correctly referred to

Posted by "Alberto Massari (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517296 ] 

Alberto Massari commented on XERCESC-1728:
------------------------------------------

Scott,
the issue you are referring is a different one, and it's a bug (setExternalSchemaLocation should take the precedence on the xsi:schemaLocation attribute). In this case the namespace "ns2" is associated with the first schema, and "ns1" with the second one; when the second schema tries to import the third one as namespace "ns2", Xerces ignores the hint because it already saw it, and use the first schema only (hence, the 'missing type' error). I used the term "strict" because of this statement in the specs:

Note: The above (paragraph 4.2.3 , Schema Representation Constraint: Import Constraints and Semantics) is carefully worded so that multiple <import>ing of the same schema document will not constitute a violation of clause 2 of Schema Properties Correct (3.15.6), but applications are allowed, indeed encouraged, to avoid <import>ing the same schema document more than once to forestall the necessity of establishing identity component by component. Given that the schemaLocation [attribute] is only a hint, it is open to applications to ignore all but the first <import> for a given namespace,

Xerces takes the road of "applications are encouraged to avoid importing the same schema document more than once" and "applications can ignore all but the first import for a given namespace".

Alberto


> Element defined in the imported schema file can not be correctly referred to
> ----------------------------------------------------------------------------
>
>                 Key: XERCESC-1728
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1728
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP
>            Reporter: Bill Yan
>
> There are there schema files in the following:
> testelemref.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="ns2" xmlns:nm1="ns1" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns1" schemaLocation="testelemref1.xsd"/>
> 	<xs:element name="elem3">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="nm1:elem1"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> testelemref1.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n0="ns1" xmlns:n1="ns2" targetNamespace="ns1" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns2" schemaLocation="testelemref2.xsd"/> 
> 	<xs:element name="elem1">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="n0:elem2" minOccurs="0"/>
> 				<xs:element ref="n1:elem4" minOccurs="0"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> 	<xs:element name="elem2" type="xs:string"/>
> </xs:schema>
> testelemref2.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:nm1="ns2">
> 	<xs:element name="elem4" type="xs:string"/>
> </xs:schema>
> When I use XercesDOMParser::loadGrammar() to check the validity of testelemref.xsd, the following error is reported:
> "Type not found in ns2:elem4 - Line 8, Col 47"
> but when I use XMLSpy to check, it's valid, no error is found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1728) Element defined in the imported schema file can not be correctly referred to

Posted by "Scott Cantor (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517298 ] 

Scott Cantor commented on XERCESC-1728:
---------------------------------------

Yep, you're right, I didn't realize the use of "ns2" above was meant literally as a stand-in for a full namespace that would have to map to two different schemas, and that's certainly wrong. So, never mind. ;-)


> Element defined in the imported schema file can not be correctly referred to
> ----------------------------------------------------------------------------
>
>                 Key: XERCESC-1728
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1728
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP
>            Reporter: Bill Yan
>
> There are there schema files in the following:
> testelemref.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="ns2" xmlns:nm1="ns1" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns1" schemaLocation="testelemref1.xsd"/>
> 	<xs:element name="elem3">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="nm1:elem1"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> testelemref1.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n0="ns1" xmlns:n1="ns2" targetNamespace="ns1" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns2" schemaLocation="testelemref2.xsd"/> 
> 	<xs:element name="elem1">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="n0:elem2" minOccurs="0"/>
> 				<xs:element ref="n1:elem4" minOccurs="0"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> 	<xs:element name="elem2" type="xs:string"/>
> </xs:schema>
> testelemref2.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:nm1="ns2">
> 	<xs:element name="elem4" type="xs:string"/>
> </xs:schema>
> When I use XercesDOMParser::loadGrammar() to check the validity of testelemref.xsd, the following error is reported:
> "Type not found in ns2:elem4 - Line 8, Col 47"
> but when I use XMLSpy to check, it's valid, no error is found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (XERCESC-1728) Element defined in the imported schema file can not be correctly referred to

Posted by "Alberto Massari (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESC-1728?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alberto Massari resolved XERCESC-1728.
--------------------------------------

    Resolution: Invalid

Xerces implements the xs:import in a strict way, i.e. each namespace must be imported only from one URL. Your schema don't follow this guideline, as testelemref1.xsd imports namespace ns2 from testelemref2.xsd, while its root would be testelemref.xsd.
If you change testelemref.xsd to do

	<xs:include schemaLocation="testelemref2.xsd"/>
	<xs:import namespace="ns1" schemaLocation="testelemref1.xsd"/>
	<xs:element name="elem3">
        ...

and testelemref1.xsd to do

	<xs:import namespace="ns2" schemaLocation="testelemref.xsd"/>
	<xs:element name="elem1">
		<xs:complexType>
        ....

Xerces will treat them as valid.

Alberto

> Element defined in the imported schema file can not be correctly referred to
> ----------------------------------------------------------------------------
>
>                 Key: XERCESC-1728
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1728
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP
>            Reporter: Bill Yan
>
> There are there schema files in the following:
> testelemref.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="ns2" xmlns:nm1="ns1" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns1" schemaLocation="testelemref1.xsd"/>
> 	<xs:element name="elem3">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="nm1:elem1"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> testelemref1.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n0="ns1" xmlns:n1="ns2" targetNamespace="ns1" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns2" schemaLocation="testelemref2.xsd"/> 
> 	<xs:element name="elem1">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="n0:elem2" minOccurs="0"/>
> 				<xs:element ref="n1:elem4" minOccurs="0"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> 	<xs:element name="elem2" type="xs:string"/>
> </xs:schema>
> testelemref2.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:nm1="ns2">
> 	<xs:element name="elem4" type="xs:string"/>
> </xs:schema>
> When I use XercesDOMParser::loadGrammar() to check the validity of testelemref.xsd, the following error is reported:
> "Type not found in ns2:elem4 - Line 8, Col 47"
> but when I use XMLSpy to check, it's valid, no error is found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1728) Element defined in the imported schema file can not be correctly referred to

Posted by "Scott Cantor (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517287 ] 

Scott Cantor commented on XERCESC-1728:
---------------------------------------

I would dispute this characterization of Xerces as "strict". It's a bug. If I override schemaLocation in my code, I do not want nor expect Xerces to look at any schema location hints in any documents. This is a longstanding bug in Xerces.

Locations in documents are not normative, only the namespace is. Anything else is just a hint to editing tools.


> Element defined in the imported schema file can not be correctly referred to
> ----------------------------------------------------------------------------
>
>                 Key: XERCESC-1728
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1728
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP
>            Reporter: Bill Yan
>
> There are there schema files in the following:
> testelemref.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="ns2" xmlns:nm1="ns1" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns1" schemaLocation="testelemref1.xsd"/>
> 	<xs:element name="elem3">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="nm1:elem1"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> testelemref1.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n0="ns1" xmlns:n1="ns2" targetNamespace="ns1" elementFormDefault="qualified" attributeFormDefault="unqualified">
> 	<xs:import namespace="ns2" schemaLocation="testelemref2.xsd"/> 
> 	<xs:element name="elem1">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="n0:elem2" minOccurs="0"/>
> 				<xs:element ref="n1:elem4" minOccurs="0"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> 	<xs:element name="elem2" type="xs:string"/>
> </xs:schema>
> testelemref2.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="ns2" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:nm1="ns2">
> 	<xs:element name="elem4" type="xs:string"/>
> </xs:schema>
> When I use XercesDOMParser::loadGrammar() to check the validity of testelemref.xsd, the following error is reported:
> "Type not found in ns2:elem4 - Line 8, Col 47"
> but when I use XMLSpy to check, it's valid, no error is found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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