summaryrefslogtreecommitdiff
path: root/xmlschemas.c
diff options
context:
space:
mode:
authorAron Xu <aron@debian.org>2014-07-09 04:01:07 +0800
committerAron Xu <aron@debian.org>2014-07-09 04:01:07 +0800
commit7042e17490515a990a45aa7237d11bc49ab0eaf0 (patch)
tree62b661911406394bbeaca8951d660bb6d8aac0de /xmlschemas.c
parent2c8fe012ef1ff6e0613480dd182dec099aa9636e (diff)
downloadlibxml2-7042e17490515a990a45aa7237d11bc49ab0eaf0.tar.gz
Imported Upstream version 2.8.0+dfsg1
Diffstat (limited to 'xmlschemas.c')
-rw-r--r--xmlschemas.c275
1 files changed, 71 insertions, 204 deletions
diff --git a/xmlschemas.c b/xmlschemas.c
index 121533f..2fb2151 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -107,7 +107,7 @@
#endif
#define UNBOUNDED (1 << 30)
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -975,7 +975,6 @@ struct _xmlSchemaValidCtxt {
xmlSAXHandlerPtr sax;
xmlParserCtxtPtr parserCtxt;
void *user_data; /* TODO: What is this for? */
- char *filename;
int err;
int nberrors;
@@ -1029,10 +1028,6 @@ struct _xmlSchemaValidCtxt {
int hasKeyrefs;
int createIDCNodeTables;
int psviExposeIDCNodeTables;
-
- /* Locator for error reporting in streaming mode */
- xmlSchemaValidityLocatorFunc locFunc;
- void *locCtxt;
};
/**
@@ -1048,9 +1043,9 @@ struct _xmlSchemaSubstGroup {
};
/************************************************************************
- * *
- * Some predeclarations *
- * *
+ * *
+ * Some predeclarations *
+ * *
************************************************************************/
static int xmlSchemaParseInclude(xmlSchemaParserCtxtPtr ctxt,
@@ -1103,7 +1098,7 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt,
/************************************************************************
* *
- * Helper functions *
+ * Helper functions *
* *
************************************************************************/
@@ -1841,7 +1836,7 @@ xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt,
/************************************************************************
* *
- * Error functions *
+ * Error functions *
* *
************************************************************************/
@@ -1979,7 +1974,7 @@ xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
/************************************************************************
* *
- * Allround error functions *
+ * Allround error functions *
* *
************************************************************************/
@@ -2083,20 +2078,6 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
(vctxt->parserCtxt->input != NULL))
file = vctxt->parserCtxt->input->filename;
}
- if (vctxt->locFunc != NULL) {
- if ((file == NULL) || (line == 0)) {
- unsigned long l;
- const char *f;
- vctxt->locFunc(vctxt->locCtxt, &f, &l);
- if (file == NULL)
- file = f;
- if (line == 0)
- line = (int) l;
- }
- }
- if ((file == NULL) && (vctxt->filename != NULL))
- file = vctxt->filename;
-
__xmlRaiseError(schannel, channel, data, ctxt,
node, XML_FROM_SCHEMASV,
error, errorLevel, file, line,
@@ -3218,25 +3199,25 @@ xmlSchemaPContentErr(xmlSchemaParserCtxtPtr ctxt,
}
/************************************************************************
- * *
- * Streamable error functions *
- * *
+ * *
+ * Streamable error functions *
+ * *
************************************************************************/
/************************************************************************
- * *
- * Validation helper functions *
- * *
+ * *
+ * Validation helper functions *
+ * *
************************************************************************/
/************************************************************************
- * *
- * Allocation functions *
- * *
+ * *
+ * Allocation functions *
+ * *
************************************************************************/
/**
@@ -4154,9 +4135,9 @@ xmlSchemaFree(xmlSchemaPtr schema)
}
/************************************************************************
- * *
- * Debug functions *
- * *
+ * *
+ * Debug functions *
+ * *
************************************************************************/
#ifdef LIBXML_OUTPUT_ENABLED
@@ -4606,7 +4587,7 @@ xmlSchemaDebugDumpIDCTable(FILE * output,
/************************************************************************
* *
- * Utilities *
+ * Utilities *
* *
************************************************************************/
@@ -4711,9 +4692,9 @@ xmlSchemaGetProp(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
}
/************************************************************************
- * *
- * Parsing functions *
- * *
+ * *
+ * Parsing functions *
+ * *
************************************************************************/
#define WXS_FIND_GLOBAL_ITEM(slot) \
@@ -4985,9 +4966,9 @@ xmlSchemaGetNamedComponent(xmlSchemaPtr schema,
}
/************************************************************************
- * *
- * Parsing functions *
- * *
+ * *
+ * Parsing functions *
+ * *
************************************************************************/
#define IS_BLANK_NODE(n) \
@@ -5762,9 +5743,9 @@ xmlSchemaAddElementSubstitutionMember(xmlSchemaParserCtxtPtr pctxt,
}
/************************************************************************
- * *
+ * *
* Utilities for parsing *
- * *
+ * *
************************************************************************/
/**
@@ -5958,7 +5939,7 @@ xmlSchemaPValAttrNodeID(xmlSchemaParserCtxtPtr ctxt, xmlAttrPtr attr)
xmlFree((xmlChar *) value);
value = strip;
}
- res = xmlAddID(NULL, attr->doc, value, attr);
+ res = xmlAddID(NULL, attr->doc, value, attr);
if (res == NULL) {
ret = XML_SCHEMAP_S4S_ATTR_INVALID_VALUE;
xmlSchemaPSimpleTypeErr(ctxt,
@@ -6210,9 +6191,9 @@ xmlGetBooleanProp(xmlSchemaParserCtxtPtr ctxt,
}
/************************************************************************
- * *
+ * *
* Shema extraction from an Infoset *
- * *
+ * *
************************************************************************/
static xmlSchemaTypePtr xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr
ctxt, xmlSchemaPtr schema,
@@ -8246,7 +8227,7 @@ xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,
*/
attr = xmlSchemaGetPropNode(node, "xpath");
if (attr == NULL) {
- xmlSchemaPMissingAttrErr(ctxt,
+ xmlSchemaPMissingAttrErr(ctxt,
XML_SCHEMAP_S4S_ATTR_MISSING,
NULL, node,
"name", NULL);
@@ -12372,15 +12353,15 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
}
/************************************************************************
- * *
- * Validating using Schemas *
- * *
+ * *
+ * Validating using Schemas *
+ * *
************************************************************************/
/************************************************************************
- * *
- * Reading/Writing Schemas *
- * *
+ * *
+ * Reading/Writing Schemas *
+ * *
************************************************************************/
#if 0 /* Will be enabled if it is clear what options are needed. */
@@ -12957,15 +12938,6 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt,
if (tmp2 != 1) ret = 0;
sub = sub->next;
}
-
- /*
- * epsilon needed to block previous trans from
- * being allowed to enter back from another
- * construct
- */
- pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
- pctxt->state, NULL);
-
if (particle->minOccurs == 0) {
xmlAutomataNewEpsilon(pctxt->am, oldstate,
pctxt->state);
@@ -20181,7 +20153,7 @@ xmlSchemaResolveAttrUseReferences(xmlSchemaAttributeUsePtr ause,
ref->name, ref->targetNamespace);
if (ause->attrDecl == NULL) {
xmlSchemaPResCompAttrErr(ctxt,
- XML_SCHEMAP_SRC_RESOLVE,
+ XML_SCHEMAP_SRC_RESOLVE,
WXS_BASIC_CAST ause, ause->node,
"ref", ref->name, ref->targetNamespace,
XML_SCHEMA_TYPE_ATTRIBUTE, NULL);
@@ -21561,16 +21533,16 @@ xmlSchemaGetWhiteSpaceFacetValue(xmlSchemaTypePtr type)
}
/************************************************************************
- * *
- * Simple type validation *
- * *
+ * *
+ * Simple type validation *
+ * *
************************************************************************/
/************************************************************************
- * *
- * DOM Validation code *
- * *
+ * *
+ * DOM Validation code *
+ * *
************************************************************************/
/**
@@ -21964,9 +21936,9 @@ xmlSchemaVAddNodeQName(xmlSchemaValidCtxtPtr vctxt,
}
/************************************************************************
- * *
+ * *
* Validation of identity-constraints (IDC) *
- * *
+ * *
************************************************************************/
/**
@@ -23894,9 +23866,9 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
}
/************************************************************************
- * *
- * XML Reader validation code *
- * *
+ * *
+ * XML Reader validation code *
+ * *
************************************************************************/
static xmlSchemaAttrInfoPtr
@@ -25016,9 +24988,9 @@ xmlSchemaValidateElemDecl(xmlSchemaValidCtxtPtr vctxt)
return (vctxt->err);
}
if (actualType == NULL) {
- VERROR(XML_SCHEMAV_CVC_TYPE_1, NULL,
- "The type definition is absent");
- return (XML_SCHEMAV_CVC_TYPE_1);
+ VERROR(XML_SCHEMAV_CVC_TYPE_1, NULL,
+ "The type definition is absent");
+ return (XML_SCHEMAV_CVC_TYPE_1);
}
if (vctxt->nbAttrInfos != 0) {
int ret;
@@ -25108,9 +25080,9 @@ xmlSchemaValidateElemDecl(xmlSchemaValidCtxtPtr vctxt)
* No actual type definition.
*/
if (actualType == NULL) {
- VERROR(XML_SCHEMAV_CVC_TYPE_1, NULL,
- "The type definition is absent");
- return (XML_SCHEMAV_CVC_TYPE_1);
+ VERROR(XML_SCHEMAV_CVC_TYPE_1, NULL,
+ "The type definition is absent");
+ return (XML_SCHEMAV_CVC_TYPE_1);
}
/*
* Remember the actual type definition.
@@ -26063,20 +26035,6 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
"AUTOMATON create on '%s'\n", inode->localName);
#endif
}
-
- /*
- * Do not check further content if the node has been nilled
- */
- if (INODE_NILLED(inode)) {
- ret = 0;
-#ifdef DEBUG_AUTOMATA
- xmlGenericError(xmlGenericErrorContext,
- "AUTOMATON succeeded on nilled '%s'\n",
- inode->localName);
-#endif
- goto skip_nilled;
- }
-
/*
* Get hold of the still expected content, since a further
* call to xmlRegExecPushString() will loose this information.
@@ -26114,9 +26072,6 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
}
}
-
-skip_nilled:
-
if (inode->typeDef->contentType == XML_SCHEMA_CONTENT_ELEMENTS)
goto end_elem;
@@ -26955,15 +26910,15 @@ type_validation:
if (vctxt->inode->typeDef == NULL) {
vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE;
ret = XML_SCHEMAV_CVC_TYPE_1;
- VERROR(ret, NULL,
- "The type definition is absent");
+ VERROR(ret, NULL,
+ "The type definition is absent");
goto exit;
}
if (vctxt->inode->typeDef->flags & XML_SCHEMAS_TYPE_ABSTRACT) {
vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE;
ret = XML_SCHEMAV_CVC_TYPE_2;
- VERROR(ret, NULL,
- "The type definition is abstract");
+ VERROR(ret, NULL,
+ "The type definition is abstract");
goto exit;
}
/*
@@ -27210,9 +27165,9 @@ internal_error:
#endif
/************************************************************************
- * *
- * SAX validation handlers *
- * *
+ * *
+ * SAX validation handlers *
+ * *
************************************************************************/
/*
@@ -27463,9 +27418,9 @@ internal_error:
}
/************************************************************************
- * *
- * Validation interfaces *
- * *
+ * *
+ * Validation interfaces *
+ * *
************************************************************************/
/**
@@ -27495,28 +27450,8 @@ xmlSchemaNewValidCtxt(xmlSchemaPtr schema)
}
/**
- * xmlSchemaValidateSetFilename:
- * @vctxt: the schema validation context
- * @filename: the file name
- *
- * Workaround to provide file error reporting information when this is
- * not provided by current APIs
- */
-void
-xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt, const char *filename) {
- if (vctxt == NULL)
- return;
- if (vctxt->filename != NULL)
- xmlFree(vctxt->filename);
- if (filename != NULL)
- vctxt->filename = (char *) xmlStrdup((const xmlChar *) filename);
- else
- vctxt->filename = NULL;
-}
-
-/**
* xmlSchemaClearValidCtxt:
- * @vctxt: the schema validation context
+ * @ctxt: the schema validation context
*
* Free the resources associated to the schema validation context;
* leaves some fields alive intended for reuse of the context.
@@ -27617,11 +27552,6 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
* where the user provides the dict?
*/
vctxt->dict = xmlDictCreate();
-
- if (vctxt->filename != NULL) {
- xmlFree(vctxt->filename);
- vctxt->filename = NULL;
- }
}
/**
@@ -27707,8 +27637,6 @@ xmlSchemaFreeValidCtxt(xmlSchemaValidCtxtPtr ctxt)
xmlSchemaItemListFree(ctxt->nodeQNames);
if (ctxt->dict != NULL)
xmlDictFree(ctxt->dict);
- if (ctxt->filename != NULL)
- xmlFree(ctxt->filename);
xmlFree(ctxt);
}
@@ -27863,10 +27791,7 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt)
const xmlChar *nsName;
/* DOC VAL TODO: Move this to the start function. */
- if (vctxt->validationRoot != NULL)
- valRoot = vctxt->validationRoot;
- else
- valRoot = xmlDocGetRootElement(vctxt->doc);
+ valRoot = xmlDocGetRootElement(vctxt->doc);
if (valRoot == NULL) {
/* VAL TODO: Error code? */
VERROR(1, NULL, "The document has no document element");
@@ -28187,9 +28112,9 @@ xmlSchemaValidateDoc(xmlSchemaValidCtxtPtr ctxt, xmlDocPtr doc)
/************************************************************************
- * *
- * Function and data for SAX streaming API *
- * *
+ * *
+ * Function and data for SAX streaming API *
+ * *
************************************************************************/
typedef struct _xmlSchemaSplitSAXData xmlSchemaSplitSAXData;
typedef xmlSchemaSplitSAXData *xmlSchemaSplitSAXDataPtr;
@@ -28706,63 +28631,6 @@ xmlSchemaSAXUnplug(xmlSchemaSAXPlugPtr plug)
}
/**
- * xmlSchemaValidateSetLocator:
- * @vctxt: a schema validation context
- * @f: the locator function pointer
- * @ctxt: the locator context
- *
- * Allows to set a locator function to the validation context,
- * which will be used to provide file and line information since
- * those are not provided as part of the SAX validation flow
- * Setting @f to NULL disable the locator.
- */
-
-void
-xmlSchemaValidateSetLocator(xmlSchemaValidCtxtPtr vctxt,
- xmlSchemaValidityLocatorFunc f,
- void *ctxt)
-{
- if (vctxt == NULL) return;
- vctxt->locFunc = f;
- vctxt->locCtxt = ctxt;
-}
-
-/**
- * xmlSchemaValidateStreamLocator:
- * @ctx: the xmlTextReaderPtr used
- * @file: returned file information
- * @line: returned line information
- *
- * Internal locator function for the readers
- *
- * Returns 0 in case the Schema validation could be (des)activated and
- * -1 in case of error.
- */
-static int
-xmlSchemaValidateStreamLocator(void *ctx, const char **file,
- unsigned long *line) {
- xmlParserCtxtPtr ctxt;
-
- if ((ctx == NULL) || ((file == NULL) && (line == NULL)))
- return(-1);
-
- if (file != NULL)
- *file = NULL;
- if (line != NULL)
- *line = 0;
-
- ctxt = (xmlParserCtxtPtr) ctx;
- if (ctxt->input != NULL) {
- if (file != NULL)
- *file = ctxt->input->filename;
- if (line != NULL)
- *line = ctxt->input->line;
- return(0);
- }
- return(-1);
-}
-
-/**
* xmlSchemaValidateStream:
* @ctxt: a schema validation context
* @input: the input to use for reading the data
@@ -28805,7 +28673,6 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
xmlCtxtUseOptions(pctxt, options);
#endif
pctxt->linenumbers = 1;
- xmlSchemaValidateSetLocator(ctxt, xmlSchemaValidateStreamLocator, pctxt);
inputStream = xmlNewIOInputStream(pctxt, input, enc);;
if (inputStream == NULL) {