mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-27 18:50:07 +03:00
fixed a typo pointed by Jeroen Ruigrok increased the APIs for xmlReader
* doc/xmllint.1 doc/xmllint.html doc/xmllint.xml: fixed a typo pointed by Jeroen Ruigrok * include/libxml/xmlreader.h include/libxml/xmlschemas.h: increased the APIs for xmlReader schemas validation support * xmllint.c xmlreader.c xmlschemas.c: xmlReader schemas validation implementation and testing as xmllint --stream --schema ... Daniel
This commit is contained in:
parent
d17760f397
commit
f10ae12cb8
@ -1,3 +1,12 @@
|
||||
Sun Jul 10 21:00:54 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* doc/xmllint.1 doc/xmllint.html doc/xmllint.xml: fixed a typo
|
||||
pointed by Jeroen Ruigrok
|
||||
* include/libxml/xmlreader.h include/libxml/xmlschemas.h: increased
|
||||
the APIs for xmlReader schemas validation support
|
||||
* xmllint.c xmlreader.c xmlschemas.c: xmlReader schemas validation
|
||||
implementation and testing as xmllint --stream --schema ...
|
||||
|
||||
Sun Jul 10 16:11:26 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* include/libxml/xmlwin32version.h.in: try to avoid conflicts.
|
||||
|
@ -144,7 +144,7 @@ Use the HTML parser\&.
|
||||
|
||||
.TP
|
||||
\fB\-\-xmlout\fR
|
||||
Used in conjusntion with \fB\-\-html\fR\&. Usually when HTML is parsed the document is saved with the HTML serializer, but with this option the resulting document is saved with the XML serializer\&. This is primarily used to generate XHTML from HTML input\&.
|
||||
Used in conjunction with \fB\-\-html\fR\&. Usually when HTML is parsed the document is saved with the HTML serializer, but with this option the resulting document is saved with the XML serializer\&. This is primarily used to generate XHTML from HTML input\&.
|
||||
|
||||
.TP
|
||||
\fB\-\-push\fR
|
||||
|
@ -71,7 +71,7 @@
|
||||
Turn on gzip compression of output.
|
||||
</dd><dt><span class="term"><tt class="option">--html</tt></span></dt><dd>
|
||||
Use the <span class="acronym">HTML</span> parser.
|
||||
</dd><dt><span class="term"><tt class="option">--xmlout</tt></span></dt><dd>Used in conjusntion with <tt class="option">--html</tt>. Usually
|
||||
</dd><dt><span class="term"><tt class="option">--xmlout</tt></span></dt><dd>Used in conjunction with <tt class="option">--html</tt>. Usually
|
||||
when HTML is parsed the document is saved with the HTML serializer, but with
|
||||
this option the resulting document is saved with the XML serializer. This is
|
||||
primarily used to generate XHTML from HTML input.</dd><dt><span class="term"><tt class="option">--push</tt></span></dt><dd>
|
||||
|
@ -376,7 +376,7 @@
|
||||
<varlistentry>
|
||||
<term><option>--xmlout</option></term>
|
||||
<listitem>
|
||||
<simpara>Used in conjusntion with <option>--html</option>. Usually
|
||||
<simpara>Used in conjunction with <option>--html</option>. Usually
|
||||
when HTML is parsed the document is saved with the HTML serializer, but with
|
||||
this option the resulting document is saved with the XML serializer. This is
|
||||
primarily used to generate XHTML from HTML input.</simpara>
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <libxml/xmlIO.h>
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
#include <libxml/relaxng.h>
|
||||
#include <libxml/xmlschemas.h>
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
@ -275,6 +276,12 @@ XMLPUBFUN int XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
|
||||
xmlRelaxNGPtr schema);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
|
||||
const char *xsd);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlTextReaderSetSchema (xmlTextReaderPtr reader,
|
||||
xmlSchemaPtr schema);
|
||||
#endif
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);
|
||||
|
@ -114,10 +114,13 @@ XMLPUBFUN void XMLCALL
|
||||
xmlSchemaValidityWarningFunc warn,
|
||||
void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchemaGetParserErrors (xmlSchemaParserCtxtPtr ctxt,
|
||||
xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
|
||||
xmlSchemaValidityErrorFunc * err,
|
||||
xmlSchemaValidityWarningFunc * warn,
|
||||
void **ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
|
||||
|
||||
XMLPUBFUN xmlSchemaPtr XMLCALL
|
||||
xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
|
19
xmllint.c
19
xmllint.c
@ -1843,6 +1843,21 @@ static void streamFile(char *filename) {
|
||||
endTimer("Compiling the schemas");
|
||||
}
|
||||
}
|
||||
if (schema != NULL) {
|
||||
if ((timing) && (!repeat)) {
|
||||
startTimer();
|
||||
}
|
||||
ret = xmlTextReaderSchemaValidate(reader, schema);
|
||||
if (ret < 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XSD schema %s failed to compile\n", schema);
|
||||
progresult = XMLLINT_ERR_SCHEMACOMP;
|
||||
schema = NULL;
|
||||
}
|
||||
if ((timing) && (!repeat)) {
|
||||
endTimer("Compiling the schemas");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -1885,7 +1900,7 @@ static void streamFile(char *filename) {
|
||||
}
|
||||
#endif /* LIBXML_VALID_ENABLED */
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
if (relaxng != NULL) {
|
||||
if ((relaxng != NULL) || (schema != NULL)) {
|
||||
if (xmlTextReaderIsValid(reader) != 1) {
|
||||
fprintf(stderr, "%s fails to validate\n", filename);
|
||||
progresult = XMLLINT_ERR_VALID;
|
||||
@ -3208,7 +3223,7 @@ main(int argc, char **argv) {
|
||||
}
|
||||
} else if ((schema != NULL)
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
&& (stream == 0)
|
||||
&& (stream == 0)
|
||||
#endif
|
||||
) {
|
||||
xmlSchemaParserCtxtPtr ctxt;
|
||||
|
206
xmlreader.c
206
xmlreader.c
@ -32,7 +32,10 @@
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/xmlreader.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
#include <libxml/relaxng.h>
|
||||
#include <libxml/xmlschemas.h>
|
||||
#endif
|
||||
#include <libxml/uri.h>
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#include <libxml/xinclude.h>
|
||||
@ -85,7 +88,8 @@ typedef enum {
|
||||
typedef enum {
|
||||
XML_TEXTREADER_NOT_VALIDATE = 0,
|
||||
XML_TEXTREADER_VALIDATE_DTD = 1,
|
||||
XML_TEXTREADER_VALIDATE_RNG = 2
|
||||
XML_TEXTREADER_VALIDATE_RNG = 2,
|
||||
XML_TEXTREADER_VALIDATE_XSD = 4
|
||||
} xmlTextReaderValidate;
|
||||
|
||||
struct _xmlTextReader {
|
||||
@ -129,6 +133,11 @@ struct _xmlTextReader {
|
||||
xmlRelaxNGValidCtxtPtr rngValidCtxt;/* The Relax NG validation context */
|
||||
int rngValidErrors;/* The number of errors detected */
|
||||
xmlNodePtr rngFullNode; /* the node if RNG not progressive */
|
||||
/* Handling of Schemas validation */
|
||||
xmlSchemaPtr xsdSchemas; /* The Schemas schemas */
|
||||
xmlSchemaValidCtxtPtr xsdValidCtxt;/* The Schemas validation context */
|
||||
int xsdValidErrors;/* The number of errors detected */
|
||||
xmlSchemaSAXPlugPtr xsdPlug; /* the schemas plug in SAX pipeline */
|
||||
#endif
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
/* Handling of XInclude processing */
|
||||
@ -1522,6 +1531,13 @@ node_found:
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* LIBXML_PATTERN_ENABLED */
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
if ((reader->validate == XML_TEXTREADER_VALIDATE_XSD) &&
|
||||
(reader->xsdValidErrors == 0) &&
|
||||
(reader->xsdValidCtxt != NULL)) {
|
||||
reader->xsdValidErrors = !xmlSchemaIsValid(reader->xsdValidCtxt);
|
||||
}
|
||||
#endif /* LIBXML_PATTERN_ENABLED */
|
||||
return(1);
|
||||
node_end:
|
||||
@ -2118,6 +2134,18 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
|
||||
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
||||
reader->rngValidCtxt = NULL;
|
||||
}
|
||||
if (reader->xsdPlug != NULL) {
|
||||
xmlSchemaSAXUnplug(reader->xsdPlug);
|
||||
reader->xsdPlug = NULL;
|
||||
}
|
||||
if (reader->xsdValidCtxt != NULL) {
|
||||
xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
|
||||
reader->xsdValidCtxt = NULL;
|
||||
}
|
||||
if (reader->xsdSchemas != NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
}
|
||||
#endif
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
if (reader->xincctxt != NULL)
|
||||
@ -3906,6 +3934,80 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderSetSchema:
|
||||
* @reader: the xmlTextReaderPtr used
|
||||
* @schema: a precompiled Schema schema
|
||||
*
|
||||
* Use XSD Schema to validate the document as it is processed.
|
||||
* Activation is only possible before the first Read().
|
||||
* if @schema is NULL, then Schema validation is desactivated.
|
||||
@ The @schema should not be freed until the reader is deallocated
|
||||
* or its use has been deactivated.
|
||||
*
|
||||
* Returns 0 in case the Schema validation could be (des)activated and
|
||||
* -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
|
||||
if (reader == NULL)
|
||||
return(-1);
|
||||
if (schema == NULL) {
|
||||
if (reader->xsdPlug != NULL) {
|
||||
xmlSchemaSAXUnplug(reader->xsdPlug);
|
||||
reader->xsdPlug = NULL;
|
||||
}
|
||||
if (reader->xsdValidCtxt != NULL) {
|
||||
xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
|
||||
reader->xsdValidCtxt = NULL;
|
||||
}
|
||||
if (reader->xsdSchemas != NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
|
||||
return(-1);
|
||||
if (reader->xsdPlug != NULL) {
|
||||
xmlSchemaSAXUnplug(reader->xsdPlug);
|
||||
reader->xsdPlug = NULL;
|
||||
}
|
||||
if (reader->xsdValidCtxt != NULL) {
|
||||
xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
|
||||
reader->xsdValidCtxt = NULL;
|
||||
}
|
||||
if (reader->xsdSchemas != NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
}
|
||||
reader->xsdValidCtxt = xmlSchemaNewValidCtxt(schema);
|
||||
if (reader->xsdValidCtxt == NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
return(-1);
|
||||
}
|
||||
reader->xsdPlug = xmlSchemaSAXPlug(reader->xsdValidCtxt,
|
||||
&(reader->ctxt->sax),
|
||||
&(reader->ctxt->userData));
|
||||
if (reader->xsdPlug == NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
|
||||
reader->xsdValidCtxt = NULL;
|
||||
return(-1);
|
||||
}
|
||||
if (reader->errorFunc != NULL) {
|
||||
xmlSchemaSetValidErrors(reader->xsdValidCtxt,
|
||||
(xmlSchemaValidityErrorFunc)reader->errorFunc,
|
||||
(xmlSchemaValidityWarningFunc) reader->errorFunc,
|
||||
reader->errorFuncArg);
|
||||
}
|
||||
reader->xsdValidErrors = 0;
|
||||
reader->validate = XML_TEXTREADER_VALIDATE_XSD;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderRelaxNGValidate:
|
||||
* @reader: the xmlTextReaderPtr used
|
||||
@ -3926,14 +4028,14 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
|
||||
return(-1);
|
||||
|
||||
if (rng == NULL) {
|
||||
if (reader->rngSchemas != NULL) {
|
||||
xmlRelaxNGFree(reader->rngSchemas);
|
||||
reader->rngSchemas = NULL;
|
||||
}
|
||||
if (reader->rngValidCtxt != NULL) {
|
||||
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
||||
reader->rngValidCtxt = NULL;
|
||||
}
|
||||
if (reader->rngSchemas != NULL) {
|
||||
xmlRelaxNGFree(reader->rngSchemas);
|
||||
reader->rngSchemas = NULL;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
|
||||
@ -3958,8 +4060,11 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
|
||||
if (reader->rngSchemas == NULL)
|
||||
return(-1);
|
||||
reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(reader->rngSchemas);
|
||||
if (reader->rngValidCtxt == NULL)
|
||||
if (reader->rngValidCtxt == NULL) {
|
||||
xmlRelaxNGFree(reader->rngSchemas);
|
||||
reader->rngSchemas = NULL;
|
||||
return(-1);
|
||||
}
|
||||
if (reader->errorFunc != NULL) {
|
||||
xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
|
||||
(xmlRelaxNGValidityErrorFunc)reader->errorFunc,
|
||||
@ -3971,6 +4076,93 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
|
||||
reader->validate = XML_TEXTREADER_VALIDATE_RNG;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlTextReaderSchemaValidate:
|
||||
* @reader: the xmlTextReaderPtr used
|
||||
* @xsd: the path to a W3C XSD schema or NULL
|
||||
*
|
||||
* Use W3C XSD schema to validate the document as it is processed.
|
||||
* Activation is only possible before the first Read().
|
||||
* if @xsd is NULL, then RelaxNG validation is desactivated.
|
||||
*
|
||||
* Returns 0 in case the schemas validation could be (des)activated and
|
||||
* -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlTextReaderSchemaValidate(xmlTextReaderPtr reader, const char *xsd) {
|
||||
xmlSchemaParserCtxtPtr ctxt;
|
||||
|
||||
if (reader == NULL)
|
||||
return(-1);
|
||||
|
||||
if (xsd == NULL) {
|
||||
if (reader->xsdPlug != NULL) {
|
||||
xmlSchemaSAXUnplug(reader->xsdPlug);
|
||||
reader->xsdPlug = NULL;
|
||||
}
|
||||
if (reader->xsdSchemas != NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
}
|
||||
if (reader->xsdValidCtxt != NULL) {
|
||||
xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
|
||||
reader->xsdValidCtxt = NULL;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
if ((reader->mode != XML_TEXTREADER_MODE_INITIAL) ||
|
||||
(reader->ctxt == NULL))
|
||||
return(-1);
|
||||
if (reader->xsdPlug != NULL) {
|
||||
xmlSchemaSAXUnplug(reader->xsdPlug);
|
||||
reader->xsdPlug = NULL;
|
||||
}
|
||||
if (reader->xsdValidCtxt != NULL) {
|
||||
xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
|
||||
reader->xsdValidCtxt = NULL;
|
||||
}
|
||||
if (reader->xsdSchemas != NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
}
|
||||
ctxt = xmlSchemaNewParserCtxt(xsd);
|
||||
if (reader->errorFunc != NULL) {
|
||||
xmlSchemaSetParserErrors(ctxt,
|
||||
(xmlSchemaValidityErrorFunc) reader->errorFunc,
|
||||
(xmlSchemaValidityWarningFunc) reader->errorFunc,
|
||||
reader->errorFuncArg);
|
||||
}
|
||||
reader->xsdSchemas = xmlSchemaParse(ctxt);
|
||||
xmlSchemaFreeParserCtxt(ctxt);
|
||||
if (reader->xsdSchemas == NULL)
|
||||
return(-1);
|
||||
reader->xsdValidCtxt = xmlSchemaNewValidCtxt(reader->xsdSchemas);
|
||||
if (reader->xsdValidCtxt == NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
return(-1);
|
||||
}
|
||||
reader->xsdPlug = xmlSchemaSAXPlug(reader->xsdValidCtxt,
|
||||
&(reader->ctxt->sax),
|
||||
&(reader->ctxt->userData));
|
||||
if (reader->xsdPlug == NULL) {
|
||||
xmlSchemaFree(reader->xsdSchemas);
|
||||
reader->xsdSchemas = NULL;
|
||||
xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
|
||||
reader->xsdValidCtxt = NULL;
|
||||
return(-1);
|
||||
}
|
||||
if (reader->errorFunc != NULL) {
|
||||
xmlSchemaSetValidErrors(reader->xsdValidCtxt,
|
||||
(xmlSchemaValidityErrorFunc)reader->errorFunc,
|
||||
(xmlSchemaValidityWarningFunc) reader->errorFunc,
|
||||
reader->errorFuncArg);
|
||||
}
|
||||
reader->xsdValidErrors = 0;
|
||||
reader->validate = XML_TEXTREADER_VALIDATE_XSD;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -4339,6 +4531,8 @@ xmlTextReaderIsValid(xmlTextReaderPtr reader) {
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
if (reader->validate == XML_TEXTREADER_VALIDATE_RNG)
|
||||
return(reader->rngValidErrors == 0);
|
||||
if (reader->validate == XML_TEXTREADER_VALIDATE_XSD)
|
||||
return(reader->xsdValidErrors == 0);
|
||||
#endif
|
||||
if ((reader->ctxt != NULL) && (reader->ctxt->validate == 1))
|
||||
return(reader->ctxt->valid);
|
||||
|
115
xmlschemas.c
115
xmlschemas.c
@ -23465,6 +23465,7 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
|
||||
return;
|
||||
|
||||
vctxt->flags = 0;
|
||||
vctxt->err = 0;
|
||||
vctxt->validationRoot = NULL;
|
||||
vctxt->doc = NULL;
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
@ -23607,6 +23608,23 @@ xmlSchemaFreeValidCtxt(xmlSchemaValidCtxtPtr ctxt)
|
||||
xmlFree(ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSchemaIsValid:
|
||||
* @ctxt: the schema validation context
|
||||
*
|
||||
* Check if any error was detected during validation.
|
||||
*
|
||||
* Returns 1 if valid so far, 0 if errors were detected, and -1 in case
|
||||
* of internal error.
|
||||
*/
|
||||
int
|
||||
xmlSchemaIsValid(xmlSchemaValidCtxtPtr ctxt)
|
||||
{
|
||||
if (ctxt == NULL)
|
||||
return(-1);
|
||||
return(ctxt->err == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSchemaSetValidErrors:
|
||||
* @ctxt: a schema validation context
|
||||
@ -23863,10 +23881,7 @@ internal_error:
|
||||
}
|
||||
|
||||
static int
|
||||
xmlSchemaVStart(xmlSchemaValidCtxtPtr vctxt)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
|
||||
/*
|
||||
* Some initialization.
|
||||
*/
|
||||
@ -23899,32 +23914,11 @@ xmlSchemaVStart(xmlSchemaValidCtxtPtr vctxt)
|
||||
xmlHashScan(vctxt->schema->idcDef,
|
||||
(xmlHashScanner) xmlSchemaAugmentIDC, vctxt);
|
||||
}
|
||||
if (vctxt->doc != NULL) {
|
||||
/*
|
||||
* Tree validation.
|
||||
*/
|
||||
ret = xmlSchemaVDocWalk(vctxt);
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
} else if (vctxt->reader != NULL) {
|
||||
/*
|
||||
* XML Reader validation.
|
||||
*/
|
||||
#ifdef XML_SCHEMA_READER_ENABLED
|
||||
ret = xmlSchemaVReaderWalk(vctxt);
|
||||
#endif
|
||||
#endif
|
||||
} else if ((vctxt->sax != NULL) && (vctxt->parserCtxt != NULL)) {
|
||||
/*
|
||||
* SAX validation.
|
||||
*/
|
||||
/* ret = xmlSAXUserParseFile(ctxt->sax, ctxt, uri); */
|
||||
ret = xmlParseDocument(vctxt->parserCtxt);
|
||||
} else {
|
||||
VERROR_INT("xmlSchemaVStartValidation",
|
||||
"no instance to validate");
|
||||
ret = -1;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
xmlSchemaPostRun(xmlSchemaValidCtxtPtr vctxt) {
|
||||
if (vctxt->xsiAssemble) {
|
||||
if (vctxt->schema != NULL) {
|
||||
xmlSchemaFree(vctxt->schema);
|
||||
@ -23932,6 +23926,42 @@ xmlSchemaVStart(xmlSchemaValidCtxtPtr vctxt)
|
||||
}
|
||||
}
|
||||
xmlSchemaClearValidCtxt(vctxt);
|
||||
}
|
||||
|
||||
static int
|
||||
xmlSchemaVStart(xmlSchemaValidCtxtPtr vctxt)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (xmlSchemaPreRun(vctxt) < 0)
|
||||
return(-1);
|
||||
|
||||
if (vctxt->doc != NULL) {
|
||||
/*
|
||||
* Tree validation.
|
||||
*/
|
||||
ret = xmlSchemaVDocWalk(vctxt);
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
} else if (vctxt->reader != NULL) {
|
||||
/*
|
||||
* XML Reader validation.
|
||||
*/
|
||||
#ifdef XML_SCHEMA_READER_ENABLED
|
||||
ret = xmlSchemaVReaderWalk(vctxt);
|
||||
#endif
|
||||
#endif
|
||||
} else if ((vctxt->sax != NULL) && (vctxt->parserCtxt != NULL)) {
|
||||
/*
|
||||
* SAX validation.
|
||||
*/
|
||||
ret = xmlParseDocument(vctxt->parserCtxt);
|
||||
} else {
|
||||
VERROR_INT("xmlSchemaVStartValidation",
|
||||
"no instance to validate");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
xmlSchemaPostRun(vctxt);
|
||||
if (ret == 0)
|
||||
ret = vctxt->err;
|
||||
return (ret);
|
||||
@ -24470,6 +24500,9 @@ xmlSchemaSAXPlug(xmlSchemaValidCtxtPtr ctxt,
|
||||
* plug the pointers back.
|
||||
*/
|
||||
*sax = &(ret->schemas_sax);
|
||||
ctxt->sax = *sax;
|
||||
ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM;
|
||||
xmlSchemaPreRun(ctxt);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -24492,6 +24525,7 @@ xmlSchemaSAXUnplug(xmlSchemaSAXPlugPtr plug)
|
||||
return(-1);
|
||||
plug->magic = 0;
|
||||
|
||||
xmlSchemaPostRun(plug->ctxt);
|
||||
/* restore the data */
|
||||
sax = plug->user_sax_ptr;
|
||||
*sax = plug->user_sax;
|
||||
@ -24629,29 +24663,6 @@ xmlSchemaValidateFile(xmlSchemaValidCtxtPtr ctxt,
|
||||
#endif /* XML_SCHEMA_SAX_ENABLED */
|
||||
}
|
||||
|
||||
#ifdef XML_SCHEMA_READER_ENABLED
|
||||
/**
|
||||
* xmlSchemaValidateReader:
|
||||
* @ctxt: a schema validation context
|
||||
* @reader: an XML reader.
|
||||
*
|
||||
* Do a schemas validation of the given resource, using the reader.
|
||||
*
|
||||
* Returns 0 if the document is valid, a positive error code
|
||||
* number otherwise and -1 in case of an internal or API error.
|
||||
*/
|
||||
int
|
||||
xmlSchemaValidateReader(xmlSchemaValidCtxtPtr ctxt,
|
||||
xmlTextReaderPtr reader)
|
||||
{
|
||||
if ((ctxt == NULL) || (reader == NULL))
|
||||
return (-1);
|
||||
ctxt->reader = reader;
|
||||
ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM;
|
||||
return(xmlSchemaVStart(ctxt, NULL));
|
||||
}
|
||||
#endif /* XML_SCHEMA_READER_ENABLED */
|
||||
|
||||
#define bottom_xmlschemas
|
||||
#include "elfgcchack.h"
|
||||
#endif /* LIBXML_SCHEMAS_ENABLED */
|
||||
|
Loading…
x
Reference in New Issue
Block a user