473,466 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using xsd in jar to validate

Hello,

I have a set of XML Schemas and a Xerces DOM parser that is supposed to
use those xsd to validate an XML.

My problem is that I want to put the xsd and the parser in the same jar
and enable the parsing of xml without having to specify the xsd location
in the xml. Since the xsd are in the jar, I cannot use the
DOMParser.setProperty() to specify the xsd location (or can I, but how?)

Do you know a way to do such a thing? Is it even possible?

Thanks

Antoine Brun
Jul 20 '05 #1
4 5529
In principle you should be able to use a jar: URL to identify your
schema document -- I don't know whether Xerces will do the right thing
or not.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jul 20 '05 #2
Dunno if the parser can get resources from the jar but you could
probably do it by hand. Xerces allows you to cache "grammars" so you
could prepopulate the cache by doing "getResourceAsStream" to get the
xsd out of the jar and load it.

Henry S. Thompson wrote:
In principle you should be able to use a jar: URL to identify your
schema document -- I don't know whether Xerces will do the right thing
or not.

ht


Jul 20 '05 #3
Catalogs are your friends: http://www.xml.com/pub/a/2004/03/03/catalogs.html

You can also pass the URL of the XSD to the DocumentBuilderFactory.

DocumentBuilderFactory dbf;
dbf.setValidating(validate);
dbf.setNamespaceAware(true);
dbf.setAttribute(http://java.sun.com/xml/jaxp/properties/schemaLanguage,
"http://www.w3.org/2001/XMLSchema");
URL xsdURL = cl.getResource("my/package/my.xsd");
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
jxlURL.toString());

I bet that for SAX there's a similar mechanism to configure the Schema.
Anyway, catalogs offer the most comprehensive solution.
Regards
-Laurens
Jul 20 '05 #4
Charles Fineman wrote:
Dunno if the parser can get resources from the jar but you could
probably do it by hand. Xerces allows you to cache "grammars" so you
could prepopulate the cache by doing "getResourceAsStream" to get the
xsd out of the jar and load it.


Hello, thanks for the answer, I found a way to get resource from a jar
and it works fine, but you talk about caching grammars. How do you do
such a thing?
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: aevans1108 | last post by:
Greetings All If this is the wrong place to post this question, please give me a push in the right direction. Thanks. I know there has to be a simpler way to do this, but this is as simple a...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
2
by: Steffen Balslev | last post by:
I tried to find a way to validate user credentials using C#, searching google and lots of other news and kb sites left me without a solution. You can use a SSPI but it's that easy to implement so...
1
by: ApexData | last post by:
Hello I have an UNBOUND textbox Text1 that I want to validate in code. I want to lock the user into the field until Valid Data is entered. I created the following Function: Private Function...
11
by: TokyoJ | last post by:
I run a small camp in Alaska for kids and my director is asking for a web form. Could someone please have a look and offer some advice on where I'm making mistake(s)? I'm using the RegExp function...
21
by: abcd | last post by:
In my code I am debating whether or not to validate the types of data being passed to my functions. For example def sayHello(self, name): if not name: rasie "name can't be null" if not...
4
by: syed.akhlaq | last post by:
Hi, Does anyone know how can I validate XPath expressions using xsd schema? Thanks
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
3
by: Adhal | last post by:
Hello, I have an XML and XSD file. When I do validation in the XML file I only get the first error. Is it possible to list all errors? One other question. -------------Microsoft Sample Code...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.