This week's book giveaway is in the
General Computing
forum.
We're giving away four copies of
Arduino in Action
and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Engineering
»
XML and Related Technologies
Author
Error while validating XML
Swordfish
Greenhorn
Joined: Jun 13, 2005
Posts: 4
posted
Jun 13, 2005 00:54:00
0
Hi All,
I am trying to validate a XML against a XSD. I am using the sample code from
web page
.
Heres the updated code ...
import org.apache.xerces.parsers.DOMParser; import org.w3c.dom.Document; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; import java.io.IOException; public class SchemaValidationExample { public static void main(String args[]) { DOMParser parser = new DOMParser(); Document doc = null; String SchemaUrl = "D:/Projects/Tests/ValidateWithXSD/sample/sample.xsd"; String XmlDocumentUrl = "D:/Projects/Tests/ValidateWithXSD/sample/sample.xml"; try { parser.setFeature("http: //xml.org/sax/features/validation", true); parser.setFeature("http: //apache.org/xml/features/validation/schema", true); parser.setProperty("http: //apache.org/xml/properties/schema/external-schemaLocation", SchemaUrl); parser.parse(XmlDocumentUrl); doc = parser.getDocument(); }catch(IOException e) { System.out.println("Could not read file: " + e.getMessage()); }catch(SAXNotRecognizedException e) { System.out.println("Feature not recognized: " + e.getMessage()); }catch(SAXNotSupportedException e) { System.out.println("Feature not supported: " + e.getMessage()); } catch (SAXException e) { System.out.print("Parsing XML failed due to a " + e.getClass().getName() + ":"); System.out.println(e.getMessage()); } } }
When i run this program ... it gives me the following error ...
Feature not recognized: http: //xml.org/sax/features/validation
I am using Xerces Impl 2.6.2. I am kinda stuck here ...
Please let me know if anybody has came across this situation and if there is any solution for this ...
Thanks and regards,
Shailendra
Swordfish
Greenhorn
Joined: Jun 13, 2005
Posts: 4
posted
Jun 13, 2005 01:32:00
0
Got it ... Guys ... whitespace issue ...
But i've managed to land into another issue now ... It says ...
Feature not recognized:
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
at
parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", SchemaUrl);
Please suggest me something ...
Thanks and regards,
Shailendra
I agree. Here's the link:
http://aspose.com/file-tools
subject: Error while validating XML
Similar Threads
DOM Parser
validate schema in DOM
Feature not recognized: - schema validation
package problem
Why it is happening like this.........
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter