Hi,

I am just starting learn how to use xml with Java, and decided to use
Xerces-J as my XML parser as it is the one recommended by the book I
am learning from "Java and XML" by Brett McLaughlin.

I have hit serious problems when it comes to trying to use the
SAXParser to validate my xml file, i do this by the below line of code

reader.setFeature("http://xm.org/sax/features/validation";, true)

where "reader" is a XMLReader object, for the exact error returned
please see the attached error message/stack trace.

I don't think my XML file is wrong as nothing is picked up in XMLSpy
(Home Version) it seems to think that the file is perfectly valid.

The bit of the XML file that Xerces seems to think is wrong is:

<book xmlns="http://www.oreilly.com/javaxml2"; 
           xmlns:ora="http://www.oreilly.com";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xsi:schemaLocation="http://www.oreilly.com/javaxml2 XSD/contents.xsd
                                              http://www.oreilly.com
XSD/contents-ora.xsd"
>

it does not seem to like xmlns:xsi="......

Any help will be greatly appreciated, and if any more information/data
is needed please let me know.

Thanks,

Andy
Found entity with public ID null and system ID file:///c:/XML/DTD/JavaXML.dtd
** Parsing Error **
  Line:     11
  URI:      file:///c:/XML/contents.xml
  Message   Attribute "xmlns:xsi" must be declared for element type "book".
org.xml.sax.SAXException: Error encountered
        at 
javaxml2.SAXTreeViewer$JTreeErrorHandler.error(SAXTreeViewer.java:389)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at 
org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown
 Source)
        at 
org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown
 Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
 Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at javaxml2.SAXTreeViewer.buildTree(SAXTreeViewer.java:129)
        at javaxml2.SAXTreeViewer.init(SAXTreeViewer.java:67)
        at javaxml2.SAXTreeViewer.main(SAXTreeViewer.java:435)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to