mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-23 01:52:48 +03:00
Fix file and line report for XSD SAX and reader streaming validation
Things now work correctly at the xmllint level: thinkpad:~/XML -> xmllint --sax --noout --schema test_schema.xsd test_xml.xml test_xml.xml:72721: Schemas validity error : Element 'level1': Missing child element(s). Expected is ( level2 ). test_xml.xml fails to validate thinkpad:~/XML -> xmllint --stream --schema test_schema.xsd test_xml.xml test_xml.xml:72721: Schemas validity error : Element 'level1': Missing child element(s). Expected is ( level2 ). test_xml.xml fails to validate thinkpad:~/XML -> * error.c: fix a corner case of not reporting lines when we should * include/libxml/xmlschemas.h doc/symbols.xml: had to add new entry points to set the filename on a validation context and a locator callback used to fetch the line and file from the context * xmlschemas.c: add the new entry points xmlSchemaValidateSetFilename() and xmlSchemaValidateSetLocator(), plus make sure the error reporting routine gets the information if available. Add a locator for SAX. * xmlreader.c: add and plug a locator for readers.
This commit is contained in:
@@ -113,6 +113,22 @@ typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
|
||||
typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
|
||||
typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
|
||||
|
||||
/**
|
||||
* xmlSchemaValidityLocatorFunc:
|
||||
* @ctx: user provided context
|
||||
* @file: returned file information
|
||||
* @line: returned line information
|
||||
*
|
||||
* A schemas validation locator, a callback called by the validator.
|
||||
* This is used when file or node informations are not available
|
||||
* to find out what file and line number are affected
|
||||
*
|
||||
* Returns: 0 in case of success and -1 in case of error
|
||||
*/
|
||||
|
||||
typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
|
||||
const char **file, unsigned long *line);
|
||||
|
||||
/*
|
||||
* Interfaces for parsing.
|
||||
*/
|
||||
@@ -171,6 +187,9 @@ XMLPUBFUN int XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
|
||||
int options);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
|
||||
const char *filename);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
|
||||
|
||||
@@ -210,6 +229,13 @@ XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
|
||||
void **user_data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
|
||||
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
|
||||
xmlSchemaValidityLocatorFunc f,
|
||||
void *ctxt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user