[jdom-interest] Re: Problem extracting include elements from an XML schema.

Bart Read bart.read at uk.lionbioscience.com
Wed Jul 30 06:35:18 PDT 2003


(I've reposted this because the original message was too big)

 

Dear All,

 

 

We are developing a tool for a bioinformatics system that allows the
user to interact directly with XML schemas.  My code loads a schema and
creates a JDOM tree just as if it were a normal XML document.  However,
here's the problem: I'm trying to get the include child elements from
the root element but always the list I'm returned is empty.  Checking
using the NetBeans debugger shows that the JDOM Document object matches
the underlying schema.

 

Right, so here's my code:

 

Document schema = .  // This code gets the schema from wherever it
happens to be and

// gives it to JDOM

Element root = schema.getRootElement();

Namespace ns = root.getNamespace();

List includes = root.getChildren( "include", ns );

 

The List in the last line of code is always empty, this is even the case
when I don't specify the namespace.  But when I use the debugger it
clearly shows that the namespace of the root element is the same as that
of the child elements, including the include elements.  Does anybody
have any idea what I'm doing wrong?  I'm using a test schema from the
Ordinance Survey in the UK, which is as follows (abridged version):

 

<?xml version="1.0" encoding="UTF-8"?>

<schema
targetNamespace="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb"
xmlns:osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="2.4">

        <annotation>

                <appinfo>OSComplexTypes.xsd 2.4 2003/01</appinfo>

                <documentation xml:lang="en">Ordnance Survey, (c) Crown
Copyright. All Rights Reserved January 2003.</documentation>

                <documentation xml:lang="en">See
http://www.ordnancesurvey.co.uk/xml/schema for guidelines and related
information</documentation>

                <documentation xml:lang="en">This schema defines the
complex types used as properties on features.</documentation>

        </annotation>

        <!-- include constructs from other OS schemas -->

        <include schemaLocation="OSQueryResult.xsd"/>

        <include schemaLocation="OSSimpleTypes.xsd"/>

        <include schemaLocation="OSMeasures.xsd"/>

        <!--import OGC constructs-->

        <import namespace="http://www.opengis.net/gml"/>

         <!-- import xml:lang construct.  This is sourced from :
http://www.w3.org/2001/03 -->

        <import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="xml.xsd"/>

        <!--
================================================================

        Complex Type Definitions 

        ================================================================
-->

        <complexType name="addressStatusType">

                <sequence>

                        <element name="matchStatus"
type="osgb:matchStatusType"/>

                        <element name="physicalStatus"
type="osgb:physicalStatusType"/>

                        <element name="positionalQuality"
type="osgb:positionalQualityType"/>

                        <element name="structureType"
type="osgb:structureTypeType"/>

                </sequence>

        </complexType>

        <complexType name="changeHistoryType">

                <sequence>

                        <element name="changeDate" type="date"/>

                        <element name="reasonForChange"
type="osgb:reasonForChangeType"/>

                </sequence>

        </complexType>

        .

        .

        <complexType name="vehicleQualifierType">

                <sequence>

                        <element name="type" minOccurs="0"
maxOccurs="unbounded">

                                <complexType>

                                        <simpleContent>

                                                <extension
base="string">

                                                        <attribute
name="exceptFor" type="boolean"/>

                                                </extension>

                                        </simpleContent>

                                </complexType>

                        </element>

                        <element name="load" minOccurs="0"
maxOccurs="unbounded">

                                <complexType>

                                        <simpleContent>

                                                <extension
base="string">

                                                        <attribute
name="exceptFor" type="boolean"/>

                                                </extension>

                                        </simpleContent>

                                </complexType>

                        </element>

                        <element name="use" minOccurs="0"
maxOccurs="unbounded">

                                <complexType>

                                        <simpleContent>

                                                <extension
base="string">

                                                        <attribute
name="exceptFor" type="boolean"/>

                                                </extension>

                                        </simpleContent>

                                </complexType>

                        </element>

                        <element name="maxHeight" minOccurs="0"
type="osgb:MetresMeasureType"/>

                        <element name="maxCompositeHeight" minOccurs="0"
type="osgb:ImperialMeasureType"/>

                </sequence>

        </complexType>

</schema>

 

I'd be incredibly grateful for any assistance anybody could offer.

 

 

Many thanks,

Bart

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20030730/6dadbf7c/attachment.htm


More information about the jdom-interest mailing list