Results 1 to 2 of 2
Thread: XML Schema validation
- 05-04-2010, 06:34 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
XML Schema validation
Hi,
I am having some problems validating XML against a schema. I have an XML document and a very simple schema file, when I run it against the code below it fails. However, when I manually add my schema definition to my XML file and run "Validate XML" in Netbeans it passes. The validation is complaining about the root node not being defined. This is the same error you get in Netbeans when you don't define a schema. Is there something else I have to do to make validate use my schema file? I don't want to define the schema definition in the XML file because I am validating XML files that I have no control over.
The exact error I get is:
Error validating XML against schemacvc-elt.1: Cannot find the declaration of element rootNode
where rootNode is the rootNode of my document. I even changed my schema file to not have any constraints and it still complains with the same error.
Java Code:File schema = new File(xsdLocation); Document xmlDoc = getXMLDocument(xmlFile); SchemaFactory factory = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory.newSchema(schemaFile); Validator validator = schema.newValidator(); DOMSource dom = new DOMSource(xmlDoc); validator.validate(dom);
- 05-04-2010, 09:28 PM #2
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
XML Schema what is it good for.
By kroiz in forum XMLReplies: 4Last Post: 08-20-2009, 04:30 AM -
xml schema to document convert?
By makpandian in forum XMLReplies: 4Last Post: 08-12-2009, 10:57 AM -
XML Schema
By Abder-Rahman in forum XMLReplies: 1Last Post: 02-22-2009, 04:33 PM -
Merge 2 XMLs Based on Schema
By wowstartup in forum XMLReplies: 0Last Post: 02-12-2009, 05:46 PM -
Graphic library for XML Schema
By earns in forum XMLReplies: 0Last Post: 10-26-2008, 04:49 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks