[jdom-interest] XML Schema problem

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


Sorry, I made a mistake with the last message.

I have changed my file properly this time and am getting a different 
exception:

org.jdom.JDOMException: Error on line 5 of document 
file:/E:/Caretaker/classgen.xml: Element type "test" must be followed by 
either attribute specifications, ">" or "/>".
	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: Element type "test" must be 
followed by either attribute specifications, ">" or "/>".
	at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1008)
	at 
org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocumentScanner.java:634)
	at 
org.apache.xerces.framework.XMLDocumentScanner.abortMarkup(XMLDocumentScanner.java:683)
	at 
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1846)
	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)

My xml file reads:

<?xml version="1.0"?>
<test
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://default.namespace.com
  xsi:schemaLocation="http://default.namespace.com test.xsd"/>

Sorry for the spurious email.

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