[jdom-interest] parsing problem while using SAXBuilder
aruna konreddy
konreddy at hotmail.com
Fri Mar 23 12:55:36 PST 2001
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>
</Book>
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>
</xsd:schema>
Errors:
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
declared.
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
More information about the jdom-interest
mailing list