473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Schema validation ( and my pain in the u know what)

i have the following code (see below), i run my validation and get
unexpected results.

Public ID: null
System ID: file:///C:/DATA/Sandpit/Eclipse/workspace/dtdValidation/memory.xml
Line number: 4
Column number: 44
Message: Element type "memories" must be declared.

Public ID: null
System ID: file:///C:/DATA/Sandpit/Eclipse/workspace/dtdValidation/memory.xml
Line number: 5
Column number: 24
Message: Element type "memory" must be declared.

and so on for almost every element in the XML where i should be
getting real schema errors eg.

Public ID: null
System ID: file:///D:/herong/dictionary_invalid_xsd.xml
Line number: 7
Column number: 22
Message: cvc-datatype-valid.1.2.1: 'yes' is not a valid 'boolean'

To me it looks like the validation is not actually picking up the
schema, does this sound right?. The schema and xml are both in the
same directory. Can someone give me some ideas on the possible source
of the problem.
I have been looking at previous posts on this forum and nobody seems
to be getting an answer. Please help i am despirate here, my deadline
date is approaching fast.
class validation {

public static StringBuffer sErrorBuffer = new StringBuffer();

public static void main(String args[]) {
try {

String parserClass = "org.apache.xerces.parsers.SAXParser";
String validationFeature
= "http://xml.org/sax/features/validation";
String schemaFeature
= "http://apache.org/xml/features/validation/schema";

XMLReader r = XMLReaderFactory.createXMLReader(parserClass);
r.setErrorHandler(new MyErrorHandler());


System.out.println("So many errors so little time");

} catch (SAXException e) {
} catch (IOException e) {
}catch (Exception e) {
private static class MyErrorHandler extends DefaultHandler {

public void warning(SAXParseException e) throws SAXException {
System.out.println("Warning: ");
public void error(SAXParseException e) throws SAXException {
System.out.println("Error: ");
public void fatalError(SAXParseException e) throws SAXException {
System.out.println("Fattal error: ");
private void printInfo(SAXParseException e) {
sErrorBuffer.append("\n Public ID: "+e.getPublicId());
sErrorBuffer.append("\n System ID: "+e.getSystemId());
sErrorBuffer.append("\n Line number: "+e.getLineNumber());
sErrorBuffer.append("\n Column number: "+e.getColumnNumber());
sErrorBuffer.append("\n Message: "+e.getMessage() + "\n");


<?xml version="1.0"?>
<memories xmlns:xsi=
<memory tapeid="23412">
<donor>John Baker</donor>
<subject>Fishing off Pier 60</subject>
<memory tapeid="23692">
<donor>Elizabeth Davison</donor>
<subject>Beach volleyball</subject>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="memories">
<xsd:element name="memory" maxOccurs="unbounded"

<xsd:complexType name="memoryType">
<xsd:element name="media">
<xsd:attribute name="mediaid" type="xsd:string" />
<xsd:attribute name="status" type="xsd:string" />
<xsd:element name="subdate" type="xsd:string"/>
<xsd:element name="donor" type="xsd:string"/>
<xsd:element name="subject" type="xsd:string"/>
<xsd:element name="location" type="locationType" />
<xsd:attribute name="tapeid" type="xsd:string" />
<xsd:attribute name="status" type="xsd:string" />

<xsd:complexType name="locationType">
<xsd:element name="description" type="xsd:string" />
<xsd:element name="place" type="xsd:string" />
Jul 20 '05 #1
0 1675

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...
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...
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....
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: ...
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...
by: Adam Clauss | last post by:
I'm running into a problem with schema validation. For some reason, if a schema has an xs:all section to it, it does not validate correctly. It seems to treat it as a sequence. My understanding...
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)...
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...
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" ...
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:...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
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...
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...
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,...
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...

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.