aboutsummaryrefslogtreecommitdiffstats
path: root/xmlschemas.c
diff options
context:
space:
mode:
Diffstat (limited to 'xmlschemas.c')
-rw-r--r--xmlschemas.c154
1 files changed, 102 insertions, 52 deletions
diff --git a/xmlschemas.c b/xmlschemas.c
index 7afe2ebf..405f72ae 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -44,6 +44,12 @@
* but is done here due to performance. Move it to an other layer
* is schema construction via an API is implemented.
*/
+
+/* To avoid EBCDIC trouble when parsing on zOS */
+#if defined(__MVS__)
+#pragma convert("ISO8859-1")
+#endif
+
#define IN_LIBXML
#include "libxml.h"
@@ -166,7 +172,7 @@ static const xmlChar *xmlNamespaceNs = (const xmlChar *)
/*
* Macros for attribute uses.
*/
-#define WXS_ATTRUSE_DECL(au) WXS_ATTR_CAST (WXS_ATTR_USE_CAST (au))->attrDecl
+#define WXS_ATTRUSE_DECL(au) (WXS_ATTR_USE_CAST (au))->attrDecl
#define WXS_ATTRUSE_TYPEDEF(au) WXS_ATTR_TYPEDEF(WXS_ATTRUSE_DECL( WXS_ATTR_USE_CAST au))
@@ -363,6 +369,7 @@ typedef struct _xmlSchemaAbstractCtxt xmlSchemaAbstractCtxt;
typedef xmlSchemaAbstractCtxt *xmlSchemaAbstractCtxtPtr;
struct _xmlSchemaAbstractCtxt {
int type; /* E.g. XML_SCHEMA_CTXT_VALIDATOR */
+ void *dummy; /* Fix alignment issues */
};
typedef struct _xmlSchemaBucket xmlSchemaBucket;
@@ -473,6 +480,7 @@ typedef struct _xmlSchemaBasicItem xmlSchemaBasicItem;
typedef xmlSchemaBasicItem *xmlSchemaBasicItemPtr;
struct _xmlSchemaBasicItem {
xmlSchemaTypeType type;
+ void *dummy; /* Fix alignment issues */
};
/**
@@ -1734,6 +1742,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
*buf = xmlStrcat(*buf, BAD_CAST "'");
FREE_AND_NULL(str);
}
+ /* Falls through. */
default:
named = 0;
}
@@ -2833,7 +2842,7 @@ xmlSchemaPResCompAttrErr(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaFormatItemForReport(&des, NULL, ownerItem, ownerElem);
if (refTypeStr == NULL)
refTypeStr = (const char *) xmlSchemaItemTypeToStr(refType);
- xmlSchemaPErrExt(ctxt, ownerElem, error,
+ xmlSchemaPErrExt(ctxt, ownerElem, error,
NULL, NULL, NULL,
"%s, attribute '%s': The QName value '%s' does not resolve to a(n) "
"%s.\n", BAD_CAST des, BAD_CAST name,
@@ -3556,6 +3565,12 @@ xmlSchemaBucketFree(xmlSchemaBucketPtr bucket)
xmlFree(bucket);
}
+static void
+xmlSchemaBucketFreeEntry(void *bucket, const xmlChar *name ATTRIBUTE_UNUSED)
+{
+ xmlSchemaBucketFree((xmlSchemaBucketPtr) bucket);
+}
+
static xmlSchemaBucketPtr
xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
int type, const xmlChar *targetNamespace)
@@ -4150,8 +4165,7 @@ xmlSchemaFree(xmlSchemaPtr schema)
xmlHashFree(schema->idcDef, NULL);
if (schema->schemasImports != NULL)
- xmlHashFree(schema->schemasImports,
- (xmlHashDeallocator) xmlSchemaBucketFree);
+ xmlHashFree(schema->schemasImports, xmlSchemaBucketFreeEntry);
if (schema->includes != NULL) {
xmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes;
int i;
@@ -4187,11 +4201,13 @@ xmlSchemaTypeDump(xmlSchemaTypePtr type, FILE * output); /* forward */
* Dump the element
*/
static void
-xmlSchemaElementDump(xmlSchemaElementPtr elem, FILE * output,
+xmlSchemaElementDump(void *payload, void *data,
const xmlChar * name ATTRIBUTE_UNUSED,
const xmlChar * namespace ATTRIBUTE_UNUSED,
const xmlChar * context ATTRIBUTE_UNUSED)
{
+ xmlSchemaElementPtr elem = (xmlSchemaElementPtr) payload;
+ FILE *output = (FILE *) data;
if (elem == NULL)
return;
@@ -4506,6 +4522,13 @@ xmlSchemaTypeDump(xmlSchemaTypePtr type, FILE * output)
#endif
}
+static void
+xmlSchemaTypeDumpEntry(void *type, void *output,
+ const xmlChar *name ATTRIBUTE_UNUSED)
+{
+ xmlSchemaTypeDump((xmlSchemaTypePtr) type, (FILE *) output);
+}
+
/**
* xmlSchemaDump:
* @output: the file output
@@ -4534,10 +4557,8 @@ xmlSchemaDump(FILE * output, xmlSchemaPtr schema)
fprintf(output, "\n");
if (schema->annot != NULL)
xmlSchemaAnnotDump(output, schema->annot);
- xmlHashScan(schema->typeDecl, (xmlHashScanner) xmlSchemaTypeDump,
- output);
- xmlHashScanFull(schema->elemDecl,
- (xmlHashScannerFull) xmlSchemaElementDump, output);
+ xmlHashScan(schema->typeDecl, xmlSchemaTypeDumpEntry, output);
+ xmlHashScanFull(schema->elemDecl, xmlSchemaElementDump, output);
}
#ifdef DEBUG_IDC_NODE_TABLE
@@ -5697,6 +5718,12 @@ xmlSchemaSubstGroupFree(xmlSchemaSubstGroupPtr group)
xmlFree(group);
}
+static void
+xmlSchemaSubstGroupFreeEntry(void *group, const xmlChar *name ATTRIBUTE_UNUSED)
+{
+ xmlSchemaSubstGroupFree((xmlSchemaSubstGroupPtr) group);
+}
+
static xmlSchemaSubstGroupPtr
xmlSchemaSubstGroupAdd(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaElementPtr head)
@@ -7364,8 +7391,8 @@ attr_next:
*/
if (defValue != NULL)
use->defValue = defValue;
- if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
- use->flags |= XML_SCHEMA_ATTR_USE_FIXED;
+ if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
+ use->flags |= XML_SCHEMA_ATTR_USE_FIXED;
}
check_children:
@@ -9909,8 +9936,7 @@ xmlSchemaConstructionCtxtFree(xmlSchemaConstructionCtxtPtr con)
if (con->pending != NULL)
xmlSchemaItemListFree(con->pending);
if (con->substGroups != NULL)
- xmlHashFree(con->substGroups,
- (xmlHashDeallocator) xmlSchemaSubstGroupFree);
+ xmlHashFree(con->substGroups, xmlSchemaSubstGroupFreeEntry);
if (con->redefs != NULL)
xmlSchemaRedefListFree(con->redefs);
if (con->dict != NULL)
@@ -15890,7 +15916,7 @@ xmlSchemaParseCheckCOSValidDefault(xmlSchemaParserCtxtPtr pctxt,
* STATUS: (seems) complete
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
@@ -16137,7 +16163,7 @@ xmlSchemaCheckCOSDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
* (1.4.3.2.2.2) "Particle Valid (Extension)"
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
@@ -16394,7 +16420,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
* Validation Rule: Checking complex type subsumption
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
@@ -16584,7 +16610,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
* (3.4.6) Constraints on Complex Type Definition Schema Components
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckCTComponent(xmlSchemaParserCtxtPtr ctxt,
@@ -16614,7 +16640,7 @@ xmlSchemaCheckCTComponent(xmlSchemaParserCtxtPtr ctxt,
* Complex Type Definition Representation OK (src-ct)
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
@@ -16783,7 +16809,7 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
* STATUS: complete
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckParticleRangeOK(int rmin, int rmax,
@@ -16813,7 +16839,7 @@ xmlSchemaCheckParticleRangeOK(int rmin, int rmax,
* CLARIFY: (3.2.2)
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckRCaseNameAndTypeOK(xmlSchemaParserCtxtPtr ctxt,
@@ -16918,7 +16944,7 @@ xmlSchemaCheckRCaseNameAndTypeOK(xmlSchemaParserCtxtPtr ctxt,
* STATUS: complete
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckRCaseNSCompat(xmlSchemaParserCtxtPtr ctxt,
@@ -16962,7 +16988,7 @@ xmlSchemaCheckRCaseNSCompat(xmlSchemaParserCtxtPtr ctxt,
* STATUS: TODO
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckRCaseRecurseAsIfGroup(xmlSchemaParserCtxtPtr ctxt,
@@ -16988,7 +17014,7 @@ xmlSchemaCheckRCaseRecurseAsIfGroup(xmlSchemaParserCtxtPtr ctxt,
* STATUS: complete
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckRCaseNSSubset(xmlSchemaParserCtxtPtr ctxt,
@@ -17038,7 +17064,7 @@ xmlSchemaCheckRCaseNSSubset(xmlSchemaParserCtxtPtr ctxt,
* STATUS: TODO
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckCOSParticleRestrict(xmlSchemaParserCtxtPtr ctxt,
@@ -17079,7 +17105,7 @@ xmlSchemaCheckCOSParticleRestrict(xmlSchemaParserCtxtPtr ctxt,
* STATUS: TODO: subst-groups
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt,
@@ -17134,7 +17160,7 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt,
* TODO: subst-groups
*
* Returns 0 if the constraints are satisfied, a positive
- * error code if not and -1 if an internal error occured.
+ * error code if not and -1 if an internal error occurred.
*/
static int
xmlSchemaCheckRCaseRecurse(xmlSchemaParserCtxtPtr ctxt,
@@ -17764,7 +17790,7 @@ xmlSchemaDeriveAndValidateFacets(xmlSchemaParserCtxtPtr pctxt,
return (0);
internal_error:
PERROR_INT("xmlSchemaDeriveAndValidateFacets",
- "an error occured");
+ "an error occurred");
return (-1);
}
@@ -21284,8 +21310,7 @@ exit:
con->bucket = oldbucket;
con->pending->nbItems = 0;
if (con->substGroups != NULL) {
- xmlHashFree(con->substGroups,
- (xmlHashDeallocator) xmlSchemaSubstGroupFree);
+ xmlHashFree(con->substGroups, xmlSchemaSubstGroupFreeEntry);
con->substGroups = NULL;
}
if (con->redefs != NULL) {
@@ -21413,7 +21438,7 @@ exit_failure:
ctxt->ownsConstructor = 0;
}
PERROR_INT2("xmlSchemaParse",
- "An internal error occured");
+ "An internal error occurred");
ctxt->schema = NULL;
return(NULL);
}
@@ -21993,9 +22018,11 @@ xmlSchemaVAddNodeQName(xmlSchemaValidCtxtPtr vctxt,
* Returns the item, or NULL on internal errors.
*/
static void
-xmlSchemaAugmentIDC(xmlSchemaIDCPtr idcDef,
- xmlSchemaValidCtxtPtr vctxt)
+xmlSchemaAugmentIDC(void *payload, void *data,
+ const xmlChar *name ATTRIBUTE_UNUSED)
{
+ xmlSchemaIDCPtr idcDef = (xmlSchemaIDCPtr) payload;
+ xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) data;
xmlSchemaIDCAugPtr aidc;
aidc = (xmlSchemaIDCAugPtr) xmlMalloc(sizeof(xmlSchemaIDCAug));
@@ -22029,10 +22056,12 @@ xmlSchemaAugmentIDC(xmlSchemaIDCPtr idcDef,
* Creates an augmented IDC definition for the imported schema.
*/
static void
-xmlSchemaAugmentImportedIDC(xmlSchemaImportPtr imported, xmlSchemaValidCtxtPtr vctxt) {
+xmlSchemaAugmentImportedIDC(void *payload, void *data,
+ const xmlChar *name ATTRIBUTE_UNUSED) {
+ xmlSchemaImportPtr imported = (xmlSchemaImportPtr) payload;
+ xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) data;
if (imported->schema->idcDef != NULL) {
- xmlHashScan(imported->schema->idcDef ,
- (xmlHashScanner) xmlSchemaAugmentIDC, vctxt);
+ xmlHashScan(imported->schema->idcDef, xmlSchemaAugmentIDC, vctxt);
}
}
@@ -25957,11 +25986,12 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
}
static void
-xmlSchemaVContentModelCallback(xmlSchemaValidCtxtPtr vctxt ATTRIBUTE_UNUSED,
+xmlSchemaVContentModelCallback(xmlRegExecCtxtPtr exec ATTRIBUTE_UNUSED,
const xmlChar * name ATTRIBUTE_UNUSED,
- xmlSchemaElementPtr item,
- xmlSchemaNodeInfoPtr inode)
+ void *transdata, void *inputdata)
{
+ xmlSchemaElementPtr item = (xmlSchemaElementPtr) transdata;
+ xmlSchemaNodeInfoPtr inode = (xmlSchemaNodeInfoPtr) inputdata;
inode->decl = item;
#ifdef DEBUG_CONTENT
{
@@ -26066,8 +26096,7 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
*/
inode->regexCtxt =
xmlRegNewExecCtxt(inode->typeDef->contModel,
- (xmlRegExecCallbacks) xmlSchemaVContentModelCallback,
- vctxt);
+ xmlSchemaVContentModelCallback, vctxt);
if (inode->regexCtxt == NULL) {
VERROR_INT("xmlSchemaValidatorPopElem",
"failed to create a regex context");
@@ -26094,7 +26123,7 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
/*
* Get hold of the still expected content, since a further
- * call to xmlRegExecPushString() will loose this information.
+ * call to xmlRegExecPushString() will lose this information.
*/
xmlRegExecNextValues(inode->regexCtxt,
&nbval, &nbneg, &values[0], &terminal);
@@ -26615,8 +26644,7 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
* Create the regex context.
*/
regexCtxt = xmlRegNewExecCtxt(ptype->contModel,
- (xmlRegExecCallbacks) xmlSchemaVContentModelCallback,
- vctxt);
+ xmlSchemaVContentModelCallback, vctxt);
if (regexCtxt == NULL) {
VERROR_INT("xmlSchemaValidateChildElem",
"failed to create a regex context");
@@ -26876,7 +26904,8 @@ xmlSchemaValidateElem(xmlSchemaValidCtxtPtr vctxt)
* Augment the IDC definitions for the main schema and all imported ones
* NOTE: main schema is the first in the imported list
*/
- xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentImportedIDC, vctxt);
+ xmlHashScan(vctxt->schema->schemasImports, xmlSchemaAugmentImportedIDC,
+ vctxt);
}
if (vctxt->depth > 0) {
/*
@@ -27150,7 +27179,7 @@ root_found:
}
if (ret < 0) {
/*
- * VAL TODO: A reader error occured; what to do here?
+ * VAL TODO: A reader error occurred; what to do here?
*/
ret = 1;
goto exit;
@@ -27391,6 +27420,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
* attributes yet.
*/
if (nb_attributes != 0) {
+ int valueLen, k, l;
xmlChar *value;
for (j = 0, i = 0; i < nb_attributes; i++, j += 5) {
@@ -27400,12 +27430,31 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
* libxml2 differs from normal SAX here in that it escapes all ampersands
* as &#38; instead of delivering the raw converted string. Changing the
* behavior at this point would break applications that use this API, so
- * we are forced to work around it. There is no danger of accidentally
- * decoding some entity other than &#38; in this step because without
- * unescaped ampersands there can be no other entities in the string.
+ * we are forced to work around it.
*/
- value = xmlStringLenDecodeEntities(vctxt->parserCtxt, attributes[j+3],
- attributes[j+4] - attributes[j+3], XML_SUBSTITUTE_REF, 0, 0, 0);
+ valueLen = attributes[j+4] - attributes[j+3];
+ value = xmlMallocAtomic(valueLen + 1);
+ if (value == NULL) {
+ xmlSchemaVErrMemory(vctxt,
+ "allocating string for decoded attribute",
+ NULL);
+ goto internal_error;
+ }
+ for (k = 0, l = 0; k < valueLen; l++) {
+ if (k < valueLen - 4 &&
+ attributes[j+3][k+0] == '&' &&
+ attributes[j+3][k+1] == '#' &&
+ attributes[j+3][k+2] == '3' &&
+ attributes[j+3][k+3] == '8' &&
+ attributes[j+3][k+4] == ';') {
+ value[l] = '&';
+ k += 5;
+ } else {
+ value[l] = attributes[j+3][k];
+ k++;
+ }
+ }
+ value[l] = '\0';
/*
* TODO: Set the node line.
*/
@@ -27788,7 +27837,7 @@ xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
{
if (ctxt == NULL)
return;
- ctxt->serror = serror;
+ ctxt->serror = serror;
ctxt->error = NULL;
ctxt->warning = NULL;
ctxt->errCtxt = ctx;
@@ -28098,7 +28147,8 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
* Augment the IDC definitions for the main schema and all imported ones
* NOTE: main schema if the first in the imported list
*/
- xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentImportedIDC, vctxt);
+ xmlHashScan(vctxt->schema->schemasImports, xmlSchemaAugmentImportedIDC,
+ vctxt);
return(0);
}