[jdom-interest] Unable to validate a JDOM document or element with the Schema class of jdom contrib package.

John Dous johndous at hotmail.com
Wed Aug 27 02:54:18 PDT 2008

Unable to validate a JDOM document or element with the Schema class of jdom contrib package.I make a customValidation method and i try to Validate a JDOM document. the problem is that 
every time I get an exception "Failed to parse
schema "file:/C:/messages.xsd": no validation engine available for: http://www.w3.org/2001/XMLSchema."
I have try to Parse the xsd with following String values but all the times I failed.String uriFile = "C:/messages.xsd"
String uriFile = "file:/C:/messages.xsd"Below is the code and the xml,xsd.public void
customValidation() throws JDOMException, IOException{


      String xmlFile = "C:/messages.xml";

builder = new SAXBuilder();

doc = builder.build(new FileInputStream(xmlFile));


      String schemaFile = "C:/messages.xsd";

      File file =
new File(schemaFile);


      String uriFile =

schema = Schema.parse( uriFile, Schema.W3C_XML_SCHEMA);


      List errors = schema.validate(doc);

            if (errors != null) {

          // Validation errors

          for (Iterator
i=errors.iterator(); i.hasNext(); ) {

ValidationError e = (ValidationError)(i.next());




          // Else: No error, document is valid.



messages.xml<?xml version="1.0" encoding="UTF-8"?>
<messages xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com messages.xsd">

  <message id="first">
    <english>first msg</english>
    <greek>first msg.</greek>
  <message id="second">
    <english>second msg</english>
    <greek>second msg.</greek>

messages.xsd:<?xml version="1.0"?>


<xs:element name="messages" >
        <xs:element name="message" maxOccurs="unbounded">
                    <xs:element name="english" type="xs:string" minOccurs="0" />
                    <xs:element name="greek" type="xs:string" minOccurs="0" />
                <xs:attribute name="id" type="xs:string" />
</xs:schema>Thanks in advance. 
John Dousaitis.

News, entertainment and everything you care about at Live.com. Get it now!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20080827/3e796498/attachment.htm

More information about the jdom-interest mailing list