Hi Vitaly,
Thanks for the reply. I did set up an error handler, similar to
SAX2Count example. Basically my xml processing class extends the
DefaultHandler class in Xerces, and I implemented the following five
methods:
void endElement( const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname);
void characters(const XMLCh* const chars, const unsigned int
length);
void startElement( const XMLCh* const uri,
const XMLCh* const
localname,
const XMLCh* const
qname,
const Attributes&
attributes);
void error(const SAXParseException& exception);
void fatalError(const SAXParseException& exception);
But when I run the code, it never enters into the methods error(...) or
fatalError(...).
Again, I know I am using a very old version 1.7.0. Is this a problem? I
don't have problem parsing correct xml files, only that the validation
part seems not working as expected.
Thanks.
Frank
-----Original Message-----
From: Vitaly Prapirny [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 11, 2004 1:02 AM
To: [EMAIL PROTECTED]
Subject: Re: SAX parser validation set up
Hi,
Xiaofan Zhou wrote:
> Hi, all,
> I am a new xerces c++ users, and I am working on a project that uses
> xerces c++ 1.7 SAX parser. I have a question regarding setting up a
> validating SAX parser. I did the following when I set up the parser:
>
> ******
> SAX2XMLReader* pParser = XMLReaderFactory::createXMLReader();
> pParser->setFeature(XMLUni::fgSAX2CoreValidation, true);
> pParser->setFeature(XMLUni::fgSAX2XercesDynamic, true);
>
> *****
> But when I run the code, it seems the validation does not occur, for
> example, the DTD defines an element as the following:
>
> <!ELEMENT email EMPTY>
> <!ATTLIST email value CDATA #FIXED "[EMAIL PROTECTED]">
> Which means that the email element has an attribute with fixed value>
> [EMAIL PROTECTED], however, when I have a xml instance contain an element
>
> <email value="[EMAIL PROTECTED]"></email>
>
> It does not fail.
> My xml instance file has the following line
> <!DOCTYPE personnel SYSTEM "C:/mylocation/meta.dtd">
> Which is the DTD location that governs my xml instances.
> What else I need to do set up the parser correctly? And how about if
> the meta data is an XML schema?
You have to setting up error handler. Please try to process your xml
instance with SAX2Count sample and if it works than compare your sources
with SAX2Count sources. SAX2Count can validate against XML schema too.
Good luck !
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]