Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within XML
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
XML and Related Technologies
Error while validating XML
Swordfish
Greenhorn
Posts: 4
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 4
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Feature not recognized: - schema validation
package problem
How To Validate Xml Against Schema
Why it is happening like this.........
validate schema in DOM
More...