Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Problem Including schemas
Problem Including schemas [message #7187] Thu, 26 December 2002 11:42 Go to next message
Eclipse User
Originally posted by: hayden.unicorn.com

I have encountered a problem with the references schema resolving - below
I explain the scenario:

I have 3 xsds - A.xsd, B.xsd, and C.xsd.

Here are snippets of my schemas:

A.xsd:

<xs:include schemaLocation="B.xsd"/>
<xs:include schemaLocation="C.xsd"/>
<xs:element name="car">
<xs:complexType>
<xs:sequence>
<xs:element ref="service"/>
<xs:element ref="model"/>
</xs:sequence>
</xs:complexType>
</xs:element>

B.xsd

<xs:element name="service>
<complexTYpe>
<sequence>
<element ref="id"/>
</sequence>
</complexType>
</xs:element>

C.xsd

<xs:element name="id>....

<xs:element name="model...


Now, when validating A.xsd, then the whole group of schemas is valid, even
though the element reference 'id' that is referenced in B, is defined in
C, and there in no include/import of C. this works since in A.xsd we are
including both B and C, so as a whole, we have no problems.

However, when I parse A.xsd with eclipse xsd, and I look at the
XSDElementDeclaration for 'id' in schema B, when I call
XSDElementDeclaration.getTypeDefinition() it returns null, and not the
XSDTypeDefintion for id (whether it be a complex type of simple type).

At the moment I have hacked my B.xsd to have the include statement.

Other parsers can cope with this problem, and XML Spy lets my open my
A.xsd is does not complain (but does complain when I open B.xsd)

I hope that my explanation is clear.
Re: Problem Including schemas [message #9498 is a reply to message #7187] Fri, 24 January 2003 10:52 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

Hayden,

Sorry for the long delay answering forum questions...

In the example below, B.xsd must have an include of C.xsd in order to be
valid. Including B.xsd in A.xsd will not help to resolve the ref to "id" in
B.xsd. According to the spec (in my reading of it), for a QName to resolve,
there must be an explicit import/include/redefine directly in the .xsd file;
the "id" element simply isn't visible in B.xsd when the schema for B.xsd is
being (transitively) processed. Perhaps other processors are more tolerant of
this error, perhaps even resolving the identifier via indirect
includes/imports, but XSD is strict in this regard. And since the ref to "id"
doesn't resolve, a placeholder element is provided by XSD instead and that
placeholder doesn't have a type.

Adding the include to B.xsd is not a hack, it's required.


Hayden Marchant wrote:

> I have encountered a problem with the references schema resolving - below
> I explain the scenario:
>
> I have 3 xsds - A.xsd, B.xsd, and C.xsd.
>
> Here are snippets of my schemas:
>
> A.xsd:
>
> <xs:include schemaLocation="B.xsd"/>
> <xs:include schemaLocation="C.xsd"/>
> <xs:element name="car">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="service"/>
> <xs:element ref="model"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> B.xsd
>
> <xs:element name="service>
> <complexTYpe>
> <sequence>
> <element ref="id"/>
> </sequence>
> </complexType>
> </xs:element>
>
> C.xsd
>
> <xs:element name="id>....
>
> <xs:element name="model...
>
> Now, when validating A.xsd, then the whole group of schemas is valid, even
> though the element reference 'id' that is referenced in B, is defined in
> C, and there in no include/import of C. this works since in A.xsd we are
> including both B and C, so as a whole, we have no problems.
>
> However, when I parse A.xsd with eclipse xsd, and I look at the
> XSDElementDeclaration for 'id' in schema B, when I call
> XSDElementDeclaration.getTypeDefinition() it returns null, and not the
> XSDTypeDefintion for id (whether it be a complex type of simple type).
>
> At the moment I have hacked my B.xsd to have the include statement.
>
> Other parsers can cope with this problem, and XML Spy lets my open my
> A.xsd is does not complain (but does complain when I open B.xsd)
>
> I hope that my explanation is clear.

--
Ed Merks
Re: Problem Including schemas [message #564728 is a reply to message #7187] Fri, 24 January 2003 10:52 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26063
Registered: July 2009
Senior Member
Hayden,

Sorry for the long delay answering forum questions...

In the example below, B.xsd must have an include of C.xsd in order to be
valid. Including B.xsd in A.xsd will not help to resolve the ref to "id" in
B.xsd. According to the spec (in my reading of it), for a QName to resolve,
there must be an explicit import/include/redefine directly in the .xsd file;
the "id" element simply isn't visible in B.xsd when the schema for B.xsd is
being (transitively) processed. Perhaps other processors are more tolerant of
this error, perhaps even resolving the identifier via indirect
includes/imports, but XSD is strict in this regard. And since the ref to "id"
doesn't resolve, a placeholder element is provided by XSD instead and that
placeholder doesn't have a type.

Adding the include to B.xsd is not a hack, it's required.


Hayden Marchant wrote:

> I have encountered a problem with the references schema resolving - below
> I explain the scenario:
>
> I have 3 xsds - A.xsd, B.xsd, and C.xsd.
>
> Here are snippets of my schemas:
>
> A.xsd:
>
> <xs:include schemaLocation="B.xsd"/>
> <xs:include schemaLocation="C.xsd"/>
> <xs:element name="car">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="service"/>
> <xs:element ref="model"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> B.xsd
>
> <xs:element name="service>
> <complexTYpe>
> <sequence>
> <element ref="id"/>
> </sequence>
> </complexType>
> </xs:element>
>
> C.xsd
>
> <xs:element name="id>....
>
> <xs:element name="model...
>
> Now, when validating A.xsd, then the whole group of schemas is valid, even
> though the element reference 'id' that is referenced in B, is defined in
> C, and there in no include/import of C. this works since in A.xsd we are
> including both B and C, so as a whole, we have no problems.
>
> However, when I parse A.xsd with eclipse xsd, and I look at the
> XSDElementDeclaration for 'id' in schema B, when I call
> XSDElementDeclaration.getTypeDefinition() it returns null, and not the
> XSDTypeDefintion for id (whether it be a complex type of simple type).
>
> At the moment I have hacked my B.xsd to have the include statement.
>
> Other parsers can cope with this problem, and XML Spy lets my open my
> A.xsd is does not complain (but does complain when I open B.xsd)
>
> I hope that my explanation is clear.

--
Ed Merks
Previous Topic:XSDPrototypicalSchema and classpath
Next Topic:xerces version
Goto Forum:
  


Current Time: Tue Sep 23 06:23:40 GMT 2014

Powered by FUDForum. Page generated in 0.12503 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software