At 13.01 12/09/2006 -0700, Frank Zhou wrote:
Hi All,
I have the attached simple schemas a, b, and c, in
which a import b, and b import c, a and c have the
same target namespace, but b have a different target
namespace.
[...]
I always get the type not found error for a type
defined in schema.
However, if I use schema b as the root, I don't have a
problem. And I debugged the Xerces code, seems like in
preprocessImport (in traverseSchema.cpp), when try to
resolve schema c, because it have the same target
namespace as a, and it thinks grammar already found,
so stop loading types from schema c.
Hi Frank,
the behavior of Xerces is allowed by the specs; see the note in
$4.2.3 "Note: The above 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,
regardless of the actual value of schemaLocation, but such a strategy
risks missing useful information when new schemaLocations are offered."
So you should design your schemas to have a single .xsd as the
official repository for a given targetNamespace, and have it include
all the other pieces.
Hope this helps,
Alberto
I tried to use my own entityResolver as well as the
default one.
Is this a bug in Xerces or I need to set up my parser
differently?
Thanks much.
Frank
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.xyz.org/XYZ"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ABC="http://www.xyz.org/ABC"
targetNamespace="http://www.xyz.org/XYZ"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.xyz.org/ABC"
schemaLocation="b.xsd"/>
<xs:element name="E1">
<xs:complexType>
<xs:sequence>
<xs:element name="E3" type="e3Type"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ABC="http://www.xyz.org/ABC"
xmlns:XYZ="http://www.xyz.org/XYZ" xmlns="http://www.xyz.org/ABC"
targetNamespace="http://www.xyz.org/ABC"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.xyz.org/XYZ"
schemaLocation="c.xsd"/>
<xs:element name="E2" type="XYZ:e2Type">
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="http://www.xyz.org/XYZ"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ABC="http://www.xyz.org/ABC"
targetNamespace="http://www.xyz.org/XYZ"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="e2Type">
<xs:restriction base="xs:int"/>
</xs:simpleType>
<xs:simpleType name="e3Type">
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]