[jdom-interest] parsing problem while using SAXBuilder

Chad LaJoie clajoie at vt.edu
Fri Mar 23 09:42:09 PST 2001

One of my co-workers was have the same problem.  His problem was that he 
had turned on validating in the SAXBuilder but did not have a DTD 
defined.  You might want to just double check that.

At 07:55 AM 3/23/2001, you wrote:
>I am trying to build a JDOM document using the SAXBuilder.
>I want the SAXBuilder to validate the XML file before building
>document and the SAXBuilder complains that it can't find the root
>element. Can you tell me what the problem is? Thanks for your help!!!
>(Below are the xml file, xml schema and the errors)
>XML File:
>"<?xml version="1.0" encoding="UTF-8"?>
><Book xmlns:xsi="http://www.w3.org/2000/10/XMLSchemainstance"
>  xsi:noNamespaceSchemaLocation="/home/yen/ex/jdomexamples/simple.xsd"
>   <Title>ALTOVA - The XML Spy Company</Title>
>   <Author>Joe Smith</Author>
>XML Schema:
><?xml version="1.0" encoding="UTF-8"?>
><xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
>         <xsd:element name="Book">
>           <xsd:complexType>
>             <xsd:sequence>
>                 <xsd:element name="Title" type="xsd:string"/>
>                 <xsd:element name="Author" type="xsd:string"/>
>             </xsd:sequence>
>           </xsd:complexType>
>         </xsd:element>
>Exception in thread "main" org.jdom.JDOMException: Error on line 1: 
>Element type "Book" must be declared.
>        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:407)
>        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:499)
>        at ex.jdomexamples.TestSchema.main(TestSchema.java:54)
>Root cause: org.xml.sax.SAXParseException: Element type "Book" must be 
>        at 
> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1008)
>        at 
> org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1236)
>        at 
> org.apache.xerces.validators.common.XMLValidator.validateElementAndAttributes(XMLValidator.java:2673)
>        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:395)
>        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:499)
>        at ex.jdomexamples.TestSchema.main(TestSchema.java:54)
>Get your FREE download of MSN Explorer at http://explorer.msn.com
>To control your jdom-interest membership:

Chad La Joie                           "Only a man who can not conquer
IT Specialist                             his deficiencies feels the need to
IS&C - WARD                             convince the world he has none"

More information about the jdom-interest mailing list