473,498 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to programatically assign a validating schema using Xerces?

Hello All,

Has anyone found a way to specify an xsd schema programatically when
using the apache xerces xml processor? I know that the validation
works fine as long as the xml instance document explicitly refernces
the schema via an 'xsd:xsi schemaLocation=...' tab. But how can you
validate xml documents which don't contain the schemaLocation?

Reading the instance and assigning the schemaLocation before flushing
it back out and reading it back works, but is such bad practice and
wasteful that it's not really worth considering.

MSXML has a simple validateOnParse and Schema Location properties
which can be set when parsing an instance. I was hoping there would
something similar in Xerces?

Thanks for any furher info..

Duncan
Jul 20 '05 #1
1 1588
> Has anyone found a way to specify an xsd schema programatically when
using the apache xerces xml processor?

You have to call these methods on the parser object:
setFeature("http://xml.org/sax/features/validation", true);
setFeature("http://apache.org/xml/features/validation/schema"
setProperty("http://apache.org/xml/properties/schema/external
-schemaLocation", "<namespace> <schema file>");

Jesper

--
Jesper Zedlitz eMail : je****@zedlitz.de
Homepage : http://www.zedlitz.de
ICQ# : 23890711
PGP-Key : http://zedlitz.de/pub_key.asc
Jul 20 '05 #2

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

Similar topics

0
1513
by: Jasmin Wason | last post by:
Hi, Does anyone know if it is possible to validate some XML with an in-memory schema using Xerces-J? I have a schema that exists as a String in my Java code. I would like to validate some XML...
1
1824
by: Kevin Partin | last post by:
I have downloaded the latest Xerces-J files from Apache.org and am trying to use them to validate an xml data file against a schema that I wrote. Can someone please provide me with the java command...
1
4265
by: scorpion | last post by:
I have this problem that an xml instance is validated correctly by xml tools, but not with my simple code, by setting the validating flag to true. --------------- Schema...
2
3590
by: Will | last post by:
I have been having problems validating an XForms document against the XForms schema located at http://www.w3.org/MarkUp/Forms/2002/XForms-Schema.xsd. I have reduced the XForm to its bare bones...
4
2911
by: Lénaďc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are...
4
5574
by: joes | last post by:
Hello there I tried for several days to get a simple validation with xml schema & xerces working. Goal for me is tuse JAXP and not specific Xerces classes. I don't get the point what I am doing...
4
2325
by: Oskar Stuffer | last post by:
Hi! I'm using the msv tool which uses xerces to validate a XML document against a XML Schema definition. This is my XML Schema definition: <?xml version="1.0" encoding="ISO-8859-1"?>...
2
3913
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
0
1189
by: Aaron P Frenger | last post by:
Hello All, I have a very large XML file that I would like to split up into a few smaller files, but still use only one schema. I am using Xerces C++ libraries. My idea is to have one schema...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7203
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
6885
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
7379
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...
1
4908
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
4588
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
3093
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...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.