Skip Menu |

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 14470
Status: resolved
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: l.simonneau [...] free.fr
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Patch adding support of new structured RNG validation function of libxml 2.6.21
Hi, I join a patch to LibXML.xs using xmlRelaxNGSetValidStructuredErrors for RelaxNG validation. The xmlRelaxNGSetValidStructuredErrors function appears in libxml 2.6.21 and permit to report more convenient error message including filename, line of error and error message. Cdt, Laurent Simonneau.
diff -ru XML-LibXML-1.58_1/LibXML.xs XML-LibXML-1.58_1-patched/LibXML.xs --- XML-LibXML-1.58_1/LibXML.xs 2004-03-25 00:06:14.000000000 +0100 +++ XML-LibXML-1.58_1-patched/LibXML.xs 2005-09-05 10:30:38.518899536 +0200 @@ -112,6 +112,28 @@ SvREFCNT_dec(sv); } +/* stores libxml structured errors into $@ */ +void +LibXML_structurederror_handler(void * ctxt, xmlErrorPtr serror) +{ + va_list args; + SV * sv; + /* xmlParserCtxtPtr context = (xmlParserCtxtPtr) ctxt; */ + sv = NEWSV(0,512); + + sv_setpvf(sv, "%s %s line %d: %s" , (serror->level == XML_ERR_WARNING) ? "Warning":"Error", + serror->file, serror->line, serror->message); + + if (LibXML_error != NULL) { + sv_catsv(LibXML_error, sv); /* remember the last error */ + } + else { + croak("%s", SvPV_nolen(sv)); + } + + SvREFCNT_dec(sv); +} + void LibXML_validity_error(void * ctxt, const char * msg, ...) { @@ -6116,10 +6138,9 @@ } /* Register Error callbacks */ - xmlRelaxNGSetValidErrors( vctxt, - (xmlRelaxNGValidityErrorFunc)LibXML_error_handler, - (xmlRelaxNGValidityWarningFunc)LibXML_error_handler, - vctxt ); + xmlRelaxNGSetValidStructuredErrors( vctxt, + (xmlStructuredErrorFunc)LibXML_structurederror_handler, + vctxt ); RETVAL = xmlRelaxNGValidateDoc( vctxt, doc ); xmlRelaxNGFreeValidCtxt( vctxt );
I'm postponing this bug since your patch provides only a half way solution to the problem. The CVS contains a rather incomplete and possibly broken and somewhat abandoned branch tagged 'structerror', which contains a new experimental approach to error handling. It completely replaces current XML-LibXML error handling code with a new subsystem based on structured error exception objects. If you are interested, feel free to look at it and help us improving it so that it can be merged with the CVS head. -- Petr Pajas
Complete support for structured errors was added in the SVN version, which will soon become 1.67. This should cover RNG validation as well.