[jdom-interest] XML Schema problem

Eric e.macaulay at cs.ucl.ac.uk
Wed Aug 22 08:49:34 PDT 2001


Hi,

I think the last exception was because I omitted a '"' from the 
document. When I reran the program I got the following exception:

org.jdom.JDOMException: Error on line 5 of document 
file:/E:/Caretaker/classgen.xml: General Schema Error: Grammar with uri 
: http://default.namespace.com , can not found.
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:296)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:617)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:599)
	at TestParser.main(TestParser.java:20)
Root cause: org.xml.sax.SAXParseException: General Schema Error: Grammar 
with uri : http://default.namespace.com , can not found.
	at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1008)
	at 
org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1250)
	at 
org.apache.xerces.validators.common.XMLValidator.validateElementAndAttributes(XMLValidator.java:2497)
	at 
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:818)
	at 
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1852)
	at 
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1000)
	at 
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:380)
	at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:287)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:617)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:599)
	at TestParser.main(TestParser.java:20)

Could it be that xerces trying to find the actual .xsd file?

Eric M.

Brett McLaughlin wrote:
>>I have defined the following schema, test.xsd:
>>
>><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>>  <xsd:element name="test" type="xsd:string"/>
>></xsd:schema>
>>
>>I have also defined the following xml file, test.xml:
>>
>><?xml version="1.0"?>
>><test
>>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>  xsi:schemaLocation="http://www.w3.org/2001/XMLSchema test.xsd"/>
>>
> 
> This last attribute isn't right. The value for schemaLocation should be
> 
> 1. The namespace being constrained
> 2. The file for that namespace
> 
> So you want something like:
> 
> <test
>   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
>   xmlns=http://default.namespace.com
>   xsi:schemaLocation=http://default.namespace.com test.xsd />
> 
> That will locate the schema for the default namespace (which the element
> "test" is in), and should work.
> 
> ---
> Brett McLaughlin
> Enhydra Strategist   http://www.enhydra.org
> Lutris Technologies http://www.lutris.com
> O'Reilly Author       http://www.oreilly.com/catalog/javaxml2
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
> 
> 






More information about the jdom-interest mailing list