Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Problem Including schemas
Problem Including schemas [message #583848] Mon, 08 March 2004 12:34
Hayden Marchant is currently offline Hayden MarchantFriend
Messages: 90
Registered: July 2009
Member
Ed,

A question that I had over a year ago has come up again and I rummaged
through my correspondence with the Eclipse XSD newsgroups/forums and found
the email below. It's a question concerning nested schemae. I have
included the email at the bottom of this mail.

I took a look at the XML Schema spec and I think that the relevant part is
at http://www.w3.org/TR/xmlschema-1/#compound-schema I took a look at the
"Professional XML Schemas" published by Wrox, and on page 274 in Chapter
8, there is a bolded out sentence that says "If the schema we include
borrows from other schemas, we only have to reference the topmost schema
for it to pull in other schemas it references".

Thanks,
Hayden Marchant

From 26 Jan 2003:


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:Moving components from one XSD schema to another Ctd
Next Topic:Help with annotations
Goto Forum:
  


Current Time: Mon Oct 26 08:22:36 GMT 2020

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

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

Back to the top