Patrizio.Ferlito
Mon, 07 Jul 2008 06:25:21 -0700
Hi all, I've the below very simple document <event-bus:runtime xmlns:event-bus="http://www.bsource.ch/EventBus <http://www.bsource.ch/EventBus> "> <event-bus:instituteId>undefined</event-bus:instituteId> </event-bus:runtime> and the related xml schema: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!--W3C Schema generated by XMLSpy v2006 sp2 U (http://www.altova.com <http://www.altova.com> )--> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> " targetNamespace="http://www.bsource.ch/EventBus <http://www.bsource.ch/EventBus> " xmlns:event-bus="http://www.bsource.ch/EventBus <http://www.bsource.ch/EventBus> " elementFormDefault="qualified"> <xs:element name="instituteId" type="xs:string"/> <xs:element name="runtime"> <xs:complexType> <xs:sequence> <xs:element ref="event-bus:instituteId"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> and I would like to validate the document. My code, taken from dom4j documentation, is: SAXReader reader = new SAXReader(true); reader.setProperty(http://apache.org/xml/properties/schema/external-noNa mespaceSchemaLocation, args[1]); XMLErrorHandler errorHandler = new XMLErrorHandler(); reader.setErrorHandler(errorHandler); reader.read(args[0]); XMLWriter writer = new XMLWriter(OutputFormat.createPrettyPrint()); if (errorHandler.getErrors() != null) { writer.write(errorHandler.getErrors()); System.exit(FAILURE); } and the output is: <errors> <error column="19" line="1" systemID="file:///C:/tmp/myxml.xml">Document is invalid: no grammar found.</error> <error column="19" line="1" systemID="file:///C:/tmp/myxml.xml">Document root element "event-bus:runtime", must match DOCTYPE root "null".</error> </errors> but if I validate the xml document against the above xml schema using XMLSpy the document is valid. Should I use different settings when I define the SAXReader ? Regards Patrizio IMPORTANT: This e-mail transmission is intended for the named addressee(s)only. Its contents are private, confidential and protected from disclosure and should not be read, copied or disclosed by any other person. If you are not the intended recipient, we kindly ask you to notify the sender immediately by telephone (+41 (0)58 806 50 00), to redirect the message to the account "[EMAIL PROTECTED]" and to delete this e-mail. E-mail transmissions may be intercepted, altered or read by unauthorized persons and may contain viruses. Therefore, it is recommended that you use regular mail or courier services for any information intended to be confidential. However, by sending us messages through e-mail, you authorize and instruct us to correspond by e-mail in the relevant matter. Thank you.
------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________ dom4j-dev mailing list dom4j-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-dev