mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-23 01:52:48 +03:00
Changed xmlSchemaValidateFile() to use xmlSchemaValidateStream()
* xmlschemas.c: Changed xmlSchemaValidateFile() to use xmlSchemaValidateStream() internally.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
Fri Jul 8 18:34:22 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
||||||
|
|
||||||
|
* xmlschemas.c: Changed xmlSchemaValidateFile() to use
|
||||||
|
xmlSchemaValidateStream() internally.
|
||||||
|
|
||||||
Fri Jul 8 17:02:14 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
Fri Jul 8 17:02:14 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* test/relaxng/docbook_0.xml: added the missing entity to the
|
* test/relaxng/docbook_0.xml: added the missing entity to the
|
||||||
|
70
xmlschemas.c
70
xmlschemas.c
@@ -33,13 +33,14 @@
|
|||||||
#include <libxml/parserInternals.h>
|
#include <libxml/parserInternals.h>
|
||||||
#include <libxml/hash.h>
|
#include <libxml/hash.h>
|
||||||
#include <libxml/uri.h>
|
#include <libxml/uri.h>
|
||||||
|
|
||||||
#include <libxml/xmlschemas.h>
|
#include <libxml/xmlschemas.h>
|
||||||
#include <libxml/schemasInternals.h>
|
#include <libxml/schemasInternals.h>
|
||||||
#include <libxml/xmlschemastypes.h>
|
#include <libxml/xmlschemastypes.h>
|
||||||
#include <libxml/xmlautomata.h>
|
#include <libxml/xmlautomata.h>
|
||||||
#include <libxml/xmlregexp.h>
|
#include <libxml/xmlregexp.h>
|
||||||
#include <libxml/dict.h>
|
#include <libxml/dict.h>
|
||||||
|
#include <libxml/encoding.h>
|
||||||
|
#include <libxml/xmlIO.h>
|
||||||
#ifdef LIBXML_PATTERN_ENABLED
|
#ifdef LIBXML_PATTERN_ENABLED
|
||||||
#include <libxml/pattern.h>
|
#include <libxml/pattern.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -24406,6 +24407,7 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
|
|||||||
xmlCtxtUseOptions(pctxt, options);
|
xmlCtxtUseOptions(pctxt, options);
|
||||||
#endif
|
#endif
|
||||||
pctxt->linenumbers = 1;
|
pctxt->linenumbers = 1;
|
||||||
|
pctxt->userData = (void *) ctxt;
|
||||||
|
|
||||||
inputStream = xmlNewIOInputStream(pctxt, input, XML_CHAR_ENCODING_NONE);;
|
inputStream = xmlNewIOInputStream(pctxt, input, XML_CHAR_ENCODING_NONE);;
|
||||||
if (inputStream == NULL) {
|
if (inputStream == NULL) {
|
||||||
@@ -24458,71 +24460,17 @@ xmlSchemaValidateFile(xmlSchemaValidCtxtPtr ctxt,
|
|||||||
{
|
{
|
||||||
#ifdef XML_SCHEMA_SAX_ENABLED
|
#ifdef XML_SCHEMA_SAX_ENABLED
|
||||||
int ret;
|
int ret;
|
||||||
|
xmlParserInputBufferPtr input;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (filename == NULL))
|
if ((ctxt == NULL) || (filename == NULL))
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
|
input = xmlParserInputBufferCreateFilename(filename,
|
||||||
if (ctxt->sax == NULL) {
|
XML_CHAR_ENCODING_NONE);
|
||||||
xmlSchemaVErrMemory(ctxt,
|
if (input == NULL)
|
||||||
"creating SAX handler", NULL);
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
ret = xmlSchemaValidateStream(ctxt, input, XML_CHAR_ENCODING_NONE,
|
||||||
memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
|
NULL, NULL);
|
||||||
ctxt->parserCtxt = xmlCreateFileParserCtxt(filename);
|
|
||||||
if (ctxt->parserCtxt == NULL) {
|
|
||||||
xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) ctxt,
|
|
||||||
"xmlSchemaValidateFile", "creating a parser context");
|
|
||||||
xmlFree(ctxt->sax);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
#ifdef LIBXML_SAX1_ENABLED
|
|
||||||
if (ctxt->parserCtxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
|
|
||||||
#endif /* LIBXML_SAX1_ENABLED */
|
|
||||||
xmlFree(ctxt->parserCtxt->sax);
|
|
||||||
/*
|
|
||||||
* Init the SAX handler.
|
|
||||||
*/
|
|
||||||
ctxt->sax->startElementNs = xmlSchemaSAXHandleStartElementNs;
|
|
||||||
ctxt->sax->endElementNs = xmlSchemaSAXHandleEndElementNs;
|
|
||||||
/*
|
|
||||||
* Note that we use the same text-function for both, to prevent
|
|
||||||
* the parser from testing for ignorable whitespace.
|
|
||||||
*/
|
|
||||||
ctxt->sax->ignorableWhitespace = xmlSchemaSAXHandleText;
|
|
||||||
ctxt->sax->characters = xmlSchemaSAXHandleText;
|
|
||||||
|
|
||||||
ctxt->sax->cdataBlock = xmlSchemaSAXHandleCDataSection;
|
|
||||||
ctxt->sax->reference = xmlSchemaSAXHandleReference;
|
|
||||||
ctxt->sax->initialized = XML_SAX2_MAGIC;
|
|
||||||
/*
|
|
||||||
* Init the parser context.
|
|
||||||
*/
|
|
||||||
ctxt->parserCtxt->sax = ctxt->sax;
|
|
||||||
ctxt->parserCtxt->sax2 = 1;
|
|
||||||
ctxt->parserCtxt->userData = ctxt;
|
|
||||||
/* VAL TODO: Set error handlers. */
|
|
||||||
|
|
||||||
ctxt->flags |= XML_SCHEMA_VALID_CTXT_FLAG_STREAM;
|
|
||||||
ret = xmlSchemaVStart(ctxt);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* URGENT VAL TODO: What to do with well-formedness errors?
|
|
||||||
*/
|
|
||||||
if ((ret == 0) && (! ctxt->parserCtxt->wellFormed)) {
|
|
||||||
ret = ctxt->parserCtxt->errNo;
|
|
||||||
if (ret == 0)
|
|
||||||
/* URGENT VAL TODO: Error code? */
|
|
||||||
ret = 1;
|
|
||||||
xmlSchemaErr((xmlSchemaAbstractCtxtPtr) ctxt, ret, NULL,
|
|
||||||
"The instance document '%s' is not well-formed",
|
|
||||||
BAD_CAST filename, NULL);
|
|
||||||
}
|
|
||||||
ctxt->parserCtxt->sax = NULL;
|
|
||||||
xmlFreeParserCtxt(ctxt->parserCtxt);
|
|
||||||
xmlFree(ctxt->sax);
|
|
||||||
ctxt->sax = NULL;
|
|
||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
#else
|
#else
|
||||||
return (-1);
|
return (-1);
|
||||||
|
Reference in New Issue
Block a user