Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-19-2007, 02:47 PM
Member
 
Join Date: Jul 2007
Posts: 41
oregon is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 07-31-2007, 12:52 AM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
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
oregon is on a distinguished road
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: 134
brianhks will become famous soon enough
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
Sponsored Links
Reply


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

vB 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 +3. The time now is 07:32 AM.


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