Re: [xml] accessing Parser-Ctxt in SAX based schema validation
- From: Holger Kaelberer <hkaelber math uni-bielefeld de>
- To: veillard redhat com
- Cc: xml gnome org
- Subject: Re: [xml] accessing Parser-Ctxt in SAX based schema validation
- Date: Thu, 10 Apr 2008 10:37:29 +0200
Hi Daniel.
Daniel Veillard wrote:
But what do I set my state->ctxt to (supposed to be a xmlParserCtxtPtr)
as I don't have the parser-Ctxt of the parsed xml-file? I first thought
of passing the xmlSchemaValidCtxtPtr and than using vctxt->parserCtxt in
my SAX-handler, but that does not work as the parserCtxt-element is not
"public".
Hum, right one would need to add an accessor function at the end of
xmlschemas.c ...
Ok, the attached patch does the job.
But what are you using the parser context for, i'm curious ?
So far only for accessing line numbers in the parsed xml-file, when
printing error message for content checks. May be I can get around these
messages by using the planed schema validation. But then I'm running in
another problem:
With Sax based schema validation enabled I don't get line-numbers
printed out for validity errors when using the default output handler
for validation errors -- which makes the output not very useful!. Why?
When I try to work around this by attaching some other handler using
xmlSchemaSetValidErrors I also do need access to the parserCtxt
encapsulated in the schemaValidContextPtr. With the changes made by the
supplied patch I get it working this way.
Is there any other way for accessing line numbers in the parsed xml? If
no, any chance to get the patch included in the distribution?
Thanks,
Holger
diff -r libxml2-2.6.31/include/libxml/xmlschemas.h libxml2-2.6.31-hk/include/libxml/xmlschemas.h
180a181,183
XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
diff -r libxml2-2.6.31/xmlschemas.c libxml2-2.6.31-hk/xmlschemas.c
28670a28671,28684
/**
* xmlSchemaValidCtxtGetParserCtxt:
* @ctxt: a schema validation context
*
* Return the parser context of the schema validation context passed.
*
* Returns the parser context of the schema validation context passed
*/
inline xmlParserCtxtPtr
xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt)
{
return (ctxt->parserCtxt);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]