<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>


<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB"><span style="color: rgb(0, 0, 0);">Unable to validate a JDOM document or element with the Schema class of jdom contrib package.</span></span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB"><span style="color: rgb(0, 0, 0);"></span></span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB"><span style="color: rgb(0, 0, 0);"></span></span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB"><span style="color: rgb(0, 0, 0);">I make a customValidation method and i try to Validate a JDOM document. the problem is that <br></span></span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB"><span style="color: rgb(0, 0, 0);"></span></span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB"><span style="color: rgb(0, 0, 0);"><span>e</span></span></span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB"><span style="color: rgb(0, 0, 0);"><span>very time I get an exception "</span></span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">Failed to parse
schema "file:/C:/messages.xsd": no validation engine available </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">for</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">: http://www.w3.org/2001/XMLSchema.</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB"><span style="color: rgb(0, 0, 0);"><span>"<span style="font-weight: bold;"><br></span></span></span></span></p><p class="MsoNormal" style="">I have try to Parse the xsd with following String values but all the times I failed.</p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="background: silver none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">String</span> uriFile = "C:/messages.xsd"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="background: silver none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><br></span></span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="background: silver none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">String</span> uriFile = "</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">file:/C:/messages.xsd"</span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"></span>Below is the code and the xml,xsd.</p><p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">public</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"> </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">void</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">
customValidation() </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">throws</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"> JDOMException, IOException{</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background: silver none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">String</span> xmlFile = </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);" lang="EN-GB">"C:/messages.xml"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SAXBuilder
builder = </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">new</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"> SAXBuilder();</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Document
doc = builder.build(</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">new</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"> FileInputStream(xmlFile));</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background: silver none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">String</span> schemaFile = </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);" lang="EN-GB">"C:/messages.xsd"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>File file =
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">new</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"> File(schemaFile);</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background: silver none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">String</span> uriFile =
file.toURL().toString();</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Schema
schema = Schema.<i>parse</i>( uriFile, Schema.</span><i><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);" lang="EN-GB">W3C_XML_SCHEMA</span></i><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">);</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span>List errors = schema.validate(doc);</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">if</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"> (errors != </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">null</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">) {</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 95);" lang="EN-GB">// Validation errors</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp; </span></span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-GB">for</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"> (Iterator
i=errors.iterator(); i.hasNext(); ) {</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>ValidationError e = (ValidationError)(i.next());</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>System.</span><i><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);" lang="EN-GB">out</span></i><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">.println(e);</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp; </span>}</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 95);" lang="EN-GB">// Else: No error, document is valid.</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"><o:p></o:p></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span>}</span><span style="" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"></span><span style="font-size: 10pt; font-family: Arial Black,Geneva,Arial,Sans-serif; color: black;" lang="EN-GB">messages.xml</span></p><p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>&lt;messages xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com messages.xsd"&gt;<br><br>&nbsp; &lt;message id="first"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;english&gt;first msg&lt;/english&gt;<br>&nbsp;&nbsp;&nbsp; &lt;greek&gt;first msg.&lt;/greek&gt;<br>&nbsp; &lt;/message&gt;<br>&nbsp; <br>&nbsp; &lt;message id="second"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;english&gt;second msg&lt;/english&gt;<br>&nbsp;&nbsp;&nbsp; &lt;greek&gt;second msg.&lt;/greek&gt;<br>&nbsp; &lt;/message&gt;<br>&nbsp; <br>&lt;/messages&gt;<br></span></p><p class="MsoNormal"><br><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"></span></p><p style="font-weight: bold; font-family: Arial Black,Geneva,Arial,Sans-serif;" class="MsoNormal"><font size="5"><span style="font-size: 10pt; color: black;" lang="EN-GB">messages.xsd:</span></font></p><p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">&lt;?xml version="1.0"?&gt;<br><br>&lt;xs:schema <br>xmlns:xs="http://www.w3.org/2001/XMLSchema"<br>xmlns="http://www.w3schools.com"<br>targetNamespace="http://www.w3schools.com"<br>elementFormDefault="qualified"&gt;<br><br>&lt;xs:element name="messages" &gt;<br>&nbsp; &lt;xs:complexType&gt;<br>&nbsp;&nbsp;&nbsp; &lt;xs:sequence&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xs:element name="message" maxOccurs="unbounded"&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xs:complexType&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xs:sequence&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xs:element name="english" type="xs:string" minOccurs="0" /&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xs:element name="greek" type="xs:string" minOccurs="0" /&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/xs:sequence&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xs:attribute name="id" type="xs:string" /&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/xs:complexType&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/xs:element&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/xs:sequence&gt;<br>&nbsp; &lt;/xs:complexType&gt;<br>&lt;/xs:element&gt;<br>&lt;/xs:schema&gt;</span></p><p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">Thanks in advance. <br></span></p><p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB">John Dousaitis.<br></span></p><p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-GB"><br><o:p></o:p></span></p>

<br /><hr />Get news, entertainment and everything you care about at Live.com. <a href='http://www.live.com/getstarted.aspx ' target='_new'>Check it out!</a></body>
</html>