How 2 get single JDOM doc of XML schema that also includes external schemas

K

kyancy

HI all

We have several XML schemas to describe common component document
parts. We then create new XML schemas as necessary that use "xsd:import
schemaLocation=whateverLocation.." to include the common type
definitions from 1 or more of the component XML schemas rather than
just explicitly adding the common definitions in every XML schema we
create.

This works great from a definition and validation point of view, but I
was a little surprised to find that when I generated a JDOM
representation of one of these schemas (that are importing other
schemas) that the resulting JDOM document only has the elements from
the top level schema and does not contain the elements from the
imported component schemas.

I realize that JDOM just considers this XML schema to be just another
XML document, so its not hard to imagine that the using the import from
the XML schema specific namespace would have no affect on the resulting
document, but I thought it might produce a combined XML document with
all the elements. Even playing with JDOM options for validation and
namespace awareness my resulting document was the same.

I am currently trying this with JAXP using Xerces, and I am hoping
there is a way for this to work without relying on any parser specific
property or method.

Any suggestions are very much appreciated. thx in advance.

K.E.Y.
 
G

gimme_this_gimme_that

Are you using JDOM 1.0 ?

It's impossible to help you without a sample XML schema.
 
K

kyancy

Thx for response. Have tried in both 1.0 and prior versions of JDOM.
Here is a sample schema that imports a second schema which is also
below. If I build a JDOM document of the test schema below, I want to
end up with an XML document that contains all the elements from both
schemas. Maybe I am way off and need something xlink or xinclude or
something similar. thx in advance for your response.
=====================
<!-- This is a test schema for a fictional agent class that references
an external schema -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.m3t4.com/resources"
xmlns:eri="http://www.m3t4.com/resources"
xmlns:ericommon="http://www.m3t4.com/resources/common"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xsd:import namespace="http://www.m3t4.com/resources/common"
schemaLocation="HandlerProperties.xsd"/>
<!-- Even if xsd:include is used instead of import, the resulting JDOM
does contain the imported elements :-( -->
<!-- <xsd:include schemaLocation="HandlerProperties.xsd"/> -->
<xsd:element name="TestAgentConfig" type="eri:TestAgentConfigType">
<xsd:annotation>
<xsd:documentation>Configuration for a fictional Test Agent
class</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="TestAgentConfigType">
<xsd:sequence>
<xsd:element default="false" type="xsd:boolean"
name="enableDebugEvents"/>
<xsd:element name="handlerConfiguration"
type="ericommon:HandlerPropertiesType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
=====================
The external common schema referenced from test schema:

<!-- This test schema defines a common attribute -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
version="1.0.0" targetNamespace="http://www.m3t4.com/resources/common"
xmlns:eric="http://www.m3t4.com/resources/common">
<xsd:element name="HandlerProperties"
type="eric:HandlerPropertiesType"/>
<xsd:complexType name="HandlerPropertiesType">
<xsd:sequence>
<xsd:element name="HandlerClassName" type="xsd:string"
nillable="false">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
 
K

kyancy

oops. ignore the xinclude namespace reference. That was left over from
some of my experiments. thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top