<br><font size=2 face="sans-serif">Hi,</font>
<br>
<br><font size=2 face="sans-serif">I am using org.jdom.input.SAXBuilder
to validate the xml againts the schema and I am getting this exception:</font>
<br>
<br><font size=2 face="sans-serif">org.xml.sax.SAXParseException: cvc-elt.1:
Cannot find the declaration of element 'Transmission'.</font>
<br><font size=2 face="sans-serif">at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown
Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.parsers.XMLParser.parse(Unknown Source)</font>
<br><font size=2 face="sans-serif"> at
org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)</font>
<br><font size=2 face="sans-serif"> at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)</font>
<br><font size=2 face="sans-serif"> at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:851)</font>
<br><font size=2 face="sans-serif"> at
org.nexweb.otm.util.JDOMSchemaValidator.validateSchema(JDOMSchemaValidator.java:39)</font>
<br><font size=2 face="sans-serif">Where 'Transmission' is the root element
of my xml.</font>
<br>
<br><font size=2 face="sans-serif">Here is my class</font>
<br>
<br><font size=2 face="sans-serif">public class JDOMSchemaValidator</font>
<br><font size=2 face="sans-serif">{ </font>
<br><font size=2 face="sans-serif"> public void validateSchema(String
schemaFileName, File xmlDocumentFile)</font>
<br><font size=2 face="sans-serif"> {</font>
<br><font size=2 face="sans-serif"> try</font>
<br><font size=2 face="sans-serif"> { //Create
SAXBuilder object</font>
<br><font size=2 face="sans-serif">
SAXBuilder saxBuilder = </font>
<br><font size=2 face="sans-serif">
new SAXBuilder("org.apache.xerces.parsers.SAXParser",
true);</font>
<br>
<br><font size=2 face="sans-serif">
//Set SAXBuilder parser to be a validating parser</font>
<br><font size=2 face="sans-serif">
saxBuilder.setValidation(true);</font>
<br><font size=2 face="sans-serif">
saxBuilder.setFeature("http://apache.org/xml/features/validation/schema",
</font>
<br><font size=2 face="sans-serif">
true);</font>
<br>
<br><font size=2 face="sans-serif">
saxBuilder.setFeature("http://apache.org/xml/features/validation/schema-full-checking",
</font>
<br><font size=2 face="sans-serif">
true);</font>
<br><font size=2 face="sans-serif">
saxBuilder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
</font>
<br><font size=2 face="sans-serif">
schemaFileName);</font>
<br>
<br><font size=2 face="sans-serif">
//Create a ErrorHandler and set ErrorHandler on parser.</font>
<br><font size=2 face="sans-serif">
Validator handler = new Validator();</font>
<br><font size=2 face="sans-serif">
saxBuilder.setErrorHandler(handler);</font>
<br><font size=2 face="sans-serif">
//Parse XML Document</font>
<br><font size=2 face="sans-serif">
saxBuilder.build(xmlDocumentFile);</font>
<br><font size=2 face="sans-serif">
//Output Validation Errors</font>
<br><font size=2 face="sans-serif">
if (handler.validationError == true)</font>
<br><font size=2 face="sans-serif">
{</font>
<br><font size=2 face="sans-serif">
System.out.println("XML Document has Error:" +
</font>
<br><font size=2 face="sans-serif">
handler.validationError + " " + </font>
<br><font size=2 face="sans-serif">
handler.saxParseException.getMessage());</font>
<br><font size=2 face="sans-serif">
handler.saxParseException.printStackTrace();</font>
<br><font size=2 face="sans-serif">
}</font>
<br><font size=2 face="sans-serif">
else</font>
<br><font size=2 face="sans-serif">
{</font>
<br><font size=2 face="sans-serif">
System.out.println("XML Document is valid");</font>
<br><font size=2 face="sans-serif">
}</font>
<br><font size=2 face="sans-serif"> }</font>
<br><font size=2 face="sans-serif"> catch (JDOMException
jde)</font>
<br><font size=2 face="sans-serif"> {</font>
<br><font size=2 face="sans-serif">
System.out.println("JDOMException");</font>
<br><font size=2 face="sans-serif">
jde.printStackTrace();</font>
<br><font size=2 face="sans-serif"> }</font>
<br>
<br><font size=2 face="sans-serif"> catch (IOException
ioe)</font>
<br><font size=2 face="sans-serif"> {</font>
<br><font size=2 face="sans-serif">
System.out.println("IOException");</font>
<br><font size=2 face="sans-serif">
ioe.printStackTrace();</font>
<br><font size=2 face="sans-serif"> }</font>
<br><font size=2 face="sans-serif"> }</font>
<br>
<br><font size=2 face="sans-serif">public static void main(String[] argv)
{</font>
<br><font size=2 face="sans-serif">
String schemaFile = "file://F:/JavaProjects/WorkspaceDev/OTM/xml/catalog.xsd";</font>
<br><font size=2 face="sans-serif">
File XmlFile = "catalog.xml";</font>
<br><font size=2 face="sans-serif">
JDOMValidator validator = new JDOMValidator();</font>
<br><font size=2 face="sans-serif">
validator.validateSchema(schemaFile, XmlFile);</font>
<br>
<br><font size=2 face="sans-serif"> }</font>
<br><font size=2 face="sans-serif">}</font>
<br><font size=2 face="sans-serif"><u>catalog.xsd</u></font>
<br>
<br><font size=2 face="sans-serif"><?xml version="1.0" encoding="UTF-8"
?></font>
<br><font size=2 face="sans-serif"><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"</font>
<br><font size=2 face="sans-serif">
attributeFormDefault="unqualified"> </font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif">
</font>
<br><font size=2 face="sans-serif"> <xsd:element name = "Transmission"></font>
<br><font size=2 face="sans-serif"> .........</font>
<br>
<br><font size=2 face="sans-serif"><u>catalog.xml</u></font>
<br>
<br><font size=2 face="sans-serif"><?xml version="1.0" encoding="UTF-8"?></font>
<br><font size=2 face="sans-serif"><Transmission xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation="file://F:/JavaProjects/WorkspaceDev/OTM/xml/GLogXML.xsd"></font>
<br><font size=2 face="sans-serif"> <TransmissionHeader></font>
<br><font size=2 face="sans-serif"> .........................</font>
<br>
<br><p><font size="1"><font face="arial,helvetica,sans-serif"><strong>******************************************************************************<br /></strong><font color="#ff0000">ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION</font> <br />Our domain name is changing. Please take note of the sender's<br />e-Mail address and make changes to your personal address list,<br />if needed. Both domains will continue to work, only for a limited<br />time.<br />******************************************************************************<br />This email and any files transmitted with it are intended solely for <br />the use of the individual or agency to whom they are addressed. <br />If you have received this email in error please notify the Navy <br />Exchange Service Command e-mail administrator. This footnote <br />also confirms that this email message has been scanned for the<br />presence of computer viruses.</font></font></p><p><font size="1"><font face="arial,helvetica,sans-serif">Thank You! <br /><strong>******************************************************************************</strong></font></font></p>