473,385 Members | 1,546 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,385 software developers and data experts.

Schema validation using Xerces-C++ version 1.6.0?

Hi y'all,

I am trying to do validation of xml files against their schema using
the Xerces library. I am expecting to get an exception while calling
DOMParser::parse method when the xml file is invalid, i.e. it doesn't
conform to its schema, but I don't get any exception. What am I doing
wrong?

Following is snippet of my code:

------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
cout << "Error during initialization! :\n"
<< DOMString(toCatch.getMessage()) << endl;
return 1;
}

string xml_file = "test.xml";
bool valid = true;

try
{
DOMParser* parser = new DOMParser;

parser->setDoNamespaces(true);
parser->setDoSchema(true);
parser->setValidationSchemaFullChecking(true);
parser->setValidationConstraintFatal(true);
ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
parser->setErrorHandler(errHandler);

parser->parse(xml_file.c_str());

delete errHandler;
delete parser;
}
catch (...) {
cout << "An error occurred during parsing" << endl;
valid = false;
}

cout << "The xml file is " << ( valid ? "valid" : "invalid" ) <<
endl;

XMLPlatformUtils::Terminate();

return 0;
}

------------------------------------------------------------------------------
Thank you for your replies.

Vikas
Jul 20 '05 #1
0 1510

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

Similar topics

3
by: Robert Lintner | last post by:
Hi, I woult like to switch from DTD to XML-Schema and am looking for an equivalent to external ENTITY for composition of an xml file from modules --- my.dtd -- <?xml version="1.0"...
1
by: Ole Hedegaard | last post by:
Hi, I've been looking into the Xerces documentation, and to my surprise it seems that it is impossible to validate an XML document againts an XML Schema without having a schemaLocation (or...
1
by: Duncan Smith | last post by:
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...
3
by: D. Alvarado | last post by:
Hello, I am sort of new to all this XML, but I would like to enforce a date format within one of my XML elements. Everything I've read indicates that a DTD is not suitable for this purposes, so I...
4
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...
0
by: motoman | last post by:
I have a problem with the code sample below, basically when i run it i get the error classnotfoundexception org.apache.xerces.parsers.SAXParser now i know the simple answer is declare xerces.jar...
1
by: mrc-1 | last post by:
Hello, I built a XSD File with the tool XML-Spy from Altova. My XML file consists of about 5000 elements. If I use the validate button in XML-Spy, the validation process takes about 8 seconds....
7
by: christian.eickhoff | last post by:
Hi Everyone, I am currently implementing an XercesDOMParser to parse an XML file and to validate this file against its XSD Schema file which are both located on my local HD drive. For this...
1
by: Nuno | last post by:
Hello, I'm looking for a way of validating/parsing the xsd file (schema), i only been able of validating the xml file with the corresponding schema, but what i want is only validate the xsd...
9
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13>...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
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
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 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.