473,574 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Schema validation

I have a problem with the code sample below, basically when i run it i
get the error
classnotfoundex ception org.apache.xerc es.parsers.SAXP arser
now i know the simple answer is declare xerces.jar in your classpath
but i have done that. I have even gotten xerces 2.5...... and still
nothing, i am really struggling here.
see the code below.

import java.io.IOExcep tion;
import org.xml.sax.XML Reader;
import org.apache.xerc es.parsers.SAXP arser;

import org.xml.sax.hel pers.DefaultHan dler;
import org.xml.sax.hel pers.XMLReaderF actory;
import org.xml.sax.SAX Exception;
import org.xml.sax.SAX ParseException;
class XMLReaderValida tor {
public static void main(String args[]) {

String parserClass = "org.apache.xer ces.parsers.SAX Parser";
String validationFeatu re
= "http://xml.org/sax/features/validation";
String schemaFeature
= "http://apache.org/xml/features/validation/schema";
try {
String x = "<xml></xml>"; //args[0];
XMLReader r = XMLReaderFactor y.createXMLRead er(parserClass) ;
r.setFeature(va lidationFeature ,true);
r.setFeature(sc hemaFeature,tru e);
r.setErrorHandl er(new MyErrorHandler( ));
} catch (SAXException e) {
System.out.prin tln(e.toString( ));
} catch (IOException e) {
System.out.prin tln(e.toString( ));
private static class MyErrorHandler extends DefaultHandler {
public void warning(SAXPars eException e) throws SAXException {
System.out.prin tln("Warning: ");
public void error(SAXParseE xception e) throws SAXException {
System.out.prin tln("Error: ");
public void fatalError(SAXP arseException e) throws SAXException {
System.out.prin tln("Fattal error: ");
private void printInfo(SAXPa rseException e) {
System.out.prin tln(" Public ID: "+e.getPublicId ());
System.out.prin tln(" System ID: "+e.getSystemId ());
System.out.prin tln(" Line number: "+e.getLineNumb er());
System.out.prin tln(" Column number: "+e.getColumnNu mber());
System.out.prin tln(" Message: "+e.getMessage( ));
Jul 20 '05 #1
0 1731

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

Similar topics

by: Steve | last post by:
Hi, I have xml data containing "line item" elements and a "footer" element which contains control totals for the line items. While I can easily validate the control totals in xslt, I have not been able to do it using a schema, which I need to do. Example: <data> <item><fld1>1</fld2><fld2>2</fld2></item>
by: brandon | last post by:
I want to speed up the validation of some of my fairly large and detailed XML files. In particular there is a set of child elements and attributes that does not to be validated after it has completed a certain point in the system, but that will still be present in the file. At points later in the system, when these files are read in, I do...
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data. Actually, second time I do a deserialization, the data from XML is fed directly to an object. The problem I am experiencing is the error at the...
by: Ricky Li | last post by:
I went through some article to see how I can add schema validation for my templated control by adding an XSD file into the VS.NET schema folder. Everything works fine for a schema like this: <mycontrolns:mycontrol id="test" runat="server"> <mytemplate>test</mytemplate> </mycontrolns> and I was able to specify the XSD to validate...
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i reference this wsdl in .NET it seems to do it fine, yet there are no objects to reference except RateQuoteBeanService. In the WSDL it looks like there...
by: info | last post by:
Hi, Is it possible to include in the Schema validation file, every custom error message for each validation rules? This mean, in the same xsd file we can have the validation rules (patterns) and the custom error message throw during validation for the end user. I know .NET enable it using errorMessage tag, but with a standard W3C java...
by: wolf_y | last post by:
My question is simply: under what conditions will empty tags of the form <MOM></MOM> pass schema validation? Of course, the mirror question is: under what conditions will empty tags fail validation? The former seems to be an easier question to answer. XML files will arrive from around the world and must be schema validated before further...
by: merryla | last post by:
Hi, I tried to perform schema validation. The code works well. But when I tried with the Sample txlife.xsd file from http://acord.org/ I got error in associating the namespace with the xsd i.e. in the add () method. The add () method returned E_FALSE. When I referred the MSDN library, it states that "E_FAIL is returned if: · The...
by: pnmcosta | last post by:
Hi, I'm fairly new to XML Schema validation. We have XML being imported that must validate against the following schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.temp.com/ContactsImport" xmlns="http://www.temp.com/ContactsImport" elementFormDefault="qualified"> ...
by: kenkejas | last post by:
Hello public, Got a problem. While generating proxy classes getting warnings: Schema Validation Errors: Error compiling schema. WSDL descriptor is public: http://eptstest-integra.sodra.lt/orabpel/epts/surastiAsmenis/surastiAsmenis?wsdl Have tried with Altova XML spy and SoapUI 3.5. Descriptors load well except WseWsdl3.exe tool. Using...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 we have to send another system
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.