[jdom-interest] Do schemas work with JDOM?

Michael Brennan Michael_Brennan at Allegis.com
Tue Jan 23 14:55:13 PST 2001


I haven't actually used schemas for validation yet, so I'm not sure I can
help you. However, I think the xmlns="x-schema:..." notation is still
something proprietary to Microsoft. You'll need to check the docs for the
XML parser you are using. You should be able to reference the schema via a
"schemaLocation" attribute (see
http://www.w3.org/TR/xmlschema-0/#schemaLocation for info). Also, read
through the XSD primer at http://www.w3.org/TR/xmlschema-0/. Your new schema
is still not quite correct (although I think you are on the right track).
The "<complexType>" tag specifies a type, not an element. You'll need some
"<element>" tags to specify the concrete elements allowed in your document
(although an "<element>" tag can reference a "<complexType>" to define its
content model).

> -----Original Message-----
> From: Fishman, Rick [mailto:Rick_Fishman at ctilogistx.com]
> Sent: Tuesday, January 23, 2001 7:09 AM
> To: 'Michael Brennan'; JDOM Interest (E-mail)
> Subject: RE: [jdom-interest] Do schemas work with JDOM?
> 
> 
> I appreciate the help. I don't want to wear out my welcome 
> (maybe I should
> be posting this to W3C?) but one more thing... maybe I'm 
> missing something.
> I have now changed my xml and its schema as found below. I am 
> getting a
> JDOMException indicating that it can't find the schema:
> 
> org.jdom.JDOMException: General Schema Error: Grammar with uri :
> x-schema:http://localhost/ReadTestSchema.xsd , can not 
> found.: Error on line
> 2 of document file:/C:/JavaProjects/JDomTest/ReadTest.xml: 
> General Schema
> Error: Grammar with uri : 
> x-schema:http://localhost/ReadTestSchema.xsd , can
> not found.
> 
> I am running this from a Java application that is using JDOM 
> to try and
> parse the XML file. The schema (ReadTestSchema.xsd) is located in my
> inetput/wwwroot directory that is my default web site on my 
> box and that web
> site is definitely accessible. This of course is an IIS web 
> server. I also
> copied the schema to an Apache web server on the Internet and 
> tried it using
> that URL but had the same problem. Is there something else I 
> need to do to
> allow JDOM to find the schema? I'm loading the XML file from 
> disk (not thru
> http) - maybe that's a problem?
> 
> I know I'm missing something really basic here so I'm prepared to be
> embarrassed <grin>...
> 
> Here is my xml:
> 
> <?xml version="1.0"?>
> <RICKSDOC 
> xmlns="x-schema:http://www.codeblazers.com/ReadTestSchema.xsd">
>    <ROUTE ID="1">
>       <TRIP ID="1">
>          <STOP ID="1" />
>       </TRIP>
>    </ROUTE>
> </RICKSDOC>
> 
> Here is my schema:
> 
> <xsd:schema xmlns:xsd="http://www.w3.org/2000/08/XMLSchema">
> <xsd:complexType name="RICKSDOC">
>    <xsd:element name="ROUTE" type="ROUTE"/>
> </xsd:complexType>
> <xsd:complexType name="ROUTE">
>    <xsd:element name="TRIP" type="TRIP"/>
>    <xsd:attribute name="ID" type="xsd:unsignedLong"/>
> </xsd:complexType>
> <xsd:complexType name="TRIP">
>    <xsd:element name="STOP" type="STOP"/>
>    <xsd:attribute name="ID" type="xsd:unsignedLong"/>
> </xsd:complexType>
> <xsd:complexType name="STOP">
>    <xsd:attribute name="ID" type="xsd:unsignedLong"/>
> </xsd:complexType>
> </xsd:schema>



More information about the jdom-interest mailing list