Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schemaLocation"

Thread view: 
Markus - 23 Nov 2005 13:48 GMT
I hava an applet/application which can validate an XML.
But there are some problems because the schemaLocation

In the xml-file the schemaLocation = "mySchema.xsd".
But if I start my app in a browser as applet the parser searches on the
local drive for mySchema.xsd.
This is not really the problem beacause I found out, that I can set the
Property
"http://apache.org/xml/properties/schema/external-schemaLocation" to
"myNameSpace url_to_mySchema.xsd"

The problem occours because mySchema.xsd (which is not really my schema
;-) )includes some "sub-schemas" in that way:

mySchema.xsd
...
<xsd:include schemaLocation = "mySchema_a.xsd"/>
<xsd:include schemaLocation = "mySchema_b.xsd"/>
..

The parses found mySchema.xsd on the given URL but searches mySchema_a
and _b under local driver anyway. :-/

Does anybody know a solution to configure the parser to load all XSDs
from a given URL?
-> I'm using JDOM and Xerces.

Kind regards

Markus
Markus - 23 Nov 2005 14:41 GMT
Here is the (a better) solution:

//Creating a ErrorHandler
m_SAXErrorHandler = new SPSCSAXErrorHandler();
//Setting the parser
m_builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
//activate validation
m_builder.setValidation(a_b_validate);
//setting Errorhandler
m_builder.setErrorHandler(m_SAXErrorHandler);
//activate schema-validation
m_builder.setFeature("http://apache.org/xml/features/validation/schema",
a_b_validate);
m_builder.setFeature("http://apache.org/xml/features/validation/schema-full-checking",
a_b_validate);
m_builder.setFeature("http://xml.org/sax/features/validation",
a_b_validate);
//buidling document - all relative paths are relative to a_st_base
m_document = m_builder.build(a_inputStreamXML, a_st_base);

Markus


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.