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

John Dous <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>


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";

      SAXBuilder
builder = new SAXBuilder();

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

             

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

      File file =
new File(schemaFile);

            

      String uriFile =
file.toURL().toString();

      Schema
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());

              
System.out.println(e);

            }

            }

          // 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>
  
  <message id="second">
    <english>second msg</english>
    <greek>second msg.</greek>
  </message>
  
</messages>

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

<xs:schema 
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3schools.com"
targetNamespace="http://www.w3schools.com"
elementFormDefault="qualified">

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




_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.