You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Frank Zhou <fc...@yahoo.com> on 2006/05/18 22:39:16 UTC
XML validation against DTD using loadGrammar
Hi All,
I asked this question in c-dev list, but not getting
satisfying answers, so I post it here:
I am using Xerces-c 2.7. I am having a problem
validating XML against a given DTD (a string).
I am using SAX2XMLReader and using loadGrammar(...) to
load the DTD. My code is something like this:
SAX2XMLReader* parser =
XMLReaderFactory::createXMLReader();
parser->setFeature(XMLUni::fgSAX2CoreValidation,
m_bValidate);
parser->setFeature(XMLUni::fgXercesDynamic, true);
parser->setFeature(XMLUni::fgXercesCacheGrammarFromParse,
true);
parser->loagGrammar(DTDInputSource,
Grammar::DTDGrammarType);
parser->setErrorHandler(errorHandler);
parser->setContentHandler(contentHandler);
parser->parse(XMLinputsource);
I noticed that the validation is not happening,
invalid xml gets parsed without problem. However, if I
don't use loadGrammar(...), instead, I embedded the
dtd content into XML input using <!DOCTYPE ... ]>,
then the validation happens correctly.
Do I need to do some special settings? any problem
with loadGrammar(...)?
Thanks much.
Frank
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: XML validation against DTD using loadGrammar
Posted by Frank Zhou <fc...@yahoo.com>.
I meant to send to c-users list.
sorry about that.
Frank
--- Frank Zhou <fc...@yahoo.com> wrote:
> Hi All,
>
> I asked this question in c-dev list, but not getting
> satisfying answers, so I post it here:
>
> I am using Xerces-c 2.7. I am having a problem
> validating XML against a given DTD (a string).
>
> I am using SAX2XMLReader and using loadGrammar(...)
> to
> load the DTD. My code is something like this:
>
> SAX2XMLReader* parser =
> XMLReaderFactory::createXMLReader();
> parser->setFeature(XMLUni::fgSAX2CoreValidation,
> m_bValidate);
> parser->setFeature(XMLUni::fgXercesDynamic,
> true);
>
>
parser->setFeature(XMLUni::fgXercesCacheGrammarFromParse,
> true);
>
> parser->loagGrammar(DTDInputSource,
> Grammar::DTDGrammarType);
>
> parser->setErrorHandler(errorHandler);
> parser->setContentHandler(contentHandler);
>
> parser->parse(XMLinputsource);
>
> I noticed that the validation is not happening,
> invalid xml gets parsed without problem. However, if
> I
> don't use loadGrammar(...), instead, I embedded the
> dtd content into XML input using <!DOCTYPE ... ]>,
> then the validation happens correctly.
>
> Do I need to do some special settings? any problem
> with loadGrammar(...)?
>
> Thanks much.
> Frank
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail:
> c-dev-help@xerces.apache.org
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org