Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-19-2007, 02:47 PM
Member
 
Join Date: Jul 2007
Posts: 41
Rep Power: 0
oregon is on a distinguished road
Default how to validate a xml file with schemas via SAX
I want to validate XML documents with schemas via SAX
I have problems when asigning an *.xsd file to *.xml document

My code:
Code:
<p:user xmlns:p="http://www.google.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.wsf.net user.xsd">
It works in my computer but don't in others.
The SAX parser fails to recognize that user.xsd is located in the same folder as XMl document.

So I decided to assign the schema document programmatically:

Code:
static final String = JAXP_SCHEMA_SOURCE =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
theParser.setProperty(JAXP_SCHEMA_SOURCE, new File(...some *.xsd file full path));
But this has thrown NotRecognizedException.

any ideas?
thanks
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-31-2007, 12:52 AM
Senior Member
 
Join Date: Jul 2007
Posts: 135
Rep Power: 0
brianhks will become famous soon enough
Default
I don't think that the standard SAX parser can validate a file against a schema. They can using DTD's but, I do not think against schemas. You can use the MSV project to validate your documents though. I use it a lot in unit tests for XML validation.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-01-2007, 05:54 PM
Member
 
Join Date: Jul 2007
Posts: 41
Rep Power: 0
oregon is on a distinguished road
Default
why does sax can't validate a file?
anyway I will try to use MSV project
thanks
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-01-2007, 06:15 PM
Senior Member
 
Join Date: Jul 2007
Posts: 135
Rep Power: 0
brianhks will become famous soon enough
Default
Validating XML with the schema is a very arduous task that is not for the faint of project. SAX can validate against DTD's because DTD's are simple. Schemas are complex creatures that are not to be trifled with. That is why there exists the MSV project.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to validate date using SampleDateFormat Java Tip java.text 0 04-04-2008 03:38 PM
repaint validate doLayout Gajesh Tripathi AWT / Swing 1 10-27-2007 07:53 PM
How to validate date using SampleDateFormat JavaBean Java Tips 0 10-04-2007 10:31 PM
validate hex character paul New To Java 1 07-25-2007 10:08 PM
AxisFault faultCode:{http://schemas.xmlsoap.org/soap/envelope/ Jack Advanced Java 2 07-02-2007 06:07 AM


All times are GMT +2. The time now is 10:08 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org