diff options
Diffstat (limited to 'gnulib-local/lib/libxml/xmlschemas.c')
-rw-r--r-- | gnulib-local/lib/libxml/xmlschemas.c | 3147 |
1 files changed, 1700 insertions, 1447 deletions
diff --git a/gnulib-local/lib/libxml/xmlschemas.c b/gnulib-local/lib/libxml/xmlschemas.c index 11e3eac..fe533e6 100644 --- a/gnulib-local/lib/libxml/xmlschemas.c +++ b/gnulib-local/lib/libxml/xmlschemas.c @@ -90,7 +90,7 @@ #ifndef DEBUG_IDC_NODE_TABLE #define DEBUG_IDC_NODE_TABLE #endif -#endif +#endif /* #define ENABLE_PARTICLE_RESTRICTION 1 */ @@ -107,7 +107,7 @@ #endif #define UNBOUNDED (1 << 30) -#define TODO \ +#define TODO \ xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); @@ -374,7 +374,7 @@ typedef xmlSchemaBucket *xmlSchemaBucketPtr; #define XML_SCHEMA_SCHEMA_REDEFINE 3 /** - * xmlSchemaSchemaRelation: + * xmlSchemaSchemaRelation: * * Used to create a graph of schema relationships. */ @@ -402,12 +402,12 @@ struct _xmlSchemaBucket { int parsed; int imported; int preserveDoc; - xmlSchemaItemListPtr globals; /* Global components. */ + xmlSchemaItemListPtr globals; /* Global components. */ xmlSchemaItemListPtr locals; /* Local components. */ }; /** - * xmlSchemaImport: + * xmlSchemaImport: * (extends xmlSchemaBucket) * * Reflects a schema. Holds some information @@ -422,9 +422,9 @@ struct _xmlSchemaImport { const xmlChar *schemaLocation; /* The URI of the schema document. */ /* For chameleon includes, @origTargetNamespace will be NULL */ const xmlChar *origTargetNamespace; - /* + /* * For chameleon includes, @targetNamespace will be the - * targetNamespace of the including schema. + * targetNamespace of the including schema. */ const xmlChar *targetNamespace; xmlDocPtr doc; /* The schema node-tree. */ @@ -457,7 +457,7 @@ struct _xmlSchemaInclude { int parsed; int imported; int preserveDoc; - xmlSchemaItemListPtr globals; /* Global components. */ + xmlSchemaItemListPtr globals; /* Global components. */ xmlSchemaItemListPtr locals; /* Local components. */ /* The owning main or import schema bucket. */ @@ -517,7 +517,7 @@ struct _xmlSchemaAttributeUse { xmlSchemaTypeType type; xmlSchemaAnnotPtr annot; xmlSchemaAttributeUsePtr next; /* The next attr. use. */ - /* + /* * The attr. decl. OR a QName-ref. to an attr. decl. OR * a QName-ref. to an attribute group definition. */ @@ -573,7 +573,7 @@ struct _xmlSchemaConstructionCtxt { xmlDictPtr dict; xmlSchemaItemListPtr buckets; /* List of schema buckets. */ /* xmlSchemaItemListPtr relations; */ /* List of schema relations. */ - xmlSchemaBucketPtr bucket; /* The current schema bucket */ + xmlSchemaBucketPtr bucket; /* The current schema bucket */ xmlSchemaItemListPtr pending; /* All Components of all schemas that need to be fixed. */ xmlHashTablePtr substGroups; @@ -629,7 +629,7 @@ struct _xmlSchemaParserCtxt { xmlSchemaBucketPtr redefined; /* The schema to be redefined. */ xmlSchemaRedefPtr redef; /* Used for redefinitions. */ - int redefCounter; /* Used for redefinitions. */ + int redefCounter; /* Used for redefinitions. */ xmlSchemaItemListPtr attrProhibs; }; @@ -783,7 +783,7 @@ struct _xmlSchemaPSVIIDCNode { xmlNodePtr node; xmlSchemaPSVIIDCKeyPtr *keys; int nodeLine; - int nodeQNameID; + int nodeQNameID; }; @@ -879,7 +879,7 @@ struct _xmlSchemaIDCMatcher { struct _xmlSchemaNodeInfo { int nodeType; xmlNodePtr node; - int nodeLine; + int nodeLine; const xmlChar *localName; const xmlChar *nsName; const xmlChar *value; @@ -901,7 +901,7 @@ struct _xmlSchemaNodeInfo { const xmlChar **nsBindings; /* Namespace bindings on this element */ int nbNsBindings; - int sizeNsBindings; + int sizeNsBindings; int hasKeyrefs; int appliedXPath; /* Indicates that an XPath has been applied. */ @@ -938,7 +938,7 @@ typedef xmlSchemaAttrInfo *xmlSchemaAttrInfoPtr; struct _xmlSchemaAttrInfo { int nodeType; xmlNodePtr node; - int nodeLine; + int nodeLine; const xmlChar *localName; const xmlChar *nsName; const xmlChar *value; @@ -975,6 +975,7 @@ struct _xmlSchemaValidCtxt { xmlSAXHandlerPtr sax; xmlParserCtxtPtr parserCtxt; void *user_data; /* TODO: What is this for? */ + char *filename; int err; int nberrors; @@ -1028,6 +1029,10 @@ struct _xmlSchemaValidCtxt { int hasKeyrefs; int createIDCNodeTables; int psviExposeIDCNodeTables; + + /* Locator for error reporting in streaming mode */ + xmlSchemaValidityLocatorFunc locFunc; + void *locCtxt; }; /** @@ -1043,9 +1048,9 @@ struct _xmlSchemaSubstGroup { }; /************************************************************************ - * * - * Some predeclarations * - * * + * * + * Some predeclarations * + * * ************************************************************************/ static int xmlSchemaParseInclude(xmlSchemaParserCtxtPtr ctxt, @@ -1098,7 +1103,7 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt, /************************************************************************ * * - * Helper functions * + * Helper functions * * * ************************************************************************/ @@ -1172,7 +1177,7 @@ xmlSchemaGetComponentTypeStr(xmlSchemaBasicItemPtr item) if (WXS_IS_COMPLEX(WXS_TYPE_CAST item)) return(BAD_CAST "complex type definition"); else - return(BAD_CAST "simple type definition"); + return(BAD_CAST "simple type definition"); default: return(xmlSchemaItemTypeToStr(item->type)); } @@ -1300,11 +1305,11 @@ xmlSchemaFormatQName(xmlChar **buf, *buf = xmlStrcat(*buf, localName); } else { *buf = xmlStrcat(*buf, BAD_CAST "(NULL)"); - } + } return ((const xmlChar *) *buf); } -static const xmlChar* +static const xmlChar* xmlSchemaFormatQNameNs(xmlChar **buf, xmlNsPtr ns, const xmlChar *localName) { if (ns != NULL) @@ -1466,7 +1471,7 @@ xmlSchemaWildcardPCToString(int pc) * @retValue: the returned value * @ws: the whitespace type of the value * - * Get a the cononical representation of the value. + * Get a the canonical representation of the value. * The caller has to free the returned retValue. * * Returns 0 if the value could be built and -1 in case of @@ -1480,16 +1485,16 @@ xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val, int list; xmlSchemaValType valType; const xmlChar *value, *value2 = NULL; - + if ((retValue == NULL) || (val == NULL)) return (-1); list = xmlSchemaValueGetNext(val) ? 1 : 0; *retValue = NULL; do { - value = NULL; - valType = xmlSchemaGetValType(val); - switch (valType) { + value = NULL; + valType = xmlSchemaGetValType(val); + switch (valType) { case XML_SCHEMAS_STRING: case XML_SCHEMAS_NORMSTRING: case XML_SCHEMAS_ANYSIMPLETYPE: @@ -1502,7 +1507,7 @@ xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val, if (value2 != NULL) value = value2; } - break; + break; default: if (xmlSchemaGetCanonValue(val, &value2) == -1) { if (value2 != NULL) @@ -1540,29 +1545,29 @@ internal_error: * @buf: the string buffer * @itemDes: the designation of the item * @itemName: the name of the item - * @item: the item as an object + * @item: the item as an object * @itemNode: the node of the item * @local: the local name * @parsing: if the function is used during the parse * * Returns a representation of the given item used - * for error reports. + * for error reports. * - * The following order is used to build the resulting + * The following order is used to build the resulting * designation if the arguments are not NULL: * 1a. If itemDes not NULL -> itemDes * 1b. If (itemDes not NULL) and (itemName not NULL) * -> itemDes + itemName * 2. If the preceding was NULL and (item not NULL) -> item * 3. If the preceding was NULL and (itemNode not NULL) -> itemNode - * + * * If the itemNode is an attribute node, the name of the attribute * will be appended to the result. * * Returns the formatted string and sets @buf to the resulting value. - */ -static xmlChar* -xmlSchemaFormatItemForReport(xmlChar **buf, + */ +static xmlChar* +xmlSchemaFormatItemForReport(xmlChar **buf, const xmlChar *itemDes, xmlSchemaBasicItemPtr item, xmlNodePtr itemNode) @@ -1574,9 +1579,9 @@ xmlSchemaFormatItemForReport(xmlChar **buf, xmlFree(*buf); *buf = NULL; } - + if (itemDes != NULL) { - *buf = xmlStrdup(itemDes); + *buf = xmlStrdup(itemDes); } else if (item != NULL) { switch (item->type) { case XML_SCHEMA_TYPE_BASIC: { @@ -1634,7 +1639,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, break; case XML_SCHEMA_TYPE_ATTRIBUTE_USE: { xmlSchemaAttributeUsePtr ause; - + ause = WXS_ATTR_USE_CAST item; *buf = xmlStrdup(BAD_CAST "attribute use "); if (WXS_ATTRUSE_DECL(ause) != NULL) { @@ -1650,7 +1655,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, break; case XML_SCHEMA_TYPE_ATTRIBUTE: { xmlSchemaAttributePtr attr; - + attr = (xmlSchemaAttributePtr) item; *buf = xmlStrdup(BAD_CAST "attribute decl."); *buf = xmlStrcat(*buf, BAD_CAST " '"); @@ -1666,7 +1671,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, case XML_SCHEMA_TYPE_ELEMENT: { xmlSchemaElementPtr elem; - elem = (xmlSchemaElementPtr) item; + elem = (xmlSchemaElementPtr) item; *buf = xmlStrdup(BAD_CAST "element decl."); *buf = xmlStrcat(*buf, BAD_CAST " '"); *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str, @@ -1676,7 +1681,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, break; case XML_SCHEMA_TYPE_IDC_UNIQUE: case XML_SCHEMA_TYPE_IDC_KEY: - case XML_SCHEMA_TYPE_IDC_KEYREF: + case XML_SCHEMA_TYPE_IDC_KEYREF: if (item->type == XML_SCHEMA_TYPE_IDC_UNIQUE) *buf = xmlStrdup(BAD_CAST "unique '"); else if (item->type == XML_SCHEMA_TYPE_IDC_KEY) @@ -1732,7 +1737,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, default: named = 0; } - } else + } else named = 0; if ((named == 0) && (itemNode != NULL)) { @@ -1740,7 +1745,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, if (itemNode->type == XML_ATTRIBUTE_NODE) elem = itemNode->parent; - else + else elem = itemNode; *buf = xmlStrdup(BAD_CAST "Element '"); if (elem->ns != NULL) { @@ -1750,7 +1755,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, } else *buf = xmlStrcat(*buf, elem->name); *buf = xmlStrcat(*buf, BAD_CAST "'"); - + } if ((itemNode != NULL) && (itemNode->type == XML_ATTRIBUTE_NODE)) { *buf = xmlStrcat(*buf, BAD_CAST ", attribute '"); @@ -1763,7 +1768,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, *buf = xmlStrcat(*buf, BAD_CAST "'"); } FREE_AND_NULL(str) - + return (*buf); } @@ -1786,13 +1791,13 @@ xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt, int res, found = 0; if (*buf != NULL) - xmlFree(*buf); + xmlFree(*buf); *buf = NULL; do { /* * Use the whitespace type of the base type. - */ + */ ws = xmlSchemaGetWhiteSpaceFacetValue(type->baseType); for (facet = type->facets; facet != NULL; facet = facet->next) { if (facet->type != XML_SCHEMA_FACET_ENUMERATION) @@ -1836,7 +1841,7 @@ xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt, /************************************************************************ * * - * Error functions * + * Error functions * * * ************************************************************************/ @@ -1881,7 +1886,7 @@ xmlSchemaPErrMemory(xmlSchemaParserCtxtPtr ctxt, * @msg: the error message * @str1: extra data * @str2: extra data - * + * * Handle a parser error */ static void @@ -1914,7 +1919,7 @@ xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, * @msg: the error message * @str1: extra data * @str2: extra data - * + * * Handle a parser error */ static void @@ -1933,7 +1938,7 @@ xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, * xmlSchemaPErrExt: * @ctxt: the parsing context * @node: the context node - * @error: the error code + * @error: the error code * @strData1: extra data * @strData2: extra data * @strData3: extra data @@ -1943,13 +1948,13 @@ xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, * @str3: extra parameter for the message display * @str4: extra parameter for the message display * @str5: extra parameter for the message display - * + * * Handle a parser error */ static void xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, - const xmlChar * strData1, const xmlChar * strData2, - const xmlChar * strData3, const char *msg, const xmlChar * str1, + const xmlChar * strData1, const xmlChar * strData2, + const xmlChar * strData3, const char *msg, const xmlChar * str1, const xmlChar * str2, const xmlChar * str3, const xmlChar * str4, const xmlChar * str5) { @@ -1967,14 +1972,14 @@ xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, } __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP, error, XML_ERR_ERROR, NULL, 0, - (const char *) strData1, (const char *) strData2, - (const char *) strData3, 0, 0, msg, str1, str2, + (const char *) strData1, (const char *) strData2, + (const char *) strData3, 0, 0, msg, str1, str2, str3, str4, str5); } /************************************************************************ * * - * Allround error functions * + * Allround error functions * * * ************************************************************************/ @@ -2016,7 +2021,7 @@ xmlSchemaPSimpleInternalErr(xmlNodePtr node, * @str1: extra data * @str2: extra data * @str3: extra data - * + * * Handle a validation error */ static void @@ -2028,16 +2033,17 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, { xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; - void *data = NULL; - + void *data = NULL; + if (ctxt != NULL) { if (ctxt->type == XML_SCHEMA_CTXT_VALIDATOR) { xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctxt; const char *file = NULL; + int col = 0; if (errorLevel != XML_ERR_WARNING) { vctxt->nberrors++; vctxt->err = error; - channel = vctxt->error; + channel = vctxt->error; } else { channel = vctxt->warning; } @@ -2062,6 +2068,7 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, (vctxt->parserCtxt->input != NULL)) { file = vctxt->parserCtxt->input->filename; line = vctxt->parserCtxt->input->line; + col = vctxt->parserCtxt->input->col; } } else { /* @@ -2077,19 +2084,33 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, else if ((vctxt->parserCtxt != NULL) && (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, (const char *) str1, (const char *) str2, - (const char *) str3, 0, 0, msg, str1, str2, str3, str4); + (const char *) str3, 0, col, msg, str1, str2, str3, str4); } else if (ctxt->type == XML_SCHEMA_CTXT_PARSER) { xmlSchemaParserCtxtPtr pctxt = (xmlSchemaParserCtxtPtr) ctxt; if (errorLevel != XML_ERR_WARNING) { pctxt->nberrors++; pctxt->err = error; - channel = pctxt->error; + channel = pctxt->error; } else { channel = pctxt->warning; } @@ -2115,11 +2136,11 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, * @str1: extra data * @str2: extra data * @str3: extra data - * + * * Handle a validation error */ static void -xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt, +xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt, int error, xmlNodePtr node, const char *msg, const xmlChar *str1, const xmlChar *str2, const xmlChar *str3) { @@ -2128,7 +2149,7 @@ xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt, } static void -xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt, +xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt, int error, xmlNodePtr node, const char *msg, const xmlChar *str1, const xmlChar *str2, const xmlChar *str3, const xmlChar *str4) @@ -2157,7 +2178,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, (node->type != XML_ELEMENT_NODE) && (node->type != XML_ATTRIBUTE_NODE)) { - /* + /* * Don't try to format other nodes than element and * attribute nodes. * Play save and return an empty string. @@ -2171,7 +2192,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, */ if (node->type == XML_ATTRIBUTE_NODE) { xmlNodePtr elem = node->parent; - + *msg = xmlStrdup(BAD_CAST "Element '"); if (elem->ns != NULL) *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, @@ -2181,7 +2202,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, NULL, elem->name)); FREE_AND_NULL(str); *msg = xmlStrcat(*msg, BAD_CAST "', "); - *msg = xmlStrcat(*msg, BAD_CAST "attribute '"); + *msg = xmlStrcat(*msg, BAD_CAST "attribute '"); } else { *msg = xmlStrdup(BAD_CAST "Element '"); } @@ -2197,7 +2218,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) actxt; /* * Work on node infos. - */ + */ if (vctxt->inode->nodeType == XML_ATTRIBUTE_NODE) { xmlSchemaNodeInfoPtr ielem = vctxt->elemInfos[vctxt->depth]; @@ -2207,7 +2228,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, ielem->nsName, ielem->localName)); FREE_AND_NULL(str); *msg = xmlStrcat(*msg, BAD_CAST "', "); - *msg = xmlStrcat(*msg, BAD_CAST "attribute '"); + *msg = xmlStrcat(*msg, BAD_CAST "attribute '"); } else { *msg = xmlStrdup(BAD_CAST "Element '"); } @@ -2216,7 +2237,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, FREE_AND_NULL(str); *msg = xmlStrcat(*msg, BAD_CAST "': "); } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) { - /* + /* * Hmm, no node while parsing? * Return an empty string, in case NULL will break something. */ @@ -2254,7 +2275,7 @@ xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt, return; msg = xmlStrdup(BAD_CAST "Internal error: "); msg = xmlStrcat(msg, BAD_CAST funcName); - msg = xmlStrcat(msg, BAD_CAST ", "); + msg = xmlStrcat(msg, BAD_CAST ", "); msg = xmlStrcat(msg, BAD_CAST message); msg = xmlStrcat(msg, BAD_CAST ".\n"); @@ -2262,7 +2283,7 @@ xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL, (const char *) msg, str1, str2); - else if (actxt->type == XML_SCHEMA_CTXT_PARSER) + else if (actxt->type == XML_SCHEMA_CTXT_PARSER) xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL, (const char *) msg, str1, str2); @@ -2309,7 +2330,7 @@ xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt, } else xmlSchemaFormatNodeForError(&msg, actxt, node); msg = xmlStrcat(msg, (const xmlChar *) message); - msg = xmlStrcat(msg, BAD_CAST ".\n"); + msg = xmlStrcat(msg, BAD_CAST ".\n"); xmlSchemaErr4(actxt, error, node, (const char *) msg, str1, str2, str3, str4); FREE_AND_NULL(msg) @@ -2325,7 +2346,7 @@ xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt, const xmlChar *str2) { xmlSchemaCustomErr4(actxt, error, node, item, - message, str1, str2, NULL, NULL); + message, str1, str2, NULL, NULL); } @@ -2344,8 +2365,8 @@ xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaFormatNodeForError(&msg, actxt, node); msg = xmlStrcat(msg, (const xmlChar *) message); - msg = xmlStrcat(msg, BAD_CAST ".\n"); - + msg = xmlStrcat(msg, BAD_CAST ".\n"); + /* URGENT TODO: Set the error code to something sane. */ xmlSchemaErr4Line(actxt, XML_ERR_WARNING, error, node, 0, (const char *) msg, str1, str2, str3, NULL); @@ -2365,15 +2386,15 @@ xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt, const xmlChar *str2) { xmlChar *msg = NULL, *qname = NULL; - - msg = xmlStrdup(BAD_CAST "Element '%s': "); + + msg = xmlStrdup(BAD_CAST "Element '%s': "); msg = xmlStrcat(msg, (const xmlChar *) message); msg = xmlStrcat(msg, BAD_CAST ".\n"); xmlSchemaErr4Line(ACTXT_CAST vctxt, XML_ERR_ERROR, error, NULL, idcNode->nodeLine, (const char *) msg, xmlSchemaFormatQName(&qname, vctxt->nodeQNames->items[idcNode->nodeQNameID +1], - vctxt->nodeQNames->items[idcNode->nodeQNameID]), + vctxt->nodeQNames->items[idcNode->nodeQNameID]), str1, str2, NULL); FREE_AND_NULL(qname); FREE_AND_NULL(msg); @@ -2456,7 +2477,7 @@ xmlSchemaSimpleTypeErr(xmlSchemaAbstractCtxtPtr actxt, if (type->builtInType != 0) { msg = xmlStrcat(msg, BAD_CAST "xs:"); msg = xmlStrcat(msg, type->name); - } else + } else msg = xmlStrcat(msg, xmlSchemaFormatQName(&str, type->targetNamespace, type->name)); @@ -2494,12 +2515,12 @@ xmlSchemaIllegalAttrErr(xmlSchemaAbstractCtxtPtr actxt, xmlNodePtr node) { xmlChar *msg = NULL, *str = NULL; - + xmlSchemaFormatNodeForError(&msg, actxt, node); msg = xmlStrcat(msg, BAD_CAST "The attribute '%s' is not allowed.\n"); xmlSchemaErr(actxt, error, node, (const char *) msg, xmlSchemaFormatErrorNodeQName(&str, (xmlSchemaNodeInfoPtr) ni, node), - NULL); + NULL); FREE_AND_NULL(str) FREE_AND_NULL(msg) } @@ -2518,7 +2539,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, xmlChar *localName, *nsName; const xmlChar *cur, *end; int i; - + xmlSchemaFormatNodeForError(&msg, actxt, node); msg = xmlStrcat(msg, (const xmlChar *) message); msg = xmlStrcat(msg, BAD_CAST "."); @@ -2533,7 +2554,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, } else str = xmlStrdup(BAD_CAST " Expected is ( "); nsName = NULL; - + for (i = 0; i < nbval + nbneg; i++) { cur = values[i]; if (cur == NULL) @@ -2547,7 +2568,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, * Get the local name. */ localName = NULL; - + end = cur; if (*end == '*') { localName = xmlStrdup(BAD_CAST "*"); @@ -2556,8 +2577,8 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, while ((*end != 0) && (*end != '|')) end++; localName = xmlStrncat(localName, BAD_CAST cur, end - cur); - } - if (*end != 0) { + } + if (*end != 0) { end++; /* * Skip "*|*" if they come with negated expressions, since @@ -2573,12 +2594,12 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, } else { while (*end != 0) end++; - + if (i >= nbval) nsName = xmlStrdup(BAD_CAST "{##other:"); else nsName = xmlStrdup(BAD_CAST "{"); - + nsName = xmlStrncat(nsName, BAD_CAST cur, end - cur); nsName = xmlStrcat(nsName, BAD_CAST "}"); } @@ -2588,13 +2609,13 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, FREE_AND_NULL(localName); continue; } - } + } str = xmlStrcat(str, BAD_CAST localName); FREE_AND_NULL(localName); - + if (i < nbval + nbneg -1) str = xmlStrcat(str, BAD_CAST ", "); - } + } str = xmlStrcat(str, BAD_CAST " ).\n"); msg = xmlStrcat(msg, BAD_CAST str); FREE_AND_NULL(str) @@ -2626,8 +2647,8 @@ xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt, /* * If enumerations are validated, one must not expect the * facet to be given. - */ - } else + */ + } else facetType = facet->type; msg = xmlStrcat(msg, BAD_CAST "["); msg = xmlStrcat(msg, BAD_CAST "facet '"); @@ -2655,31 +2676,31 @@ xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt, snprintf(actLen, 24, "%lu", length); if (facetType == XML_SCHEMA_FACET_LENGTH) - msg = xmlStrcat(msg, - BAD_CAST "this differs from the allowed length of '%s'.\n"); + msg = xmlStrcat(msg, + BAD_CAST "this differs from the allowed length of '%s'.\n"); else if (facetType == XML_SCHEMA_FACET_MAXLENGTH) - msg = xmlStrcat(msg, + msg = xmlStrcat(msg, BAD_CAST "this exceeds the allowed maximum length of '%s'.\n"); else if (facetType == XML_SCHEMA_FACET_MINLENGTH) - msg = xmlStrcat(msg, + msg = xmlStrcat(msg, BAD_CAST "this underruns the allowed minimum length of '%s'.\n"); - + if (nodeType == XML_ATTRIBUTE_NODE) xmlSchemaErr3(actxt, error, node, (const char *) msg, value, (const xmlChar *) actLen, (const xmlChar *) len); - else + else xmlSchemaErr(actxt, error, node, (const char *) msg, (const xmlChar *) actLen, (const xmlChar *) len); - + } else if (facetType == XML_SCHEMA_FACET_ENUMERATION) { msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not an element " "of the set {%s}.\n"); - xmlSchemaErr(actxt, error, node, (const char *) msg, value, + xmlSchemaErr(actxt, error, node, (const char *) msg, value, xmlSchemaFormatFacetEnumSet(actxt, &str, type)); } else if (facetType == XML_SCHEMA_FACET_PATTERN) { msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not accepted " "by the pattern '%s'.\n"); - xmlSchemaErr(actxt, error, node, (const char *) msg, value, + xmlSchemaErr(actxt, error, node, (const char *) msg, value, facet->value); } else if (facetType == XML_SCHEMA_FACET_MININCLUSIVE) { msg = xmlStrcat(msg, BAD_CAST "The value '%s' is less than the " @@ -2711,10 +2732,10 @@ xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt, "digits than are allowed ('%s').\n"); xmlSchemaErr(actxt, error, node, (const char*) msg, value, facet->value); - } else if (nodeType == XML_ATTRIBUTE_NODE) { + } else if (nodeType == XML_ATTRIBUTE_NODE) { msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not facet-valid.\n"); - xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL); - } else { + xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL); + } else { msg = xmlStrcat(msg, BAD_CAST "The value is not facet-valid.\n"); xmlSchemaErr(actxt, error, node, (const char *) msg, NULL, NULL); } @@ -2722,7 +2743,7 @@ xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt, msg = xmlStrcat(msg, (const xmlChar *) message); msg = xmlStrcat(msg, BAD_CAST ".\n"); xmlSchemaErr(actxt, error, node, (const char *) msg, str1, str2); - } + } FREE_AND_NULL(str) xmlFree(msg); } @@ -2967,9 +2988,9 @@ xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt, const xmlChar *str3,const xmlChar *str4) { xmlChar *str = NULL, *msg = NULL; - + xmlSchemaFormatItemForReport(&msg, NULL, ownerItem, NULL); - msg = xmlStrcat(msg, BAD_CAST ", "); + msg = xmlStrcat(msg, BAD_CAST ", "); msg = xmlStrcat(msg, BAD_CAST xmlSchemaFormatItemForReport(&str, NULL, WXS_BASIC_CAST attruse, NULL)); @@ -2977,7 +2998,7 @@ xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt, msg = xmlStrcat(msg, BAD_CAST ": "); msg = xmlStrcat(msg, (const xmlChar *) message); msg = xmlStrcat(msg, BAD_CAST ".\n"); - xmlSchemaErr4(ACTXT_CAST ctxt, error, node, + xmlSchemaErr4(ACTXT_CAST ctxt, error, node, (const char *) msg, str1, str2, str3, str4); xmlFree(msg); } @@ -3071,7 +3092,7 @@ xmlSchemaPMutualExclAttrErr(xmlSchemaParserCtxtPtr ctxt, * @error: the error code * @type: the type specifier * @ownerDes: the designation of the owner - * @ownerItem: the schema object if existent + * @ownerItem: the schema object if existent * @node: the validated node * @value: the validated value * @@ -3079,7 +3100,7 @@ xmlSchemaPMutualExclAttrErr(xmlSchemaParserCtxtPtr ctxt, * TODO: Should this report the value of an element as well? */ static void -xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, +xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, xmlParserErrors error, xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED, xmlNodePtr node, @@ -3091,37 +3112,37 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, const xmlChar *str2) { xmlChar *msg = NULL; - + xmlSchemaFormatNodeForError(&msg, ACTXT_CAST ctxt, node); if (message == NULL) { /* * Use default messages. - */ + */ if (type != NULL) { if (node->type == XML_ATTRIBUTE_NODE) msg = xmlStrcat(msg, BAD_CAST "'%s' is not a valid value of "); else msg = xmlStrcat(msg, BAD_CAST "The character content is not a " - "valid value of "); + "valid value of "); if (! xmlSchemaIsGlobalItem(type)) msg = xmlStrcat(msg, BAD_CAST "the local "); else msg = xmlStrcat(msg, BAD_CAST "the "); - + if (WXS_IS_ATOMIC(type)) msg = xmlStrcat(msg, BAD_CAST "atomic type"); else if (WXS_IS_LIST(type)) msg = xmlStrcat(msg, BAD_CAST "list type"); else if (WXS_IS_UNION(type)) msg = xmlStrcat(msg, BAD_CAST "union type"); - + if (xmlSchemaIsGlobalItem(type)) { xmlChar *str = NULL; msg = xmlStrcat(msg, BAD_CAST " '"); if (type->builtInType != 0) { msg = xmlStrcat(msg, BAD_CAST "xs:"); msg = xmlStrcat(msg, type->name); - } else + } else msg = xmlStrcat(msg, xmlSchemaFormatQName(&str, type->targetNamespace, type->name)); @@ -3134,7 +3155,7 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, else msg = xmlStrcat(msg, BAD_CAST "The character content is not " "valid."); - } + } if (expected) { msg = xmlStrcat(msg, BAD_CAST " Expected is '"); msg = xmlStrcat(msg, BAD_CAST expected); @@ -3151,7 +3172,7 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPErrExt(ctxt, node, error, NULL, NULL, NULL, (const char*) msg, str1, str2, NULL, NULL, NULL); } - /* Cleanup. */ + /* Cleanup. */ FREE_AND_NULL(msg) } @@ -3199,25 +3220,25 @@ xmlSchemaPContentErr(xmlSchemaParserCtxtPtr ctxt, } /************************************************************************ - * * - * Streamable error functions * - * * + * * + * Streamable error functions * + * * ************************************************************************/ /************************************************************************ - * * - * Validation helper functions * - * * + * * + * Validation helper functions * + * * ************************************************************************/ /************************************************************************ - * * - * Allocation functions * - * * + * * + * Allocation functions * + * * ************************************************************************/ /** @@ -3372,7 +3393,7 @@ xmlSchemaItemListAddSize(xmlSchemaItemListPtr list, static int xmlSchemaItemListInsert(xmlSchemaItemListPtr list, void *item, int idx) -{ +{ if (list->items == NULL) { list->items = (void **) xmlMalloc( 20 * sizeof(void *)); @@ -3412,7 +3433,7 @@ xmlSchemaItemListInsertSize(xmlSchemaItemListPtr list, int initialSize, void *item, int idx) -{ +{ if (list->items == NULL) { if (initialSize <= 0) initialSize = 1; @@ -3467,7 +3488,7 @@ xmlSchemaItemListRemove(xmlSchemaItemListPtr list, int idx) list->sizeItems = 0; } else if (list->nbItems -1 == idx) { list->nbItems--; - } else { + } else { for (i = idx; i < list->nbItems -1; i++) list->items[i] = list->items[i+1]; list->nbItems--; @@ -3502,19 +3523,19 @@ xmlSchemaBucketFree(xmlSchemaBucketPtr bucket) } if (bucket->locals != NULL) { xmlSchemaComponentListFree(bucket->locals); - xmlSchemaItemListFree(bucket->locals); + xmlSchemaItemListFree(bucket->locals); } if (bucket->relations != NULL) { xmlSchemaSchemaRelationPtr prev, cur = bucket->relations; do { - prev = cur; + prev = cur; cur = cur->next; xmlFree(prev); } while (cur != NULL); } if ((! bucket->preserveDoc) && (bucket->doc != NULL)) { xmlFreeDoc(bucket->doc); - } + } if (bucket->type == XML_SCHEMA_SCHEMA_IMPORT) { if (WXS_IMPBUCKET(bucket)->schema != NULL) xmlSchemaFree(WXS_IMPBUCKET(bucket)->schema); @@ -3559,7 +3580,7 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, xmlFree(ret); return(NULL); } - /* + /* * The following will assure that only the first bucket is marked as * XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema. * For each following import buckets an xmlSchema will be created. @@ -3573,7 +3594,7 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, xmlSchemaBucketFree(ret); return(NULL); } - /* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */ + /* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */ ret->type = XML_SCHEMA_SCHEMA_MAIN; /* Point to the *main* schema. */ WXS_CONSTRUCTOR(pctxt)->mainBucket = ret; @@ -3583,12 +3604,12 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, */ mainSchema->targetNamespace = targetNamespace; } else { - if (type == XML_SCHEMA_SCHEMA_MAIN) { + if (type == XML_SCHEMA_SCHEMA_MAIN) { PERROR_INT("xmlSchemaBucketCreate", "main bucket but it's not the first one"); xmlSchemaBucketFree(ret); return(NULL); - } else if (type == XML_SCHEMA_SCHEMA_IMPORT) { + } else if (type == XML_SCHEMA_SCHEMA_IMPORT) { /* * Create a schema for imports and assign the * targetNamespace. @@ -3600,7 +3621,7 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, } WXS_IMPBUCKET(ret)->schema->targetNamespace = targetNamespace; } - } + } if (WXS_IS_BUCKET_IMPMAIN(type)) { int res; /* @@ -3643,11 +3664,11 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, if (mainSchema->includes == NULL) { xmlSchemaBucketFree(ret); return(NULL); - } + } } xmlSchemaItemListAdd(mainSchema->includes, ret); } - /* + /* * Add to list of all buckets; this is used for lookup * during schema construction time only. */ @@ -4015,7 +4036,7 @@ xmlSchemaComponentListFree(xmlSchemaItemListPtr list) for (i = 0; i < list->nbItems; i++) { item = items[i]; if (item == NULL) - continue; + continue; switch (item->type) { case XML_SCHEMA_TYPE_SIMPLE: case XML_SCHEMA_TYPE_COMPLEX: @@ -4122,7 +4143,7 @@ xmlSchemaFree(xmlSchemaPtr schema) xmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes; int i; for (i = 0; i < list->nbItems; i++) { - xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]); + xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]); } xmlSchemaItemListFree(list); } @@ -4135,9 +4156,9 @@ xmlSchemaFree(xmlSchemaPtr schema) } /************************************************************************ - * * - * Debug functions * - * * + * * + * Debug functions * + * * ************************************************************************/ #ifdef LIBXML_OUTPUT_ENABLED @@ -4274,7 +4295,7 @@ xmlSchemaContentModelDump(xmlSchemaParticlePtr particle, FILE * output, int dept for (i = 0;((i < depth) && (i < 25));i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; - fprintf(output, shift); + fprintf(output, "%s", shift); if (particle->children == NULL) { fprintf(output, "MISSING particle term\n"); return; @@ -4330,7 +4351,7 @@ xmlSchemaContentModelDump(xmlSchemaParticlePtr particle, FILE * output, int dept /** * xmlSchemaAttrUsesDump: * @uses: attribute uses list - * @output: the file output + * @output: the file output * * Dumps a list of attribute use components. */ @@ -4347,7 +4368,7 @@ xmlSchemaAttrUsesDump(xmlSchemaItemListPtr uses, FILE * output) if ((uses == NULL) || (uses->nbItems == 0)) return; - fprintf(output, " attributes:\n"); + fprintf(output, " attributes:\n"); for (i = 0; i < uses->nbItems; i++) { use = uses->items[i]; if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) { @@ -4533,7 +4554,7 @@ xmlSchemaDebugDumpIDCTable(FILE * output, return; do { fprintf(output, "IDC: BINDING '%s' (%d)\n", - xmlSchemaGetComponentQName(&str, + xmlSchemaGetComponentQName(&str, bind->definition), bind->nbNodes); FREE_AND_NULL(str) for (i = 0; i < bind->nbNodes; i++) { @@ -4587,7 +4608,7 @@ xmlSchemaDebugDumpIDCTable(FILE * output, /************************************************************************ * * - * Utilities * + * Utilities * * * ************************************************************************/ @@ -4634,7 +4655,7 @@ xmlSchemaGetPropNodeNs(xmlNodePtr node, const char *uri, const char *name) xmlAttrPtr prop; if ((node == NULL) || (name == NULL)) - return(NULL); + return(NULL); prop = node->properties; while (prop != NULL) { if ((prop->ns != NULL) && @@ -4692,9 +4713,9 @@ xmlSchemaGetProp(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, } /************************************************************************ - * * - * Parsing functions * - * * + * * + * Parsing functions * + * * ************************************************************************/ #define WXS_FIND_GLOBAL_ITEM(slot) \ @@ -4729,12 +4750,12 @@ xmlSchemaGetElem(xmlSchemaPtr schema, const xmlChar * name, const xmlChar * nsName) { xmlSchemaElementPtr ret = NULL; - + if ((name == NULL) || (schema == NULL)) return(NULL); if (schema != NULL) { WXS_FIND_GLOBAL_ITEM(elemDecl) - } + } exit: #ifdef DEBUG if (ret == NULL) { @@ -4765,9 +4786,9 @@ xmlSchemaGetType(xmlSchemaPtr schema, const xmlChar * name, xmlSchemaTypePtr ret = NULL; if (name == NULL) - return (NULL); + return (NULL); /* First try the built-in types. */ - if ((nsName != NULL) && xmlStrEqual(nsName, xmlSchemaNs)) { + if ((nsName != NULL) && xmlStrEqual(nsName, xmlSchemaNs)) { ret = xmlSchemaGetPredefinedType(name, nsName); if (ret != NULL) goto exit; @@ -4780,7 +4801,7 @@ xmlSchemaGetType(xmlSchemaPtr schema, const xmlChar * name, } if (schema != NULL) { WXS_FIND_GLOBAL_ITEM(typeDecl) - } + } exit: #ifdef DEBUG @@ -4891,7 +4912,7 @@ xmlSchemaGetGroup(xmlSchemaPtr schema, const xmlChar * name, WXS_FIND_GLOBAL_ITEM(groupDecl) } exit: - + #ifdef DEBUG if (ret == NULL) { if (nsName == NULL) @@ -4966,9 +4987,9 @@ xmlSchemaGetNamedComponent(xmlSchemaPtr schema, } /************************************************************************ - * * - * Parsing functions * - * * + * * + * Parsing functions * + * * ************************************************************************/ #define IS_BLANK_NODE(n) \ @@ -5000,7 +5021,7 @@ xmlSchemaIsBlank(xmlChar * str, int len) str++; len--; } - + return (1); } @@ -5061,7 +5082,7 @@ xmlSchemaFindRedefCompInGraph(xmlSchemaBucketPtr bucket, default: /* Should not be hit. */ return(NULL); - } + } } } subschemas: @@ -5209,7 +5230,7 @@ xmlSchemaAddAttributeUse(xmlSchemaParserCtxtPtr pctxt, * resolve references to the redefined components and to check constraints. */ static xmlSchemaRedefPtr -xmlSchemaAddRedef(xmlSchemaParserCtxtPtr pctxt, +xmlSchemaAddRedef(xmlSchemaParserCtxtPtr pctxt, xmlSchemaBucketPtr targetBucket, void *item, const xmlChar *refName, @@ -5272,7 +5293,7 @@ xmlSchemaAddAttributeGroupDefinition(xmlSchemaParserCtxtPtr pctxt, ret->type = XML_SCHEMA_TYPE_ATTRIBUTEGROUP; ret->name = name; ret->targetNamespace = nsName; - ret->node = node; + ret->node = node; /* TODO: Remove the flag. */ ret->flags |= XML_SCHEMAS_ATTRGROUP_GLOBAL; @@ -5282,7 +5303,7 @@ xmlSchemaAddAttributeGroupDefinition(xmlSchemaParserCtxtPtr pctxt, if (pctxt->redef == NULL) { xmlFree(ret); return(NULL); - } + } pctxt->redefCounter = 0; } WXS_ADD_GLOBAL(pctxt, ret); @@ -5371,13 +5392,13 @@ xmlSchemaAddType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, if (ctxt->redef == NULL) { xmlFree(ret); return(NULL); - } + } ctxt->redefCounter = 0; } WXS_ADD_GLOBAL(ctxt, ret); } else WXS_ADD_LOCAL(ctxt, ret); - WXS_ADD_PENDING(ctxt, ret); + WXS_ADD_PENDING(ctxt, ret); return (ret); } @@ -5509,7 +5530,7 @@ xmlSchemaAddParticle(xmlSchemaParserCtxtPtr ctxt, ret->children = NULL; WXS_ADD_LOCAL(ctxt, ret); - /* + /* * Note that addition to pending components will be done locally * to the specific parsing function, since the most particles * need not to be fixed up (i.e. the reference to be resolved). @@ -5558,7 +5579,7 @@ xmlSchemaAddModelGroupDefinition(xmlSchemaParserCtxtPtr ctxt, if (ctxt->redef == NULL) { xmlFree(ret); return(NULL); - } + } ctxt->redefCounter = 0; } WXS_ADD_GLOBAL(ctxt, ret); @@ -5595,7 +5616,7 @@ xmlSchemaAddIDC(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, const xmlChar *name, const xmlChar *nsName, int category, xmlNodePtr node) { - xmlSchemaIDCPtr ret = NULL; + xmlSchemaIDCPtr ret = NULL; if ((ctxt == NULL) || (schema == NULL) || (name == NULL)) return (NULL); @@ -5611,8 +5632,8 @@ xmlSchemaAddIDC(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, ret->targetNamespace = nsName; ret->name = name; ret->type = category; - ret->node = node; - + ret->node = node; + WXS_ADD_GLOBAL(ctxt, ret); /* * Only keyrefs need to be fixup up. @@ -5648,7 +5669,7 @@ xmlSchemaAddWildcard(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, } memset(ret, 0, sizeof(xmlSchemaWildcard)); ret->type = type; - ret->node = node; + ret->node = node; WXS_ADD_LOCAL(ctxt, ret); return (ret); } @@ -5704,7 +5725,7 @@ xmlSchemaSubstGroupAdd(xmlSchemaParserCtxtPtr pctxt, static xmlSchemaSubstGroupPtr xmlSchemaSubstGroupGet(xmlSchemaParserCtxtPtr pctxt, xmlSchemaElementPtr head) -{ +{ if (WXS_SUBST_GROUPS(pctxt) == NULL) return(NULL); return(xmlHashLookup2(WXS_SUBST_GROUPS(pctxt), @@ -5743,9 +5764,9 @@ xmlSchemaAddElementSubstitutionMember(xmlSchemaParserCtxtPtr pctxt, } /************************************************************************ - * * + * * * Utilities for parsing * - * * + * * ************************************************************************/ /** @@ -5939,7 +5960,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, @@ -6120,7 +6141,7 @@ xmlSchemaPGetBoolNodeValue(xmlSchemaParserCtxtPtr ctxt, value = xmlNodeGetContent(node); /* * 3.2.2.1 Lexical representation - * An instance of a datatype that is defined as ·boolean· + * An instance of a datatype that is defined as `boolean` * can have the following legal literals {true, false, 1, 0}. */ if (xmlStrEqual(BAD_CAST value, BAD_CAST "true")) @@ -6168,7 +6189,7 @@ xmlGetBooleanProp(xmlSchemaParserCtxtPtr ctxt, return (def); /* * 3.2.2.1 Lexical representation - * An instance of a datatype that is defined as ·boolean· + * An instance of a datatype that is defined as `boolean` * can have the following legal literals {true, false, 1, 0}. */ if (xmlStrEqual(val, BAD_CAST "true")) @@ -6191,9 +6212,9 @@ xmlGetBooleanProp(xmlSchemaParserCtxtPtr ctxt, } /************************************************************************ - * * + * * * Shema extraction from an Infoset * - * * + * * ************************************************************************/ static xmlSchemaTypePtr xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, @@ -6288,7 +6309,7 @@ xmlSchemaPValAttrNodeValue(xmlSchemaParserCtxtPtr pctxt, ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; else ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1; - xmlSchemaPSimpleTypeErr(pctxt, + xmlSchemaPSimpleTypeErr(pctxt, ret, ownerItem, (xmlNodePtr) attr, type, NULL, value, NULL, NULL, NULL); } @@ -6352,7 +6373,7 @@ xmlSchemaPValAttrNode(xmlSchemaParserCtxtPtr ctxt, * number otherwise and -1 in case of an internal or API error. */ static int -xmlSchemaPValAttr(xmlSchemaParserCtxtPtr ctxt, +xmlSchemaPValAttr(xmlSchemaParserCtxtPtr ctxt, xmlSchemaBasicItemPtr ownerItem, xmlNodePtr ownerElem, const char *name, @@ -6442,7 +6463,7 @@ xmlSchemaCheckReference(xmlSchemaParserCtxtPtr pctxt, * @type: the hosting type where the attributes will be anchored * * Parses attribute uses and attribute declarations and - * attribute group references. + * attribute group references. */ static int xmlSchemaParseLocalAttributes(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, @@ -6797,7 +6818,7 @@ xmlSchemaParseWildcardNs(xmlSchemaParserCtxtPtr ctxt, tmp->next = NULL; if (wildc->nsSet == NULL) wildc->nsSet = tmp; - else + else if (lastNs != NULL) lastNs->next = tmp; lastNs = tmp; } @@ -7085,7 +7106,7 @@ xmlSchemaParseLocalAttribute(xmlSchemaParserCtxtPtr pctxt, int parentType) { const xmlChar *attrValue, *name = NULL, *ns = NULL; - xmlSchemaAttributeUsePtr use = NULL; + xmlSchemaAttributeUsePtr use = NULL; xmlNodePtr child = NULL; xmlAttrPtr attr; const xmlChar *tmpNs = NULL, *tmpName = NULL, *defValue = NULL; @@ -7139,7 +7160,7 @@ xmlSchemaParseLocalAttribute(xmlSchemaParserCtxtPtr pctxt, /* * Evaluate the target namespace */ - hasForm = 1; + hasForm = 1; attrValue = xmlSchemaGetNodeContent(pctxt, (xmlNodePtr) attr); if (xmlStrEqual(attrValue, BAD_CAST "qualified")) { @@ -7210,7 +7231,7 @@ xmlSchemaParseLocalAttribute(xmlSchemaParserCtxtPtr pctxt, attr_next: attr = attr->next; - } + } /* * 3.2.3 : 2 * If default and use are both present, use must have @@ -7236,7 +7257,7 @@ attr_next: /* TODO: move XML_SCHEMAS_QUALIF_ATTR to the parser. */ if ((! hasForm) && (schema->flags & XML_SCHEMAS_QUALIF_ATTR)) - ns = pctxt->targetNamespace; + ns = pctxt->targetNamespace; /* * 3.2.6 Schema Component Constraint: xsi: Not Allowed * TODO: Move this to the component layer. @@ -7293,7 +7314,7 @@ attr_next: use->attrDecl = attrDecl; /* * Value constraint. - */ + */ if (defValue != NULL) { attrDecl->defValue = defValue; if (defValueType == WXS_ATTR_DEF_VAL_FIXED) @@ -7333,14 +7354,14 @@ attr_next: if (defValueType == WXS_ATTR_DEF_VAL_FIXED) use->flags |= XML_SCHEMA_ATTR_USE_FIXED; } - + check_children: /* * And now for the children... */ child = node->children; if (occurs == XML_SCHEMAS_ATTR_USE_PROHIBITED) { - xmlSchemaAttributeUseProhibPtr prohib; + xmlSchemaAttributeUseProhibPtr prohib; if (IS_SCHEMA(child, "annotation")) { xmlSchemaParseAnnotation(pctxt, child, 0); @@ -7355,7 +7376,7 @@ check_children: /* * Check for pointlessness of attribute prohibitions. */ - if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) { + if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) { xmlSchemaCustomWarning(ACTXT_CAST pctxt, XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, node, NULL, @@ -7373,7 +7394,7 @@ check_children: return(NULL); } if (! isRef) { - tmpName = name; + tmpName = name; tmpNs = ns; } /* @@ -7381,7 +7402,7 @@ check_children: */ if (uses) { int i; - + for (i = 0; i < uses->nbItems; i++) { use = uses->items[i]; if ((use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) && @@ -7389,16 +7410,16 @@ check_children: (tmpNs == (WXS_ATTR_PROHIB_CAST use)->targetNamespace)) { xmlChar *str = NULL; - + xmlSchemaCustomWarning(ACTXT_CAST pctxt, XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, node, NULL, "Skipping duplicate attribute use prohibition '%s'", xmlSchemaFormatQName(&str, tmpNs, tmpName), NULL, NULL); - FREE_AND_NULL(str) + FREE_AND_NULL(str) return(NULL); - } + } } } /* @@ -7417,7 +7438,7 @@ check_children: WXS_ADD_PENDING(pctxt, prohib); } return(WXS_BASIC_CAST prohib); - } else { + } else { if (IS_SCHEMA(child, "annotation")) { /* * TODO: Should this go into the attr decl? @@ -7464,7 +7485,7 @@ check_children: NULL, node, child, NULL, "(annotation?, simpleType?)"); } - } + } return (WXS_BASIC_CAST use); } @@ -7486,7 +7507,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt, * 3.2.3 Constraints on XML Representations of Attribute Declarations */ if ((pctxt == NULL) || (schema == NULL) || (node == NULL)) - return (NULL); + return (NULL); /* * 3.2.3 : 3.1 * One of ref or name must be present, but not both @@ -7532,7 +7553,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt, if (ret == NULL) return (NULL); ret->flags |= XML_SCHEMAS_ATTR_GLOBAL; - + /* * Check for illegal attributes. */ @@ -7546,7 +7567,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt, (!xmlStrEqual(attr->name, BAD_CAST "type"))) { xmlSchemaPIllegalAttrErr(pctxt, - XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); + XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); } } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { xmlSchemaPIllegalAttrErr(pctxt, @@ -7556,7 +7577,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt, } xmlSchemaPValAttrQName(pctxt, schema, NULL, node, "type", &ret->typeNs, &ret->typeName); - + xmlSchemaPValAttrID(pctxt, node, BAD_CAST "id"); /* * Attribute "fixed". @@ -7641,12 +7662,12 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt, XML_SCHEMAP_S4S_ATTR_MISSING, NULL, node, "ref", NULL); return (NULL); - } + } xmlSchemaPValAttrNodeQName(pctxt, schema, NULL, attr, &refNs, &ref); if (xmlSchemaCheckReference(pctxt, schema, node, attr, refNs) != 0) return(NULL); - + /* * Check for illegal attributes. */ @@ -7698,13 +7719,13 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt, /* * SPEC src-redefine: * (7.1) "If it has an <attributeGroup> among its contents - * the ·actual value· of whose ref [attribute] is the same - * as the ·actual value· of its own name attribute plus + * the `actual value` of whose ref [attribute] is the same + * as the `actual value` of its own name attribute plus * target namespace, then it must have exactly one such group." */ if (pctxt->redefCounter != 0) { xmlChar *str = NULL; - + xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_SRC_REDEFINE, node, NULL, "The redefining attribute group definition " @@ -7738,7 +7759,7 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt, ret->node = node; /* Add to pending items, to be able to resolve the reference. */ WXS_ADD_PENDING(pctxt, ret); - } + } return (ret); } @@ -7785,7 +7806,7 @@ xmlSchemaParseAttributeGroupDefinition(xmlSchemaParserCtxtPtr pctxt, ret = xmlSchemaAddAttributeGroupDefinition(pctxt, schema, name, pctxt->targetNamespace, node); if (ret == NULL) - return (NULL); + return (NULL); /* * Check for illegal attributes. */ @@ -8185,7 +8206,7 @@ xmlSchemaAddAnnotation(xmlSchemaAnnotItemPtr annItem, * Returns the parsed identity-constraint definition. */ static xmlSchemaIDCSelectPtr -xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt, +xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt, xmlSchemaIDCPtr idc, xmlNodePtr node, int isField) @@ -8227,7 +8248,7 @@ xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt, */ attr = xmlSchemaGetPropNode(node, "xpath"); if (attr == NULL) { - xmlSchemaPMissingAttrErr(ctxt, + xmlSchemaPMissingAttrErr(ctxt, XML_SCHEMAP_S4S_ATTR_MISSING, NULL, node, "name", NULL); @@ -8848,7 +8869,7 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, type->flags |= XML_SCHEMAS_TYPE_VARIETY_UNION; /* * SPEC (Base type) (2) "If the <list> or <union> alternative is chosen, - * then the ·simple ur-type definition·." + * then the `simple ur-type definition`." */ type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE); /* @@ -9016,7 +9037,7 @@ xmlSchemaParseList(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, type->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST; /* * SPEC (Base type) (2) "If the <list> or <union> alternative is chosen, - * then the ·simple ur-type definition·." + * then the `simple ur-type definition`." */ type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE); /* @@ -9161,9 +9182,9 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, } /* * TargetNamespace: - * SPEC "The ·actual value· of the targetNamespace [attribute] + * SPEC "The `actual value` of the targetNamespace [attribute] * of the <schema> ancestor element information item if present, - * otherwise ·absent·. + * otherwise `absent`. */ if (topLevel == 0) { #ifdef ENABLE_NAMED_LOCALS @@ -9195,7 +9216,7 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, if (attr->ns == NULL) { if (!xmlStrEqual(attr->name, BAD_CAST "id")) { xmlSchemaPIllegalAttrErr(ctxt, - XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); + XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); } } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { xmlSchemaPIllegalAttrErr(ctxt, @@ -9266,9 +9287,9 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, * And now for the children... */ oldCtxtType = ctxt->ctxtType; - + ctxt->ctxtType = type; - + child = node->children; if (IS_SCHEMA(child, "annotation")) { type->annot = xmlSchemaParseAnnotation(ctxt, child, 1); @@ -9278,10 +9299,10 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_MISSING, NULL, node, child, NULL, "(annotation?, (restriction | list | union))"); - } else if (IS_SCHEMA(child, "restriction")) { + } else if (IS_SCHEMA(child, "restriction")) { xmlSchemaParseRestriction(ctxt, schema, child, - XML_SCHEMA_TYPE_SIMPLE); - hasRestriction = 1; + XML_SCHEMA_TYPE_SIMPLE); + hasRestriction = 1; child = child->next; } else if (IS_SCHEMA(child, "list")) { xmlSchemaParseList(ctxt, schema, child); @@ -9298,8 +9319,8 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, /* * REDEFINE: SPEC src-redefine (5) * "Within the [children], each <simpleType> must have a - * <restriction> among its [children] ... the ·actual value· of whose - * base [attribute] must be the same as the ·actual value· of its own + * <restriction> among its [children] ... the `actual value` of whose + * base [attribute] must be the same as the `actual value` of its own * name attribute plus target namespace;" */ if (topLevel && ctxt->isRedefine && (! hasRestriction)) { @@ -9307,7 +9328,7 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, NULL, node, "This is a redefinition, thus the " "<simpleType> must have a <restriction> child", NULL); } - + ctxt->ctxtType = oldCtxtType; return (type); } @@ -9373,13 +9394,13 @@ xmlSchemaParseModelGroupDefRef(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id"); item = xmlSchemaAddParticle(ctxt, node, min, max); if (item == NULL) - return (NULL); + return (NULL); /* * Create a qname-reference and set as the term; it will be substituted * for the model group after the reference has been resolved. */ item->children = (xmlSchemaTreeItemPtr) - xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs); + xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs); xmlSchemaPCheckParticleCorrect_2(ctxt, item, node, min, max); /* * And now for the children... @@ -9419,7 +9440,7 @@ xmlSchemaParseModelGroupDefRef(xmlSchemaParserCtxtPtr ctxt, * Note that the contraint src-redefine (6.2) can't be applied until * references have been resolved. So we will do this at the * component fixup level. - * + * * *WARNING* this interface is highly subject to change * * Returns -1 in case of error, 0 if the declaration is improper and @@ -9493,7 +9514,7 @@ xmlSchemaParseModelGroupDefinition(xmlSchemaParserCtxtPtr ctxt, child = child->next; } - + if (child != NULL) { xmlSchemaPContentErr(ctxt, @@ -9631,7 +9652,7 @@ xmlSchemaParseSchemaElement(xmlSchemaParserCtxtPtr ctxt, attr = xmlSchemaGetPropNode(node, "version"); if (attr != NULL) { res = xmlSchemaPValAttrNode(ctxt, NULL, NULL, attr, - xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val); + xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val); HFAILURE; } */ @@ -9691,7 +9712,7 @@ xmlSchemaParseSchemaElement(xmlSchemaParserCtxtPtr ctxt, } attr = xmlSchemaGetPropNode(node, "blockDefault"); if (attr != NULL) { - val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr); + val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr); res = xmlSchemaPValAttrBlockFinal(val, &(schema->flags), -1, XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION, XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION, @@ -9752,14 +9773,14 @@ xmlSchemaParseSchemaTopLevel(xmlSchemaParserCtxtPtr ctxt, HFAILURE; HSTOP(ctxt); if (tmpOldErrs != ctxt->nberrors) - goto exit; + goto exit; } else if (IS_SCHEMA(child, "include")) { tmpOldErrs = ctxt->nberrors; res = xmlSchemaParseInclude(ctxt, schema, child); HFAILURE; HSTOP(ctxt); if (tmpOldErrs != ctxt->nberrors) - goto exit; + goto exit; } else if (IS_SCHEMA(child, "redefine")) { tmpOldErrs = ctxt->nberrors; res = xmlSchemaParseRedefine(ctxt, schema, child); @@ -9884,7 +9905,7 @@ xmlSchemaConstructionCtxtFree(xmlSchemaConstructionCtxtPtr con) xmlFree(con); } -static xmlSchemaConstructionCtxtPtr +static xmlSchemaConstructionCtxtPtr xmlSchemaConstructionCtxtCreate(xmlDictPtr dict) { xmlSchemaConstructionCtxtPtr ret; @@ -9954,10 +9975,10 @@ xmlSchemaNewParserCtxtUseDict(const char *URL, xmlDictPtr dict) xmlSchemaParserCtxtPtr ret; ret = xmlSchemaParserCtxtCreate(); - if (ret == NULL) + if (ret == NULL) return (NULL); ret->dict = dict; - xmlDictReference(dict); + xmlDictReference(dict); if (URL != NULL) ret->URL = xmlDictLookup(dict, (const xmlChar *) URL, -1); return (ret); @@ -10082,8 +10103,8 @@ xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt, xmlNodePtr node; int ret, oldErrs; xmlSchemaBucketPtr oldbucket = pctxt->constructor->bucket; - - /* + + /* * Save old values; reset the *main* schema. * URGENT TODO: This is not good; move the per-document information * to the parser. Get rid of passing the main schema to the @@ -10093,9 +10114,9 @@ xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt, oldDoc = schema->doc; if (schema->flags != 0) xmlSchemaClearSchemaDefaults(schema); - schema->doc = bucket->doc; + schema->doc = bucket->doc; pctxt->schema = schema; - /* + /* * Keep the current target namespace on the parser *not* on the * main schema. */ @@ -10108,7 +10129,7 @@ xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt, * We are parsing the schema for schemas! */ pctxt->isS4S = 1; - } + } /* Mark it as parsed, even if parsing fails. */ bucket->parsed++; /* Compile the schema doc. */ @@ -10132,7 +10153,7 @@ xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt, ret = pctxt->err; goto exit; } - + exit: WXS_CONSTRUCTOR(pctxt)->bucket = oldbucket; /* Restore schema values. */ @@ -10165,7 +10186,7 @@ xmlSchemaParseNewDoc(xmlSchemaParserCtxtPtr pctxt, PERROR_INT("xmlSchemaParseNewDoc", "no constructor"); return(-1); - } + } /* Create and init the temporary parser context. */ newpctxt = xmlSchemaNewParserCtxtUseDict( (const char *) bucket->schemaLocation, pctxt->dict); @@ -10173,7 +10194,7 @@ xmlSchemaParseNewDoc(xmlSchemaParserCtxtPtr pctxt, return(-1); newpctxt->constructor = pctxt->constructor; /* - * TODO: Can we avoid that the parser knows about the main schema? + * TODO: Can we avoid that the parser knows about the main schema? * It would be better if he knows about the current schema bucket * only. */ @@ -10183,16 +10204,16 @@ xmlSchemaParseNewDoc(xmlSchemaParserCtxtPtr pctxt, xmlSchemaSetParserStructuredErrors(newpctxt, pctxt->serror, pctxt->errCtxt); newpctxt->counter = pctxt->counter; - + res = xmlSchemaParseNewDocWithContext(newpctxt, schema, bucket); - + /* Channel back errors and cleanup the temporary parser context. */ if (res != 0) pctxt->err = res; pctxt->nberrors += newpctxt->nberrors; pctxt->counter = newpctxt->counter; - newpctxt->constructor = NULL; + newpctxt->constructor = NULL; /* Free the parser context. */ xmlSchemaFreeParserCtxt(newpctxt); return(res); @@ -10217,11 +10238,11 @@ xmlSchemaSchemaRelationAddChild(xmlSchemaBucketPtr bucket, static const xmlChar * xmlSchemaBuildAbsoluteURI(xmlDictPtr dict, const xmlChar* location, xmlNodePtr ctxtNode) -{ +{ /* * Build an absolue location URI. */ - if (location != NULL) { + if (location != NULL) { if (ctxtNode == NULL) return(location); else { @@ -10244,7 +10265,7 @@ xmlSchemaBuildAbsoluteURI(xmlDictPtr dict, const xmlChar* location, } return(NULL); } - + /** @@ -10267,8 +10288,8 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, const char *schemaBuffer, int schemaBufferLen, xmlNodePtr invokingNode, - const xmlChar *sourceTargetNamespace, - const xmlChar *importNamespace, + const xmlChar *sourceTargetNamespace, + const xmlChar *importNamespace, xmlSchemaBucketPtr *bucket) { const xmlChar *targetNamespace = NULL; @@ -10279,7 +10300,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, if (bucket != NULL) *bucket = NULL; - + switch (type) { case XML_SCHEMA_SCHEMA_IMPORT: case XML_SCHEMA_SCHEMA_MAIN: @@ -10291,23 +10312,23 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, case XML_SCHEMA_SCHEMA_REDEFINE: err = XML_SCHEMAP_SRC_REDEFINE; break; - } - + } + /* Special handling for the main schema: * skip the location and relation logic and just parse the doc. * We need just a bucket to be returned in this case. - */ + */ if ((type == XML_SCHEMA_SCHEMA_MAIN) || (! WXS_HAS_BUCKETS(pctxt))) - goto doc_load; + goto doc_load; - /* Note that we expect the location to be an absulute URI. */ + /* Note that we expect the location to be an absulute URI. */ if (schemaLocation != NULL) { bkt = xmlSchemaGetSchemaBucket(pctxt, schemaLocation); if ((bkt != NULL) && (pctxt->constructor->bucket == bkt)) { /* Report self-imports/inclusions/redefinitions. */ - + xmlSchemaCustomErr(ACTXT_CAST pctxt, err, invokingNode, NULL, "The schema must not import/include/redefine itself", @@ -10320,7 +10341,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, */ relation = xmlSchemaSchemaRelationCreate(); if (relation == NULL) - return(-1); + return(-1); xmlSchemaSchemaRelationAddChild(pctxt->constructor->bucket, relation); relation->type = type; @@ -10329,7 +10350,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, * Save the namespace import information. */ if (WXS_IS_BUCKET_IMPMAIN(type)) { - relation->importNamespace = importNamespace; + relation->importNamespace = importNamespace; if (schemaLocation == NULL) { /* * No location; this is just an import of the namespace. @@ -10342,32 +10363,48 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, } /* Did we already fetch the doc? */ - if (bkt != NULL) { - /* TODO: The following nasty cases will produce an error. */ + if (bkt != NULL) { if ((WXS_IS_BUCKET_IMPMAIN(type)) && (! bkt->imported)) { - /* We included/redefined and then try to import a schema. */ - xmlSchemaCustomErr(ACTXT_CAST pctxt, err, - invokingNode, NULL, - "The schema document '%s' cannot be imported, since " - "it was already included or redefined", - schemaLocation, NULL); - goto exit; + /* + * We included/redefined and then try to import a schema, + * but the new location provided for import was different. + */ + if (schemaLocation == NULL) + schemaLocation = BAD_CAST "in_memory_buffer"; + if (!xmlStrEqual(schemaLocation, + bkt->schemaLocation)) { + xmlSchemaCustomErr(ACTXT_CAST pctxt, err, + invokingNode, NULL, + "The schema document '%s' cannot be imported, since " + "it was already included or redefined", + schemaLocation, NULL); + goto exit; + } } else if ((! WXS_IS_BUCKET_IMPMAIN(type)) && (bkt->imported)) { - /* We imported and then try to include/redefine a schema. */ - xmlSchemaCustomErr(ACTXT_CAST pctxt, err, - invokingNode, NULL, - "The schema document '%s' cannot be included or " - "redefined, since it was already imported", - schemaLocation, NULL); - goto exit; - } + /* + * We imported and then try to include/redefine a schema, + * but the new location provided for the include/redefine + * was different. + */ + if (schemaLocation == NULL) + schemaLocation = BAD_CAST "in_memory_buffer"; + if (!xmlStrEqual(schemaLocation, + bkt->schemaLocation)) { + xmlSchemaCustomErr(ACTXT_CAST pctxt, err, + invokingNode, NULL, + "The schema document '%s' cannot be included or " + "redefined, since it was already imported", + schemaLocation, NULL); + goto exit; + } + } } - + if (WXS_IS_BUCKET_IMPMAIN(type)) { /* * Given that the schemaLocation [attribute] is only a hint, it is open * to applications to ignore all but the first <import> for a given - * namespace, regardless of the ·actual value· of schemaLocation, but + * namespace, regardless of the `actual value` of schemaLocation, but * such a strategy risks missing useful information when new * schemaLocations are offered. * @@ -10383,7 +10420,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, * 5 Attempt to resolve the namespace name to locate such a resource. * * NOTE: (3) and (5) are not supported. - */ + */ if (bkt != NULL) { relation->bucket = bkt; goto exit; @@ -10391,7 +10428,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, bkt = xmlSchemaGetSchemaBucketByTNS(pctxt, importNamespace, 1); - if (bkt != NULL) { + if (bkt != NULL) { relation->bucket = bkt; if (bkt->schemaLocation == NULL) { /* First given location of the schema; load the doc. */ @@ -10404,6 +10441,9 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, * URGENT TODO: We should report a warning here. * res = XML_SCHEMAP_SRC_IMPORT; */ + if (schemaLocation == NULL) + schemaLocation = BAD_CAST "in_memory_buffer"; + xmlSchemaCustomWarning(ACTXT_CAST pctxt, XML_SCHEMAP_WARN_SKIP_SCHEMA, invokingNode, NULL, @@ -10414,19 +10454,19 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, } goto exit; } - } - /* + } + /* * No bucket + first location: load the doc and create a * bucket. */ } else { /* <include> and <redefine> */ if (bkt != NULL) { - + if ((bkt->origTargetNamespace == NULL) && (bkt->targetNamespace != sourceTargetNamespace)) { xmlSchemaBucketPtr chamel; - + /* * Chameleon include/redefine: skip loading only if it was * aleady build for the targetNamespace of the including @@ -10451,7 +10491,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, relation->bucket = chamel; goto exit; } - /* + /* * We need to parse the chameleon again for a different * targetNamespace. * CHAMELEON TODO: Optimize this by only parsing the @@ -10462,7 +10502,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt, } else { relation->bucket = bkt; goto exit; - } + } } } if ((bkt != NULL) && (bkt->doc != NULL)) { @@ -10484,7 +10524,8 @@ doc_load: if (schemaDoc->URL != NULL) schemaLocation = xmlDictLookup(pctxt->dict, schemaDoc->URL, -1); - + else + schemaLocation = BAD_CAST "in_memory_buffer"; } else if ((schemaLocation != NULL) || (schemaBuffer != NULL)) { xmlParserCtxtPtr parserCtxt; @@ -10511,9 +10552,9 @@ doc_load: /* Parse from memory buffer. */ doc = xmlCtxtReadMemory(parserCtxt, schemaBuffer, schemaBufferLen, NULL, NULL, SCHEMAS_PARSE_OPTIONS); - schemaLocation = xmlStrdup(BAD_CAST "in_memory_buffer"); + schemaLocation = BAD_CAST "in_memory_buffer"; if (doc != NULL) - doc->URL = schemaLocation; + doc->URL = xmlStrdup(schemaLocation); } /* * For <import>: @@ -10547,7 +10588,7 @@ doc_load: xmlSchemaCustomErr(ACTXT_CAST pctxt, res, invokingNode, NULL, "Failed to parse the XML resource '%s'", - schemaLocation, NULL); + schemaLocation, NULL); } } xmlFreeParserCtxt(parserCtxt); @@ -10567,11 +10608,11 @@ doc_load: if (doc != NULL) { xmlNodePtr docElem = NULL; - located = 1; + located = 1; docElem = xmlDocGetRootElement(doc); if (docElem == NULL) { xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_NOROOT, - invokingNode, NULL, + invokingNode, NULL, "The document '%s' has no document element", schemaLocation, NULL); goto exit_error; @@ -10590,14 +10631,14 @@ doc_load: schemaLocation, NULL); goto exit_error; } - /* + /* * Note that we don't apply a type check for the * targetNamespace value here. */ targetNamespace = xmlSchemaGetProp(pctxt, docElem, "targetNamespace"); } - + /* after_doc_loading: */ if ((bkt == NULL) && located) { /* Only create a bucket if the schema was located. */ @@ -10624,14 +10665,14 @@ doc_load: if (relation != NULL) relation->bucket = bkt; } - + exit: /* * Return the bucket explicitely; this is needed for the * main schema. */ if (bucket != NULL) - *bucket = bkt; + *bucket = bkt; return (0); exit_error: @@ -10647,7 +10688,7 @@ exit_failure: xmlFreeDoc(doc); if (bkt != NULL) bkt->doc = NULL; - } + } return (-1); } @@ -10716,7 +10757,7 @@ xmlSchemaParseImport(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema, XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, NULL, node, xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYURI), - NULL, namespaceName, NULL, NULL, NULL); + NULL, schemaLocation, NULL, NULL, NULL); return (pctxt->err); } /* @@ -10747,8 +10788,8 @@ xmlSchemaParseImport(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema, thisTargetNamespace = WXS_BUCKET(pctxt)->origTargetNamespace; if (namespaceName != NULL) { /* - * 1.1 If the namespace [attribute] is present, then its ·actual value· - * must not match the ·actual value· of the enclosing <schema>'s + * 1.1 If the namespace [attribute] is present, then its `actual value` + * must not match the `actual value` of the enclosing <schema>'s * targetNamespace [attribute]. */ if (xmlStrEqual(thisTargetNamespace, namespaceName)) { @@ -10802,11 +10843,11 @@ xmlSchemaParseImport(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema, "Failed to locate a schema at location '%s'. " "Skipping the import", schemaLocation, NULL, NULL); } - - if ((bucket != NULL) && CAN_PARSE_SCHEMA(bucket)) { + + if ((bucket != NULL) && CAN_PARSE_SCHEMA(bucket)) { ret = xmlSchemaParseNewDoc(pctxt, schema, bucket); } - + return (ret); } @@ -10888,7 +10929,7 @@ xmlSchemaParseIncludeOrRedefineAttrs(xmlSchemaParserCtxtPtr pctxt, XML_SCHEMAP_SRC_REDEFINE, NULL, node, "The schema document '%s' cannot redefine itself.", - *schemaLocation); + *schemaLocation); } else { xmlSchemaPCustomErr(pctxt, XML_SCHEMAP_SRC_INCLUDE, @@ -10898,7 +10939,7 @@ xmlSchemaParseIncludeOrRedefineAttrs(xmlSchemaParserCtxtPtr pctxt, } goto exit_error; } - + return(0); exit_error: return(pctxt->err); @@ -10928,19 +10969,19 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, res = xmlSchemaParseIncludeOrRedefineAttrs(pctxt, schema, node, (xmlChar **) (&schemaLocation), type); if (res != 0) - return(res); + return(res); /* * Load and add the schema document. */ res = xmlSchemaAddSchemaDoc(pctxt, type, schemaLocation, NULL, NULL, 0, node, pctxt->targetNamespace, NULL, &bucket); if (res != 0) - return(res); + return(res); /* * If we get no schema bucket back, then this means that the schema * document could not be located or was broken XML or was not * a schema document. - */ + */ if ((bucket == NULL) || (bucket->doc == NULL)) { if (type == XML_SCHEMA_SCHEMA_INCLUDE) { /* @@ -10949,7 +10990,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, * for inclusions, since the that was the feedback from the * schema people. I.e. the following spec piece will *not* be * satisfied: - * SPEC src-include: "It is not an error for the ·actual value· of the + * SPEC src-include: "It is not an error for the `actual value` of the * schemaLocation [attribute] to fail to resolve it all, in which * case no corresponding inclusion is performed. * So do we need a warning report here?" @@ -10966,7 +11007,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, * * SPEC src-redefine (1) * "If there are any element information items among the [children] - * other than <annotation> then the ·actual value· of the + * other than <annotation> then the `actual value` of the * schemaLocation [attribute] must successfully resolve." * TODO: Ask the WG if a the location has always to resolve * here as well! @@ -10982,13 +11023,13 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, * Check targetNamespace sanity before parsing the new schema. * TODO: Note that we won't check further content if the * targetNamespace was bad. - */ - if (bucket->origTargetNamespace != NULL) { + */ + if (bucket->origTargetNamespace != NULL) { /* * SPEC src-include (2.1) - * "SII has a targetNamespace [attribute], and its ·actual - * value· is identical to the ·actual value· of the targetNamespace - * [attribute] of SII’ (which must have such an [attribute])." + * "SII has a targetNamespace [attribute], and its `actual + * value` is identical to the `actual value` of the targetNamespace + * [attribute] of SII' (which must have such an [attribute])." */ if (pctxt->targetNamespace == NULL) { xmlSchemaCustomErr(ACTXT_CAST pctxt, @@ -11012,28 +11053,29 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, pctxt->targetNamespace); goto exit_error; } - } else if (pctxt->targetNamespace != NULL) { + } else if (pctxt->targetNamespace != NULL) { /* * Chameleons: the original target namespace will * differ from the resulting namespace. */ isChameleon = 1; if (bucket->parsed && - (bucket->targetNamespace != pctxt->targetNamespace)) { - /* - * This is a sanity check, I dunno yet if this can happen. - */ - PERROR_INT("xmlSchemaParseIncludeOrRedefine", - "trying to use an already parsed schema for a " - "different targetNamespace"); - return(-1); + bucket->origTargetNamespace != NULL) { + xmlSchemaCustomErr(ACTXT_CAST pctxt, + XML_SCHEMAP_SRC_INCLUDE, + node, NULL, + "The target namespace of the included/redefined schema " + "'%s' has to be absent or the same as the " + "including/redefining schema's target namespace", + schemaLocation, NULL); + goto exit_error; } bucket->targetNamespace = pctxt->targetNamespace; } - } + } /* * Parse the schema. - */ + */ if (bucket && (!bucket->parsed) && (bucket->doc != NULL)) { if (isChameleon) { /* TODO: Get rid of this flag on the schema itself. */ @@ -11050,8 +11092,8 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, /* * And now for the children... */ - child = node->children; - if (type == XML_SCHEMA_SCHEMA_REDEFINE) { + child = node->children; + if (type == XML_SCHEMA_SCHEMA_REDEFINE) { /* * Parse (simpleType | complexType | group | attributeGroup))* */ @@ -11074,7 +11116,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, } else if (IS_SCHEMA(child, "complexType")) { xmlSchemaParseComplexType(pctxt, schema, child, 1); /* hasRedefinitions = 1; */ - } else if (IS_SCHEMA(child, "group")) { + } else if (IS_SCHEMA(child, "group")) { /* hasRedefinitions = 1; */ xmlSchemaParseModelGroupDefinition(pctxt, schema, child); @@ -11094,7 +11136,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, */ child = child->next; } - } + } if (child != NULL) { res = XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED; if (type == XML_SCHEMA_SCHEMA_REDEFINE) { @@ -11105,8 +11147,8 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPContentErr(pctxt, res, NULL, node, child, NULL, "(annotation?)"); - } - } + } + } return(res); exit_error: @@ -11156,7 +11198,7 @@ xmlSchemaParseInclude(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema, * Redefinition Constraints and Semantics (src-redefine) * (6.1), (6.1.1), (6.1.2) * - * Schema Component Constraint: + * Schema Component Constraint: * All Group Limited (cos-all-limited) (2) * TODO: Actually this should go to component-level checks, * but is done here due to performance. Move it to an other layer @@ -11335,8 +11377,8 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, /* * SPEC src-redefine: * (6.1) "If it has a <group> among its contents at - * some level the ·actual value· of whose ref - * [attribute] is the same as the ·actual value· of + * some level the `actual value` of whose ref + * [attribute] is the same as the `actual value` of * its own name attribute plus target namespace, then * all of the following must be true:" * (6.1.1) "It must have exactly one such group." @@ -11361,9 +11403,9 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, xmlChar *str = NULL; /* * SPEC src-redefine: - * (6.1.2) "The ·actual value· of both that + * (6.1.2) "The `actual value` of both that * group's minOccurs and maxOccurs [attribute] - * must be 1 (or ·absent·). + * must be 1 (or `absent`). */ xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_SRC_REDEFINE, child, NULL, @@ -11380,7 +11422,7 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, } ctxt->redef->reference = WXS_BASIC_CAST part; ctxt->redefCounter++; - } + } } } else if (IS_SCHEMA(child, "any")) { part = (xmlSchemaTreeItemPtr) @@ -11417,7 +11459,7 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, WXS_ADD_PENDING(ctxt, item); } if (withParticle) - return ((xmlSchemaTreeItemPtr) particle); + return ((xmlSchemaTreeItemPtr) particle); else return ((xmlSchemaTreeItemPtr) item); } @@ -11469,7 +11511,7 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, */ xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id"); /* - * Attribute + * Attribute */ /* * Extract the base type. The "base" attribute is mandatory if inside @@ -11477,8 +11519,8 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, * * SPEC (1.2) "...otherwise (<restriction> has no <simpleType> " * among its [children]), the simple type definition which is - * the {content type} of the type definition ·resolved· to by - * the ·actual value· of the base [attribute]" + * the {content type} of the type definition `resolved` to by + * the `actual value` of the base [attribute]" */ if (xmlSchemaPValAttrQName(ctxt, schema, NULL, node, "base", &(type->baseNs), &(type->base)) == 0) @@ -11501,8 +11543,8 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, /* * REDEFINE: SPEC src-redefine (5) * "Within the [children], each <simpleType> must have a - * <restriction> among its [children] ... the ·actual value· of - * whose base [attribute] must be the same as the ·actual value· + * <restriction> among its [children] ... the `actual value` of + * whose base [attribute] must be the same as the `actual value` * of its own name attribute plus target namespace;" */ xmlSchemaPCustomErrExt(ctxt, XML_SCHEMAP_SRC_REDEFINE, @@ -11518,7 +11560,7 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, type->base = NULL; type->baseNs = NULL; } - } + } } /* * And now for the children... @@ -11585,7 +11627,7 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, /* * Model group reference <group>. */ - } else if (IS_SCHEMA(child, "group")) { + } else if (IS_SCHEMA(child, "group")) { type->subtypes = (xmlSchemaTypePtr) xmlSchemaParseModelGroupDefRef(ctxt, schema, child); /* @@ -11923,13 +11965,13 @@ xmlSchemaParseSimpleContent(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_MISSING, NULL, node, NULL, NULL, - "(annotation?, (restriction | extension))"); + "(annotation?, (restriction | extension))"); } if (child == NULL) { xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_MISSING, NULL, node, NULL, NULL, - "(annotation?, (restriction | extension))"); + "(annotation?, (restriction | extension))"); } if (IS_SCHEMA(child, "restriction")) { xmlSchemaParseRestriction(ctxt, schema, child, @@ -12086,7 +12128,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, } else if (xmlSchemaPValAttrNode(ctxt, NULL, attr, xmlSchemaGetBuiltInType(XML_SCHEMAS_NCNAME), &name) != 0) { return (NULL); - } + } } if (topLevel == 0) { @@ -12175,7 +12217,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, NULL, (xmlNodePtr) attr, NULL, "(#all | List of (extension | restriction))", attrValue, NULL, NULL, NULL); - } else + } else final = 1; } else if (xmlStrEqual(attr->name, BAD_CAST "block")) { /* @@ -12193,7 +12235,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, NULL, (xmlNodePtr) attr, NULL, "(#all | List of (extension | restriction)) ", attrValue, NULL, NULL, NULL); - } else + } else block = 1; } else { xmlSchemaPIllegalAttrErr(ctxt, @@ -12204,7 +12246,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); } } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { - xmlSchemaPIllegalAttrErr(ctxt, + xmlSchemaPIllegalAttrErr(ctxt, XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); } attr = attr->next; @@ -12263,7 +12305,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, * SPEC * "...the third alternative (neither <simpleContent> nor * <complexContent>) is chosen. This case is understood as shorthand - * for complex content restricting the ·ur-type definition·, and the + * for complex content restricting the `ur-type definition`, and the * details of the mappings should be modified as necessary. */ type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE); @@ -12332,15 +12374,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. */ @@ -12440,7 +12482,7 @@ xmlSchemaNewMemParserCtxt(const char *buffer, int size) return(NULL); ret->buffer = buffer; ret->size = size; - ret->dict = xmlDictCreate(); + ret->dict = xmlDictCreate(); return (ret); } @@ -12483,7 +12525,7 @@ xmlSchemaFreeParserCtxt(xmlSchemaParserCtxtPtr ctxt) if (ctxt == NULL) return; if (ctxt->doc != NULL && !ctxt->preserve) - xmlFreeDoc(ctxt->doc); + xmlFreeDoc(ctxt->doc); if (ctxt->vctxt != NULL) { xmlSchemaFreeValidCtxt(ctxt->vctxt); } @@ -12504,7 +12546,12 @@ xmlSchemaFreeParserCtxt(xmlSchemaParserCtxtPtr ctxt) * * ************************************************************************/ -static void +/** + * xmlSchemaBuildContentModelForSubstGroup: + * + * Returns 1 if nillable, 0 otherwise + */ +static int xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt, xmlSchemaParticlePtr particle, int counter, xmlAutomataStatePtr end) { @@ -12512,6 +12559,7 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt, xmlSchemaElementPtr elemDecl, member; xmlSchemaSubstGroupPtr substGroup; int i; + int ret = 0; elemDecl = (xmlSchemaElementPtr) particle->children; /* @@ -12527,7 +12575,7 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt, "Internal error: xmlSchemaBuildContentModelForSubstGroup, " "declaration is marked having a subst. group but none " "available.\n", elemDecl->name, NULL); - return; + return(0); } if (counter >= 0) { /* @@ -12565,7 +12613,7 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt, * was incorrectly used instead of xmlAutomataNewTransition2() * (seems like a copy&paste bug from the XML_SCHEMA_TYPE_ALL * section in xmlSchemaBuildAContentModel() ). - * TODO: Check if xmlAutomataNewOnceTrans2() was instead + * TODO: Check if xmlAutomataNewOnceTrans2() was instead * intended for the above "counter" section originally. I.e., * check xs:all with subst-groups. * @@ -12574,7 +12622,7 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt, * 1, 1, member); */ tmp = xmlAutomataNewTransition2(pctxt->am, start, NULL, - member->name, member->targetNamespace, member); + member->name, member->targetNamespace, member); xmlAutomataNewEpsilon(pctxt->am, tmp, end); } } else { @@ -12607,21 +12655,31 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt, xmlAutomataNewCountedTrans(pctxt->am, hop, start, counter); xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter); } - if (particle->minOccurs == 0) + if (particle->minOccurs == 0) { xmlAutomataNewEpsilon(pctxt->am, start, end); + ret = 1; + } pctxt->state = end; + return(ret); } -static void +/** + * xmlSchemaBuildContentModelForElement: + * + * Returns 1 if nillable, 0 otherwise + */ +static int xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt, xmlSchemaParticlePtr particle) { + int ret = 0; + if (((xmlSchemaElementPtr) particle->children)->flags & XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) { /* * Substitution groups. */ - xmlSchemaBuildContentModelForSubstGroup(ctxt, particle, -1, NULL); + ret = xmlSchemaBuildContentModelForSubstGroup(ctxt, particle, -1, NULL); } else { xmlSchemaElementPtr elemDecl; xmlAutomataStatePtr start; @@ -12629,7 +12687,7 @@ xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt, elemDecl = (xmlSchemaElementPtr) particle->children; if (elemDecl->flags & XML_SCHEMAS_ELEM_ABSTRACT) - return; + return(0); if (particle->maxOccurs == 1) { start = ctxt->state; ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL, @@ -12637,11 +12695,11 @@ xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt, } else if ((particle->maxOccurs >= UNBOUNDED) && (particle->minOccurs < 2)) { /* Special case. */ - start = ctxt->state; + start = ctxt->state; ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL, - elemDecl->name, elemDecl->targetNamespace, elemDecl); + elemDecl->name, elemDecl->targetNamespace, elemDecl); ctxt->state = xmlAutomataNewTransition2(ctxt->am, ctxt->state, ctxt->state, - elemDecl->name, elemDecl->targetNamespace, elemDecl); + elemDecl->name, elemDecl->targetNamespace, elemDecl); } else { int counter; int maxOccurs = particle->maxOccurs == UNBOUNDED ? @@ -12657,9 +12715,12 @@ xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt, ctxt->state = xmlAutomataNewCounterTrans(ctxt->am, ctxt->state, NULL, counter); } - if (particle->minOccurs == 0) + if (particle->minOccurs == 0) { xmlAutomataNewEpsilon(ctxt->am, start, ctxt->state); + ret = 1; + } } + return(ret); } /** @@ -12670,21 +12731,24 @@ xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt, * * Create the automaton for the {content type} of a complex type. * + * Returns 1 if the content is nillable, 0 otherwise */ -static void +static int xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt, xmlSchemaParticlePtr particle) { + int ret = 0, tmp2; + if (particle == NULL) { - PERROR_INT("xmlSchemaBuildAContentModel", "particle is NULL"); - return; + PERROR_INT("xmlSchemaBuildAContentModel", "particle is NULL"); + return(1); } if (particle->children == NULL) { /* * Just return in this case. A missing "term" of the particle * might arise due to an invalid "term" component. */ - return; + return(1); } switch (particle->children->type) { @@ -12736,7 +12800,8 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt, int counter; xmlAutomataStatePtr hop; int maxOccurs = - particle->maxOccurs == UNBOUNDED ? UNBOUNDED : particle->maxOccurs - 1; + particle->maxOccurs == UNBOUNDED ? UNBOUNDED : + particle->maxOccurs - 1; int minOccurs = particle->minOccurs < 1 ? 0 : particle->minOccurs - 1; @@ -12771,243 +12836,282 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt, } if (particle->minOccurs == 0) { xmlAutomataNewEpsilon(pctxt->am, start, end); + ret = 1; } pctxt->state = end; break; } case XML_SCHEMA_TYPE_ELEMENT: - xmlSchemaBuildContentModelForElement(pctxt, particle); + ret = xmlSchemaBuildContentModelForElement(pctxt, particle); break; case XML_SCHEMA_TYPE_SEQUENCE:{ - xmlSchemaTreeItemPtr sub; + xmlSchemaTreeItemPtr sub; - /* - * If max and min occurances are default (1) then - * simply iterate over the particles of the <sequence>. - */ - if ((particle->minOccurs == 1) && (particle->maxOccurs == 1)) { - sub = particle->children->children; - while (sub != NULL) { - xmlSchemaBuildAContentModel(pctxt, - (xmlSchemaParticlePtr) sub); - sub = sub->next; - } - } else { - xmlAutomataStatePtr oldstate = pctxt->state; - - if (particle->maxOccurs >= UNBOUNDED) { - if (particle->minOccurs > 1) { - xmlAutomataStatePtr tmp; - int counter; - - pctxt->state = xmlAutomataNewEpsilon(pctxt->am, - oldstate, NULL); - oldstate = pctxt->state; + ret = 1; + /* + * If max and min occurances are default (1) then + * simply iterate over the particles of the <sequence>. + */ + if ((particle->minOccurs == 1) && (particle->maxOccurs == 1)) { + sub = particle->children->children; - counter = xmlAutomataNewCounter(pctxt->am, - particle->minOccurs - 1, UNBOUNDED); + while (sub != NULL) { + tmp2 = xmlSchemaBuildAContentModel(pctxt, + (xmlSchemaParticlePtr) sub); + if (tmp2 != 1) ret = 0; + sub = sub->next; + } + } else { + xmlAutomataStatePtr oldstate = pctxt->state; - sub = particle->children->children; - while (sub != NULL) { - xmlSchemaBuildAContentModel(pctxt, - (xmlSchemaParticlePtr) sub); - sub = sub->next; - } - tmp = pctxt->state; - xmlAutomataNewCountedTrans(pctxt->am, tmp, - oldstate, counter); - pctxt->state = - xmlAutomataNewCounterTrans(pctxt->am, tmp, - NULL, counter); - - } else { - pctxt->state = xmlAutomataNewEpsilon(pctxt->am, - oldstate, NULL); - oldstate = pctxt->state; - - sub = particle->children->children; - while (sub != NULL) { - xmlSchemaBuildAContentModel(pctxt, - (xmlSchemaParticlePtr) sub); - sub = sub->next; - } - xmlAutomataNewEpsilon(pctxt->am, pctxt->state, - oldstate); - /* - * 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); - } - } - } else if ((particle->maxOccurs > 1) - || (particle->minOccurs > 1)) { + if (particle->maxOccurs >= UNBOUNDED) { + if (particle->minOccurs > 1) { xmlAutomataStatePtr tmp; int counter; pctxt->state = xmlAutomataNewEpsilon(pctxt->am, - oldstate, NULL); + oldstate, NULL); oldstate = pctxt->state; counter = xmlAutomataNewCounter(pctxt->am, - particle->minOccurs - 1, - particle->maxOccurs - 1); + particle->minOccurs - 1, UNBOUNDED); sub = particle->children->children; while (sub != NULL) { - xmlSchemaBuildAContentModel(pctxt, - (xmlSchemaParticlePtr) sub); + tmp2 = xmlSchemaBuildAContentModel(pctxt, + (xmlSchemaParticlePtr) sub); + if (tmp2 != 1) ret = 0; sub = sub->next; } tmp = pctxt->state; - xmlAutomataNewCountedTrans(pctxt->am, - tmp, oldstate, counter); + xmlAutomataNewCountedTrans(pctxt->am, tmp, + oldstate, counter); pctxt->state = - xmlAutomataNewCounterTrans(pctxt->am, tmp, NULL, - counter); - if (particle->minOccurs == 0) { + xmlAutomataNewCounterTrans(pctxt->am, tmp, + NULL, counter); + if (ret == 1) xmlAutomataNewEpsilon(pctxt->am, - oldstate, pctxt->state); - } + oldstate, pctxt->state); + } else { + pctxt->state = xmlAutomataNewEpsilon(pctxt->am, + oldstate, NULL); + oldstate = pctxt->state; + sub = particle->children->children; while (sub != NULL) { - xmlSchemaBuildAContentModel(pctxt, - (xmlSchemaParticlePtr) sub); + tmp2 = xmlSchemaBuildAContentModel(pctxt, + (xmlSchemaParticlePtr) sub); + if (tmp2 != 1) ret = 0; sub = sub->next; } + xmlAutomataNewEpsilon(pctxt->am, pctxt->state, + oldstate); + /* + * 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); + xmlAutomataNewEpsilon(pctxt->am, + oldstate, pctxt->state); + ret = 1; } } - } - break; - } - case XML_SCHEMA_TYPE_CHOICE:{ - xmlSchemaTreeItemPtr sub; - xmlAutomataStatePtr start, end; + } else if ((particle->maxOccurs > 1) + || (particle->minOccurs > 1)) { + xmlAutomataStatePtr tmp; + int counter; - start = pctxt->state; - end = xmlAutomataNewState(pctxt->am); + pctxt->state = xmlAutomataNewEpsilon(pctxt->am, + oldstate, NULL); + oldstate = pctxt->state; - /* - * iterate over the subtypes and remerge the end with an - * epsilon transition - */ - if (particle->maxOccurs == 1) { - sub = particle->children->children; + counter = xmlAutomataNewCounter(pctxt->am, + particle->minOccurs - 1, + particle->maxOccurs - 1); + + sub = particle->children->children; while (sub != NULL) { - pctxt->state = start; - xmlSchemaBuildAContentModel(pctxt, - (xmlSchemaParticlePtr) sub); - xmlAutomataNewEpsilon(pctxt->am, pctxt->state, end); + tmp2 = xmlSchemaBuildAContentModel(pctxt, + (xmlSchemaParticlePtr) sub); + if (tmp2 != 1) ret = 0; sub = sub->next; } + tmp = pctxt->state; + xmlAutomataNewCountedTrans(pctxt->am, + tmp, oldstate, counter); + pctxt->state = + xmlAutomataNewCounterTrans(pctxt->am, tmp, NULL, + counter); + if ((particle->minOccurs == 0) || (ret == 1)) { + xmlAutomataNewEpsilon(pctxt->am, + oldstate, pctxt->state); + ret = 1; + } } else { - int counter; - xmlAutomataStatePtr hop, base; - int maxOccurs = particle->maxOccurs == UNBOUNDED ? - UNBOUNDED : particle->maxOccurs - 1; - int minOccurs = - particle->minOccurs < 1 ? 0 : particle->minOccurs - 1; - - /* - * use a counter to keep track of the number of transtions - * which went through the choice. - */ - counter = - xmlAutomataNewCounter(pctxt->am, minOccurs, maxOccurs); - hop = xmlAutomataNewState(pctxt->am); - base = xmlAutomataNewState(pctxt->am); - - sub = particle->children->children; + sub = particle->children->children; while (sub != NULL) { - pctxt->state = base; - xmlSchemaBuildAContentModel(pctxt, - (xmlSchemaParticlePtr) sub); - xmlAutomataNewEpsilon(pctxt->am, pctxt->state, hop); + tmp2 = xmlSchemaBuildAContentModel(pctxt, + (xmlSchemaParticlePtr) sub); + if (tmp2 != 1) ret = 0; sub = sub->next; } - xmlAutomataNewEpsilon(pctxt->am, start, base); - xmlAutomataNewCountedTrans(pctxt->am, hop, base, counter); - xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter); - } - if (particle->minOccurs == 0) { - xmlAutomataNewEpsilon(pctxt->am, start, end); + + /* + * 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); + ret = 1; + } } - pctxt->state = end; - break; } - case XML_SCHEMA_TYPE_ALL:{ - xmlAutomataStatePtr start; - xmlSchemaParticlePtr sub; - xmlSchemaElementPtr elemDecl; - int lax; - - sub = (xmlSchemaParticlePtr) particle->children->children; - if (sub == NULL) - break; - start = pctxt->state; + break; + } + case XML_SCHEMA_TYPE_CHOICE:{ + xmlSchemaTreeItemPtr sub; + xmlAutomataStatePtr start, end; + + ret = 0; + start = pctxt->state; + end = xmlAutomataNewState(pctxt->am); + + /* + * iterate over the subtypes and remerge the end with an + * epsilon transition + */ + if (particle->maxOccurs == 1) { + sub = particle->children->children; while (sub != NULL) { pctxt->state = start; + tmp2 = xmlSchemaBuildAContentModel(pctxt, + (xmlSchemaParticlePtr) sub); + if (tmp2 == 1) ret = 1; + xmlAutomataNewEpsilon(pctxt->am, pctxt->state, end); + sub = sub->next; + } + } else { + int counter; + xmlAutomataStatePtr hop, base; + int maxOccurs = particle->maxOccurs == UNBOUNDED ? + UNBOUNDED : particle->maxOccurs - 1; + int minOccurs = + particle->minOccurs < 1 ? 0 : particle->minOccurs - 1; - elemDecl = (xmlSchemaElementPtr) sub->children; - if (elemDecl == NULL) { - PERROR_INT("xmlSchemaBuildAContentModel", - "<element> particle has no term"); - return; - }; - /* - * NOTE: The {max occurs} of all the particles in the - * {particles} of the group must be 0 or 1; this is - * already ensured during the parse of the content of - * <all>. - */ - if (elemDecl->flags & XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) { - int counter; - - /* - * This is an abstract group, we need to share - * the same counter for all the element transitions - * derived from the group - */ - counter = xmlAutomataNewCounter(pctxt->am, - sub->minOccurs, sub->maxOccurs); - xmlSchemaBuildContentModelForSubstGroup(pctxt, - sub, counter, pctxt->state); - } else { - if ((sub->minOccurs == 1) && - (sub->maxOccurs == 1)) { - xmlAutomataNewOnceTrans2(pctxt->am, pctxt->state, - pctxt->state, - elemDecl->name, - elemDecl->targetNamespace, - 1, 1, elemDecl); - } else if ((sub->minOccurs == 0) && - (sub->maxOccurs == 1)) { - - xmlAutomataNewCountTrans2(pctxt->am, pctxt->state, - pctxt->state, - elemDecl->name, - elemDecl->targetNamespace, - 0, - 1, - elemDecl); - } - } - sub = (xmlSchemaParticlePtr) sub->next; + /* + * use a counter to keep track of the number of transtions + * which went through the choice. + */ + counter = + xmlAutomataNewCounter(pctxt->am, minOccurs, maxOccurs); + hop = xmlAutomataNewState(pctxt->am); + base = xmlAutomataNewState(pctxt->am); + + sub = particle->children->children; + while (sub != NULL) { + pctxt->state = base; + tmp2 = xmlSchemaBuildAContentModel(pctxt, + (xmlSchemaParticlePtr) sub); + if (tmp2 == 1) ret = 1; + xmlAutomataNewEpsilon(pctxt->am, pctxt->state, hop); + sub = sub->next; } - lax = particle->minOccurs == 0; - pctxt->state = - xmlAutomataNewAllTrans(pctxt->am, pctxt->state, NULL, lax); + xmlAutomataNewEpsilon(pctxt->am, start, base); + xmlAutomataNewCountedTrans(pctxt->am, hop, base, counter); + xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter); + if (ret == 1) + xmlAutomataNewEpsilon(pctxt->am, base, end); + } + if (particle->minOccurs == 0) { + xmlAutomataNewEpsilon(pctxt->am, start, end); + ret = 1; + } + pctxt->state = end; + break; + } + case XML_SCHEMA_TYPE_ALL:{ + xmlAutomataStatePtr start, tmp; + xmlSchemaParticlePtr sub; + xmlSchemaElementPtr elemDecl; + + ret = 1; + + sub = (xmlSchemaParticlePtr) particle->children->children; + if (sub == NULL) break; + + ret = 0; + + start = pctxt->state; + tmp = xmlAutomataNewState(pctxt->am); + xmlAutomataNewEpsilon(pctxt->am, pctxt->state, tmp); + pctxt->state = tmp; + while (sub != NULL) { + pctxt->state = tmp; + + elemDecl = (xmlSchemaElementPtr) sub->children; + if (elemDecl == NULL) { + PERROR_INT("xmlSchemaBuildAContentModel", + "<element> particle has no term"); + return(ret); + }; + /* + * NOTE: The {max occurs} of all the particles in the + * {particles} of the group must be 0 or 1; this is + * already ensured during the parse of the content of + * <all>. + */ + if (elemDecl->flags & XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) { + int counter; + + /* + * This is an abstract group, we need to share + * the same counter for all the element transitions + * derived from the group + */ + counter = xmlAutomataNewCounter(pctxt->am, + sub->minOccurs, sub->maxOccurs); + xmlSchemaBuildContentModelForSubstGroup(pctxt, + sub, counter, pctxt->state); + } else { + if ((sub->minOccurs == 1) && + (sub->maxOccurs == 1)) { + xmlAutomataNewOnceTrans2(pctxt->am, pctxt->state, + pctxt->state, + elemDecl->name, + elemDecl->targetNamespace, + 1, 1, elemDecl); + } else if ((sub->minOccurs == 0) && + (sub->maxOccurs == 1)) { + + xmlAutomataNewCountTrans2(pctxt->am, pctxt->state, + pctxt->state, + elemDecl->name, + elemDecl->targetNamespace, + 0, + 1, + elemDecl); + } + } + sub = (xmlSchemaParticlePtr) sub->next; + } + pctxt->state = + xmlAutomataNewAllTrans(pctxt->am, pctxt->state, NULL, 0); + if (particle->minOccurs == 0) { + xmlAutomataNewEpsilon(pctxt->am, start, pctxt->state); + ret = 1; } + break; + } case XML_SCHEMA_TYPE_GROUP: /* * If we hit a model group definition, then this means that @@ -13016,14 +13120,16 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt, * TODO: But the group should be substituted and not occur at * all in the content model at this point. Fix this. */ + ret = 1; break; default: xmlSchemaInternalErr2(ACTXT_CAST pctxt, "xmlSchemaBuildAContentModel", "found unexpected term of type '%s' in content model", WXS_ITEM_TYPE_NAME(particle->children), NULL); - return; + return(ret); } + return(ret); } /** @@ -13107,8 +13213,8 @@ xmlSchemaResolveElementReferences(xmlSchemaElementPtr elemDecl, if ((elemDecl->subtypes == NULL) && (elemDecl->namedType != NULL)) { xmlSchemaTypePtr type; - /* (type definition) ... otherwise the type definition ·resolved· - * to by the ·actual value· of the type [attribute] ... + /* (type definition) ... otherwise the type definition `resolved` + * to by the `actual value` of the type [attribute] ... */ type = xmlSchemaGetType(ctxt->schema, elemDecl->namedType, elemDecl->namedTypeNs); @@ -13146,7 +13252,7 @@ xmlSchemaResolveElementReferences(xmlSchemaElementPtr elemDecl, /* * The type definitions is set to: * SPEC "...the {type definition} of the element - * declaration ·resolved· to by the ·actual value· + * declaration `resolved` to by the `actual value` * of the substitutionGroup [attribute], if present" */ if (elemDecl->subtypes == NULL) @@ -13184,8 +13290,8 @@ xmlSchemaResolveUnionMemberTypes(xmlSchemaParserCtxtPtr ctxt, /* * SPEC (1) "If the <union> alternative is chosen, then [Definition:] - * define the explicit members as the type definitions ·resolved· - * to by the items in the ·actual value· of the memberTypes [attribute], + * define the explicit members as the type definitions `resolved` + * to by the items in the `actual value` of the memberTypes [attribute], * if any, followed by the type definitions corresponding to the * <simpleType>s among the [children] of <union>, if any." */ @@ -13298,7 +13404,6 @@ xmlSchemaIsUserDerivedFromBuiltInType(xmlSchemaTypePtr type, int valType) return (0); } -#endif static xmlSchemaTypePtr xmlSchemaQueryBuiltInType(xmlSchemaTypePtr type) @@ -13311,6 +13416,7 @@ xmlSchemaQueryBuiltInType(xmlSchemaTypePtr type) return(type); return(xmlSchemaQueryBuiltInType(type->subtypes)); } +#endif /** * xmlSchemaGetPrimitiveType: @@ -13480,7 +13586,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt, return (0); } /* - * 3 If both O1 and O2 are sets of (namespace names or ·absent·), + * 3 If both O1 and O2 are sets of (namespace names or `absent`), * then the union of those sets must be the value. */ if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) { @@ -13514,7 +13620,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt, } /* * 4 If the two are negations of different values (namespace names - * or ·absent·), then a pair of not and ·absent· must be the value. + * or `absent`), then a pair of not and `absent` must be the value. */ if ((completeWild->negNsSet != NULL) && (curWild->negNsSet != NULL) && @@ -13556,7 +13662,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt, if (nsFound && absentFound) { /* * 5.1 If the set S includes both the negated namespace - * name and ·absent·, then any must be the value. + * name and `absent`, then any must be the value. */ completeWild->any = 1; if (completeWild->nsSet != NULL) { @@ -13570,7 +13676,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt, } else if (nsFound && (!absentFound)) { /* * 5.2 If the set S includes the negated namespace name - * but not ·absent·, then a pair of not and ·absent· must + * but not `absent`, then a pair of not and `absent` must * be the value. */ if (completeWild->nsSet != NULL) { @@ -13585,7 +13691,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt, completeWild->negNsSet->value = NULL; } else if ((!nsFound) && absentFound) { /* - * 5.3 If the set S includes ·absent· but not the negated + * 5.3 If the set S includes `absent` but not the negated * namespace name, then the union is not expressible. */ xmlSchemaPErr(ctxt, completeWild->node, @@ -13596,7 +13702,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt, } else if ((!nsFound) && (!absentFound)) { /* * 5.4 If the set S does not include either the negated namespace - * name or ·absent·, then whichever of O1 or O2 is a pair of not + * name or `absent`, then whichever of O1 or O2 is a pair of not * and a namespace name must be the value. */ if (completeWild->negNsSet == NULL) { @@ -13630,7 +13736,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt, while (cur != NULL) { if (cur->value == NULL) { /* - * 6.1 If the set S includes ·absent·, then any must be the + * 6.1 If the set S includes `absent`, then any must be the * value. */ completeWild->any = 1; @@ -13648,8 +13754,8 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt, } if (completeWild->negNsSet == NULL) { /* - * 6.2 If the set S does not include ·absent·, then a pair of not - * and ·absent· must be the value. + * 6.2 If the set S does not include `absent`, then a pair of not + * and `absent` must be the value. */ if (completeWild->nsSet != NULL) { xmlSchemaFreeWildcardNsSet(completeWild->nsSet); @@ -13732,9 +13838,9 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt, } /* * 3 If either O1 or O2 is a pair of not and a value (a namespace - * name or ·absent·) and the other is a set of (namespace names or - * ·absent·), then that set, minus the negated value if it was in - * the set, minus ·absent· if it was in the set, must be the value. + * name or `absent`) and the other is a set of (namespace names or + * `absent`), then that set, minus the negated value if it was in + * the set, minus `absent` if it was in the set, must be the value. */ if (((completeWild->negNsSet != NULL) && (curWild->nsSet != NULL)) || ((curWild->negNsSet != NULL) && (completeWild->nsSet != NULL))) { @@ -13783,7 +13889,7 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt, return(0); } /* - * 4 If both O1 and O2 are sets of (namespace names or ·absent·), + * 4 If both O1 and O2 are sets of (namespace names or `absent`), * then the intersection of those sets must be the value. */ if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) { @@ -13833,7 +13939,7 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt, } /* * 6 If the one is a negation of a namespace name and the other - * is a negation of ·absent·, then the one which is the negation + * is a negation of `absent`, then the one which is the negation * of a namespace name must be the value. */ if ((completeWild->negNsSet != NULL) && (curWild->negNsSet != NULL) && @@ -13865,15 +13971,15 @@ xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub, if (super->any) return (0); /* - * 2.1 sub must be a pair of not and a namespace name or ·absent·. + * 2.1 sub must be a pair of not and a namespace name or `absent`. * 2.2 super must be a pair of not and the same value. */ if ((sub->negNsSet != NULL) && (super->negNsSet != NULL) && - (sub->negNsSet->value == sub->negNsSet->value)) + (sub->negNsSet->value == super->negNsSet->value)) return (0); /* - * 3.1 sub must be a set whose members are either namespace names or ·absent·. + * 3.1 sub must be a set whose members are either namespace names or `absent`. */ if (sub->nsSet != NULL) { /* @@ -13904,7 +14010,7 @@ xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub, xmlSchemaWildcardNsPtr cur; /* * 3.2.2 super must be a pair of not and a namespace name or - * ·absent· and that value must not be in sub's set. + * `absent` and that value must not be in sub's set. */ cur = sub->nsSet; while (cur != NULL) { @@ -13929,7 +14035,7 @@ xmlSchemaGetEffectiveValueConstraint(xmlSchemaAttributeUsePtr attruse, if (val != 0) *val = NULL; - if (attruse->defValue != NULL) { + if (attruse->defValue != NULL) { *value = attruse->defValue; if (val != NULL) *val = attruse->defVal; @@ -14009,12 +14115,12 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt, xmlSchemaItemListPtr baseUses, xmlSchemaWildcardPtr wild, xmlSchemaWildcardPtr baseWild) -{ +{ xmlSchemaAttributeUsePtr cur = NULL, bcur; int i, j, found; /* err = 0; */ const xmlChar *bEffValue; int effFixed; - + if (uses != NULL) { for (i = 0; i < uses->nbItems; i++) { cur = uses->items[i]; @@ -14022,7 +14128,7 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt, if (baseUses == NULL) goto not_found; for (j = 0; j < baseUses->nbItems; j++) { - bcur = baseUses->items[j]; + bcur = baseUses->items[j]; if ((WXS_ATTRUSE_DECL_NAME(cur) == WXS_ATTRUSE_DECL_NAME(bcur)) && (WXS_ATTRUSE_DECL_TNS(cur) == @@ -14035,7 +14141,7 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt, * namespace}, then all of the following must be true:" */ found = 1; - + if ((cur->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) && (bcur->occurs == XML_SCHEMAS_ATTR_USE_REQUIRED)) { @@ -14061,12 +14167,12 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt, WXS_ATTRUSE_TYPEDEF(bcur), 0) != 0) { xmlChar *strA = NULL, *strB = NULL, *strC = NULL; - + /* * SPEC (2.1.2) "R's {attribute declaration}'s * {type definition} must be validly derived from * B's {type definition} given the empty set as - * defined in Type Derivation OK (Simple) (§3.14.6)." + * defined in Type Derivation OK (Simple) ($3.14.6)." */ xmlSchemaPAttrUseErr4(pctxt, XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, @@ -14098,17 +14204,17 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt, /* * 2.1.3 ... one of the following must be true * - * 2.1.3.1 B's ·effective value constraint· is - * ·absent· or default. + * 2.1.3.1 B's `effective value constraint` is + * `absent` or default. */ if ((bEffValue != NULL) && (effFixed == 1)) { const xmlChar *rEffValue = NULL; - + xmlSchemaGetEffectiveValueConstraint(bcur, &effFixed, &rEffValue, NULL); /* - * 2.1.3.2 R's ·effective value constraint· is + * 2.1.3.2 R's `effective value constraint` is * fixed with the same string as B's. * MAYBE TODO: Compare the computed values. * Hmm, it says "same string" so @@ -14118,7 +14224,7 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt, (! WXS_ARE_DEFAULT_STR_EQUAL(rEffValue, bEffValue))) { xmlChar *str = NULL; - + xmlSchemaPAttrUseErr4(pctxt, XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, WXS_ITEM_NODE(item), item, cur, @@ -14137,21 +14243,21 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt, break; } } -not_found: +not_found: if (!found) { /* * (2.2) "otherwise the {base type definition} must have an * {attribute wildcard} and the {target namespace} of the - * R's {attribute declaration} must be ·valid· with respect + * R's {attribute declaration} must be `valid` with respect * to that wildcard, as defined in Wildcard allows Namespace - * Name (§3.10.4)." + * Name ($3.10.4)." */ if ((baseWild == NULL) || (xmlSchemaCheckCVCWildcardNamespace(baseWild, (WXS_ATTRUSE_DECL(cur))->targetNamespace) != 0)) { xmlChar *str = NULL; - + xmlSchemaPAttrUseErr4(pctxt, XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, WXS_ITEM_NODE(item), item, cur, @@ -14167,7 +14273,7 @@ not_found: } } /* - * SPEC derivation-ok-restriction (3): + * SPEC derivation-ok-restriction (3): * (3) "For each attribute use in the {attribute uses} of the {base type * definition} whose {required} is true, there must be an attribute * use with an {attribute declaration} with the same {name} and @@ -14182,7 +14288,7 @@ not_found: found = 0; if (uses != NULL) { for (i = 0; i < uses->nbItems; i++) { - cur = uses->items[i]; + cur = uses->items[i]; if ((WXS_ATTRUSE_DECL_NAME(cur) == WXS_ATTRUSE_DECL_NAME(bcur)) && (WXS_ATTRUSE_DECL_TNS(cur) == @@ -14194,7 +14300,7 @@ not_found: } if (!found) { xmlChar *strA = NULL, *strB = NULL; - + xmlSchemaCustomErr4(ACTXT_CAST pctxt, XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, NULL, item, @@ -14216,19 +14322,19 @@ not_found: /* * (4) "If there is an {attribute wildcard}, all of the * following must be true:" - */ + */ if (baseWild == NULL) { xmlChar *str = NULL; /* * (4.1) "The {base type definition} must also have one." - */ + */ xmlSchemaCustomErr4(ACTXT_CAST pctxt, XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, NULL, item, "The %s has an attribute wildcard, " "but the %s %s '%s' does not have one", - WXS_ITEM_TYPE_NAME(item), + WXS_ITEM_TYPE_NAME(item), WXS_ACTION_STR(action), WXS_ITEM_TYPE_NAME(baseItem), xmlSchemaGetComponentQName(&str, baseItem)); @@ -14242,7 +14348,7 @@ not_found: * (4.2) "The complex type definition's {attribute wildcard}'s * {namespace constraint} must be a subset of the {base type * definition}'s {attribute wildcard}'s {namespace constraint}, - * as defined by Wildcard Subset (§3.10.6)." + * as defined by Wildcard Subset ($3.10.6)." */ xmlSchemaCustomErr4(ACTXT_CAST pctxt, XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, @@ -14256,8 +14362,8 @@ not_found: FREE_AND_NULL(str); return(pctxt->err); } - /* 4.3 Unless the {base type definition} is the ·ur-type - * definition·, the complex type definition's {attribute + /* 4.3 Unless the {base type definition} is the `ur-type + * definition`, the complex type definition's {attribute * wildcard}'s {process contents} must be identical to or * stronger than the {base type definition}'s {attribute * wildcard}'s {process contents}, where strict is stronger @@ -14308,7 +14414,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt, xmlSchemaTypePtr type) { xmlSchemaTypePtr baseType = NULL; - xmlSchemaAttributeUsePtr use; + xmlSchemaAttributeUsePtr use; xmlSchemaItemListPtr uses, baseUses, prohibs = NULL; if (type->baseType == NULL) { @@ -14316,7 +14422,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt, "no base type"); return (-1); } - baseType = type->baseType; + baseType = type->baseType; if (WXS_IS_TYPE_NOT_FIXED(baseType)) if (xmlSchemaTypeFixup(baseType, ACTXT_CAST pctxt) == -1) return(-1); @@ -14328,7 +14434,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt, * wildcard, i.e. intersect multiple wildcards. * Move attribute prohibitions into a separate list. */ - if (uses != NULL) { + if (uses != NULL) { if (WXS_IS_RESTRICTION(type)) { /* * This one will transfer all attr. prohibitions @@ -14362,7 +14468,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt, if (WXS_IS_RESTRICTION(type)) { int usesCount; - xmlSchemaAttributeUsePtr tmp; + xmlSchemaAttributeUsePtr tmp; if (uses != NULL) usesCount = uses->nbItems; @@ -14412,15 +14518,15 @@ inherit_next: {} } } else { /* Extension. */ - for (i = 0; i < baseUses->nbItems; i++) { - use = baseUses->items[i]; + for (i = 0; i < baseUses->nbItems; i++) { + use = baseUses->items[i]; if (uses == NULL) { type->attrUses = xmlSchemaItemListCreate(); if (type->attrUses == NULL) goto exit_failure; uses = type->attrUses; } - xmlSchemaItemListAddSize(uses, baseUses->nbItems, use); + xmlSchemaItemListAddSize(uses, baseUses->nbItems, use); } } } @@ -14440,10 +14546,10 @@ inherit_next: {} /* * Compute the complete wildcard. */ - if (WXS_IS_EXTENSION(type)) { + if (WXS_IS_EXTENSION(type)) { if (baseType->attributeWildcard != NULL) { /* - * (3.2.2.1) "If the ·base wildcard· is non-·absent·, then + * (3.2.2.1) "If the `base wildcard` is non-`absent`, then * the appropriate case among the following:" */ if (type->attributeWildcard != NULL) { @@ -14451,26 +14557,26 @@ inherit_next: {} * Union the complete wildcard with the base wildcard. * SPEC {attribute wildcard} * (3.2.2.1.2) "otherwise a wildcard whose {process contents} - * and {annotation} are those of the ·complete wildcard·, + * and {annotation} are those of the `complete wildcard`, * and whose {namespace constraint} is the intensional union - * of the {namespace constraint} of the ·complete wildcard· - * and of the ·base wildcard·, as defined in Attribute - * Wildcard Union (§3.10.6)." + * of the {namespace constraint} of the `complete wildcard` + * and of the `base wildcard`, as defined in Attribute + * Wildcard Union ($3.10.6)." */ if (xmlSchemaUnionWildcards(pctxt, type->attributeWildcard, baseType->attributeWildcard) == -1) - goto exit_failure; + goto exit_failure; } else { /* - * (3.2.2.1.1) "If the ·complete wildcard· is ·absent·, - * then the ·base wildcard·." + * (3.2.2.1.1) "If the `complete wildcard` is `absent`, + * then the `base wildcard`." */ type->attributeWildcard = baseType->attributeWildcard; - } + } } else { /* - * (3.2.2.2) "otherwise (the ·base wildcard· is ·absent·) the - * ·complete wildcard" + * (3.2.2.2) "otherwise (the `base wildcard` is `absent`) the + * `complete wildcard`" * NOOP */ } @@ -14478,11 +14584,11 @@ inherit_next: {} /* * SPEC {attribute wildcard} * (3.1) "If the <restriction> alternative is chosen, then the - * ·complete wildcard·;" + * `complete wildcard`;" * NOOP */ } - + return (0); exit_failure: @@ -14586,6 +14692,7 @@ xmlSchemaGetParticleTotalRangeMin(xmlSchemaParticlePtr particle) } } +#if 0 /** * xmlSchemaGetParticleTotalRangeMax: * @particle: the particle @@ -14645,6 +14752,7 @@ xmlSchemaGetParticleTotalRangeMax(xmlSchemaParticlePtr particle) return (particle->maxOccurs * sum); } } +#endif /** * xmlSchemaIsParticleEmptiable: @@ -14725,12 +14833,12 @@ xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr actxt, /* 2.2 */ if (type->baseType == baseType) { /* - * 2.2.1 D's ·base type definition· is B. + * 2.2.1 D's `base type definition` is B. */ return (0); } /* - * 2.2.2 D's ·base type definition· is not the ·ur-type definition· + * 2.2.2 D's `base type definition` is not the `ur-type definition` * and is validly derived from B given the subset, as defined by this * constraint. */ @@ -14740,8 +14848,8 @@ xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr actxt, return (0); } /* - * 2.2.3 D's {variety} is list or union and B is the ·simple ur-type - * definition·. + * 2.2.3 D's {variety} is list or union and B is the `simple ur-type + * definition`. */ if (WXS_IS_ANY_SIMPLE_TYPE(baseType) && (WXS_IS_LIST(type) || WXS_IS_UNION(type))) { @@ -14857,10 +14965,10 @@ static int xmlSchemaCheckUnionTypeDefCircularRecur(xmlSchemaParserCtxtPtr pctxt, xmlSchemaTypePtr ctxType, xmlSchemaTypeLinkPtr members) -{ +{ xmlSchemaTypeLinkPtr member; xmlSchemaTypePtr memberType; - + member = members; while (member != NULL) { memberType = member->type; @@ -14961,7 +15069,7 @@ xmlSchemaResolveTypeReferences(xmlSchemaTypePtr typeDef, } return; } - } + } /* * The ball of letters below means, that if we have a particle * which has a QName-helper component as its {term}, we want @@ -15004,7 +15112,7 @@ xmlSchemaResolveTypeReferences(xmlSchemaTypePtr typeDef, * particle's {term}. */ WXS_TYPE_PARTICLE_TERM(typeDef) = WXS_MODELGROUPDEF_MODEL(groupDef); - + if (WXS_MODELGROUPDEF_MODEL(groupDef)->type == XML_SCHEMA_TYPE_ALL) { /* * SPEC cos-all-limited (1.2) @@ -15053,14 +15161,14 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt, * NOTE: This is somehow redundant, since we actually built a simple type * to have all the needed information; this acts as an self test. */ - /* Base type: If the datatype has been ·derived· by ·restriction· - * then the Simple Type Definition component from which it is ·derived·, - * otherwise the Simple Type Definition for anySimpleType (§4.1.6). + /* Base type: If the datatype has been `derived` by `restriction` + * then the Simple Type Definition component from which it is `derived`, + * otherwise the Simple Type Definition for anySimpleType ($4.1.6). */ if (baseType == NULL) { /* * TODO: Think about: "modulo the impact of Missing - * Sub-components (§5.3)." + * Sub-components ($5.3)." */ xmlSchemaPCustomErr(ctxt, XML_SCHEMAP_ST_PROPS_CORRECT_1, @@ -15078,13 +15186,14 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt, FREE_AND_NULL(str) return (XML_SCHEMAP_ST_PROPS_CORRECT_1); } - if ( (WXS_IS_LIST(type) || WXS_IS_UNION(type)) && - (WXS_IS_RESTRICTION(type) == 0) && - (! WXS_IS_ANY_SIMPLE_TYPE(baseType))) { + if ((WXS_IS_LIST(type) || WXS_IS_UNION(type)) && + (WXS_IS_RESTRICTION(type) == 0) && + ((! WXS_IS_ANY_SIMPLE_TYPE(baseType)) && + (baseType->type != XML_SCHEMA_TYPE_SIMPLE))) { xmlSchemaPCustomErr(ctxt, XML_SCHEMAP_ST_PROPS_CORRECT_1, WXS_BASIC_CAST type, NULL, - "A type, derived by list or union, must have" + "A type, derived by list or union, must have " "the simple ur-type definition as base type, not '%s'", xmlSchemaGetComponentQName(&str, baseType)); FREE_AND_NULL(str) @@ -15119,10 +15228,10 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt, } /* - * 2 All simple type definitions must be derived ultimately from the ·simple - * ur-type definition (so· circular definitions are disallowed). That is, it - * must be possible to reach a built-in primitive datatype or the ·simple - * ur-type definition· by repeatedly following the {base type definition}. + * 2 All simple type definitions must be derived ultimately from the `simple + * ur-type definition` (so circular definitions are disallowed). That is, it + * must be possible to reach a built-in primitive datatype or the `simple + * ur-type definition` by repeatedly following the {base type definition}. * * NOTE: this is done in xmlSchemaCheckTypeDefCircular(). */ @@ -15306,10 +15415,10 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt, } /* * MAYBE TODO: (Hmm, not really) Datatypes states: - * A ·list· datatype can be ·derived· from an ·atomic· datatype - * whose ·lexical space· allows space (such as string or anyURI)or - * a ·union· datatype any of whose {member type definitions}'s - * ·lexical space· allows space. + * A `list` datatype can be `derived` from an `atomic` datatype + * whose `lexical space` allows space (such as string or anyURI)or + * a `union` datatype any of whose {member type definitions}'s + * `lexical space` allows space. */ } else { /* @@ -15346,7 +15455,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt, /* * 2.3.2.3 The {item type definition} must be validly derived * from the {base type definition}'s {item type definition} given - * the empty set, as defined in Type Derivation OK (Simple) (§3.14.6). + * the empty set, as defined in Type Derivation OK (Simple) ($3.14.6). */ { xmlSchemaTypePtr baseItemType; @@ -15393,7 +15502,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt, case XML_SCHEMA_FACET_WHITESPACE: /* * TODO: 2.5.1.2 List datatypes - * The value of ·whiteSpace· is fixed to the value collapse. + * The value of `whiteSpace` is fixed to the value collapse. */ case XML_SCHEMA_FACET_PATTERN: case XML_SCHEMA_FACET_ENUMERATION: @@ -15446,8 +15555,8 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt, member = member->next; } /* - * 3.3.1 If the {base type definition} is the ·simple ur-type - * definition· + * 3.3.1 If the {base type definition} is the `simple ur-type + * definition` */ if (type->baseType->builtInType == XML_SCHEMAS_ANYSIMPLETYPE) { /* @@ -15509,7 +15618,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt, * 3.3.2.3 The {member type definitions}, in order, must be validly * derived from the corresponding type definitions in the {base * type definition}'s {member type definitions} given the empty set, - * as defined in Type Derivation OK (Simple) (§3.14.6). + * as defined in Type Derivation OK (Simple) ($3.14.6). */ { xmlSchemaTypeLinkPtr baseMember; @@ -15557,7 +15666,8 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt, return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3); } member = member->next; - baseMember = baseMember->next; + if (baseMember != NULL) + baseMember = baseMember->next; } } } @@ -15601,7 +15711,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt, * @ctxt: the schema parser context * @type: the simple type definition * - * Checks crc-simple-type constraints. + * Checks crc-simple-type constraints. * * Returns 0 if the constraints are satisfied, * if not a positive error code and -1 on internal @@ -15615,8 +15725,8 @@ xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt, /* * src-simple-type.1 The corresponding simple type definition, if any, * must satisfy the conditions set out in Constraints on Simple Type - * Definition Schema Components (§3.14.6). - */ + * Definition Schema Components ($3.14.6). + */ if (WXS_IS_RESTRICTION(type)) { /* * src-simple-type.2 "If the <restriction> alternative is chosen, @@ -15625,7 +15735,7 @@ xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt, * NOTE: This is checked in the parse function of <restriction>. */ /* - * + * */ } else if (WXS_IS_LIST(type)) { /* src-simple-type.3 "If the <list> alternative is chosen, either it must have @@ -15634,8 +15744,8 @@ xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt, * * NOTE: This is checked in the parse function of <list>. */ - } else if (WXS_IS_UNION(type)) { - /* + } else if (WXS_IS_UNION(type)) { + /* * src-simple-type.4 is checked in xmlSchemaCheckUnionTypeDefCircular(). */ } @@ -15713,8 +15823,8 @@ xmlSchemaParseCheckCOSValidDefault(xmlSchemaParserCtxtPtr pctxt, * SPEC (2.1) "its {content type} must be a simple type definition * or mixed." * SPEC (2.2.2) "If the {content type} is mixed, then the {content - * type}'s particle must be ·emptiable· as defined by - * Particle Emptiable (§3.9.6)." + * type}'s particle must be `emptiable` as defined by + * Particle Emptiable ($3.9.6)." */ if ((! WXS_HAS_SIMPLE_CONTENT(type)) && ((! WXS_HAS_MIXED_CONTENT(type)) || (! WXS_EMPTIABLE(type)))) { @@ -15730,14 +15840,14 @@ xmlSchemaParseCheckCOSValidDefault(xmlSchemaParserCtxtPtr pctxt, } /* * 1 If the type definition is a simple type definition, then the string - * must be ·valid· with respect to that definition as defined by String - * Valid (§3.14.4). + * must be `valid` with respect to that definition as defined by String + * Valid ($3.14.4). * * AND * * 2.2.1 If the {content type} is a simple type definition, then the - * string must be ·valid· with respect to that simple type definition - * as defined by String Valid (§3.14.4). + * string must be `valid` with respect to that simple type definition + * as defined by String Valid ($3.14.4). */ if (WXS_IS_SIMPLE(type)) ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, node, @@ -15778,8 +15888,8 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt, * * SPEC (1) "The values of the properties of a complex type definition must * be as described in the property tableau in The Complex Type Definition - * Schema Component (§3.4.1), modulo the impact of Missing - * Sub-components (§5.3)." + * Schema Component ($3.4.1), modulo the impact of Missing + * Sub-components ($5.3)." */ if ((type->baseType != NULL) && (WXS_IS_SIMPLE(type->baseType)) && @@ -15790,15 +15900,15 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt, */ xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_SRC_CT_1, - NULL, WXS_BASIC_CAST type, + NULL, WXS_BASIC_CAST type, "If the base type is a simple type, the derivation method must be " "'extension'", NULL, NULL); return (XML_SCHEMAP_SRC_CT_1); } /* - * SPEC (3) "Circular definitions are disallowed, except for the ·ur-type - * definition·. That is, it must be possible to reach the ·ur-type - * definition by repeatedly following the {base type definition}." + * SPEC (3) "Circular definitions are disallowed, except for the `ur-type + * definition`. That is, it must be possible to reach the `ur-type + * definition` by repeatedly following the {base type definition}." * * NOTE (3) is done in xmlSchemaCheckTypeDefCircular(). */ @@ -15807,7 +15917,7 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt, * - attribute uses need to be already inherited (apply attr. prohibitions) * - attribute group references need to be expanded already * - simple types need to be typefixed already - */ + */ if (type->attrUses && (((xmlSchemaItemListPtr) type->attrUses)->nbItems > 1)) { @@ -15817,8 +15927,8 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt, for (i = uses->nbItems -1; i >= 0; i--) { use = uses->items[i]; - - /* + + /* * SPEC ct-props-correct * (4) "Two distinct attribute declarations in the * {attribute uses} must not have identical {name}s and @@ -15859,10 +15969,10 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt, if (WXS_ATTRUSE_TYPEDEF(use) != NULL) { if (xmlSchemaIsDerivedFromBuiltInType( WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID)) - { + { if (hasId) { xmlChar *str = NULL; - + xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_AG_PROPS_CORRECT, NULL, WXS_BASIC_CAST type, @@ -15876,7 +15986,7 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt, if (xmlSchemaItemListRemove(uses, i) == -1) goto exit_failure; } - + hasId = 1; } } @@ -15950,8 +16060,8 @@ xmlSchemaCheckCOSCTDerivedOK(xmlSchemaAbstractCtxtPtr actxt, if (type->baseType == baseType) return (0); /* - * SPEC (2.3.1) "D's {base type definition} must not be the ·ur-type - * definition·." + * SPEC (2.3.1) "D's {base type definition} must not be the `ur-type + * definition`." */ if (WXS_IS_ANYTYPE(type->baseType)) return (1); @@ -15968,7 +16078,7 @@ xmlSchemaCheckCOSCTDerivedOK(xmlSchemaAbstractCtxtPtr actxt, /* * SPEC (2.3.2.2) "If D's {base type definition} is simple, then it * must be validly derived from B given the subset as defined in Type - * Derivation OK (Simple) (§3.14.6). + * Derivation OK (Simple) ($3.14.6). */ return (xmlSchemaCheckCOSSTDerivedOK(actxt, type->baseType, baseType, set)); @@ -16029,7 +16139,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt, * SPEC (1) "If the {base type definition} is a complex type definition, * then all of the following must be true:" */ - if (WXS_IS_COMPLEX(base)) { + if (WXS_IS_COMPLEX(base)) { /* * SPEC (1.1) "The {final} of the {base type definition} must not * contain extension." @@ -16042,7 +16152,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt, "contains 'extension'", NULL); return (XML_SCHEMAP_COS_CT_EXTENDS_1_1); } - + /* * ATTENTION: The constrains (1.2) and (1.3) are not applied, * since they are automatically satisfied through the @@ -16086,11 +16196,11 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt, } if (! found) { xmlChar *str = NULL; - + xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_COS_CT_EXTENDS_1_2, NULL, WXS_BASIC_CAST type, - /* + /* * TODO: The report does not indicate that also the * type needs to be the same. */ @@ -16108,9 +16218,9 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt, * definition must also have one, and the base type definition's * {attribute wildcard}'s {namespace constraint} must be a subset * of the complex type definition's {attribute wildcard}'s {namespace - * constraint}, as defined by Wildcard Subset (§3.10.6)." + * constraint}, as defined by Wildcard Subset ($3.10.6)." */ - + /* * MAYBE TODO: Enable if ever needed. But this will be needed only * if created the type via a schema construction API. @@ -16118,7 +16228,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt, if (base->attributeWildcard != NULL) { if (type->attributeWilcard == NULL) { xmlChar *str = NULL; - + xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_COS_CT_EXTENDS_1_3, NULL, type, @@ -16131,7 +16241,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt, base->attributeWildcard, type->attributeWildcard)) { xmlChar *str = NULL; - + xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_COS_CT_EXTENDS_1_3, NULL, type, @@ -16205,9 +16315,9 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt, } /* * URGENT TODO SPEC (1.4.3.2.2.2) "The particle of the - * complex type definition must be a ·valid extension· + * complex type definition must be a `valid extension` * of the {base type definition}'s particle, as defined - * in Particle Valid (Extension) (§3.9.6)." + * in Particle Valid (Extension) ($3.9.6)." * * NOTE that we won't check "Particle Valid (Extension)", * since it is ensured by the derivation process in @@ -16285,7 +16395,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt, */ base = type->baseType; if (! WXS_IS_COMPLEX(base)) { - xmlSchemaCustomErr(ACTXT_CAST ctxt, + xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, type->node, WXS_BASIC_CAST type, "The base type must be a complex type", NULL, NULL); @@ -16296,7 +16406,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt, * SPEC (1) "The {base type definition} must be a complex type * definition whose {final} does not contain restriction." */ - xmlSchemaCustomErr(ACTXT_CAST ctxt, + xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, type->node, WXS_BASIC_CAST type, "The 'final' of the base type definition " @@ -16324,7 +16434,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt, if (base->builtInType == XML_SCHEMAS_ANYTYPE) { /* * SPEC (5.1) "The {base type definition} must be the - * ·ur-type definition·." + * `ur-type definition`." * PASS */ } else if ((type->contentType == XML_SCHEMA_CONTENT_SIMPLE) || @@ -16343,11 +16453,11 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt, * SPEC (5.2.2.1) "The {content type} of the {base type * definition} must be a simple type definition from which * the {content type} is validly derived given the empty - * set as defined in Type Derivation OK (Simple) (§3.14.6)." + * set as defined in Type Derivation OK (Simple) ($3.14.6)." * * ATTENTION TODO: This seems not needed if the type implicitely * derived from the base type. - * + * */ err = xmlSchemaCheckCOSSTDerivedOK(ACTXT_CAST ctxt, type->contentTypeDef, base->contentTypeDef, 0); @@ -16374,8 +16484,8 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt, (xmlSchemaParticlePtr) base->subtypes))) { /* * SPEC (5.2.2.2) "The {base type definition} must be mixed - * and have a particle which is ·emptiable· as defined in - * Particle Emptiable (§3.9.6)." + * and have a particle which is `emptiable` as defined in + * Particle Emptiable ($3.9.6)." * PASS */ } else { @@ -16404,7 +16514,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt, /* * SPEC (5.3.2.2) "The {content type} of the {base type * definition} must be elementOnly or mixed and have a particle - * which is ·emptiable· as defined in Particle Emptiable (§3.9.6)." + * which is `emptiable` as defined in Particle Emptiable ($3.9.6)." * PASS */ } else { @@ -16421,7 +16531,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt, /* * SPEC (5.4.1.1) "The {content type} of the complex type definition * itself must be element-only" - */ + */ if (WXS_HAS_MIXED_CONTENT(type) && (! WXS_HAS_MIXED_CONTENT(base))) { /* * SPEC (5.4.1.2) "The {content type} of the complex type @@ -16437,9 +16547,9 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt, } /* * SPEC (5.4.2) "The particle of the complex type definition itself - * must be a ·valid restriction· of the particle of the {content + * must be a `valid restriction` of the particle of the {content * type} of the {base type definition} as defined in Particle Valid - * (Restriction) (§3.9.6). + * (Restriction) ($3.9.6). * * URGENT TODO: (5.4.2) */ @@ -16508,7 +16618,7 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt, if (! WXS_HAS_SIMPLE_CONTENT(type)) { /* * 1 If the <complexContent> alternative is chosen, the type definition - * ·resolved· to by the ·actual value· of the base [attribute] + * `resolved` to by the `actual value` of the base [attribute] * must be a complex type definition; */ if (! WXS_IS_COMPLEX(base)) { @@ -16528,7 +16638,7 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt, * SPEC * 2 If the <simpleContent> alternative is chosen, all of the * following must be true: - * 2.1 The type definition ·resolved· to by the ·actual value· of the + * 2.1 The type definition `resolved` to by the `actual value` of the * base [attribute] must be one of the following: */ if (WXS_IS_SIMPLE(base)) { @@ -16578,11 +16688,11 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt, if (! xmlSchemaIsParticleEmptiable( (xmlSchemaParticlePtr) base->subtypes)) { ret = XML_SCHEMAP_SRC_CT_1; - } else + } else /* * Attention: at this point the <simpleType> child is in * ->contentTypeDef (put there during parsing). - */ + */ if (type->contentTypeDef == NULL) { xmlChar *str = NULL; /* @@ -16634,14 +16744,14 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt, /* * SPEC (3) "The corresponding complex type definition component must * satisfy the conditions set out in Constraints on Complex Type - * Definition Schema Components (§3.4.6);" + * Definition Schema Components ($3.4.6);" * NOTE (3) will be done in xmlSchemaTypeFixup(). */ /* * SPEC (4) If clause 2.2.1 or clause 2.2.2 in the correspondence specification * above for {attribute wildcard} is satisfied, the intensional * intersection must be expressible, as defined in Attribute Wildcard - * Intersection (§3.10.6). + * Intersection ($3.10.6). * NOTE (4) is done in xmlSchemaFixupTypeAttributeUses(). */ return (ret); @@ -16712,7 +16822,7 @@ xmlSchemaCheckRCaseNameAndTypeOK(xmlSchemaParserCtxtPtr ctxt, return (1); /* * SPEC (2) "R's occurrence range is a valid restriction of B's - * occurrence range as defined by Occurrence Range OK (§3.9.6)." + * occurrence range as defined by Occurrence Range OK ($3.9.6)." */ if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs, b->minOccurs, b->maxOccurs) != 0) @@ -16804,19 +16914,19 @@ xmlSchemaCheckRCaseNSCompat(xmlSchemaParserCtxtPtr ctxt, { /* TODO:Error codes (rcase-NSCompat). */ /* - * SPEC "For an element declaration particle to be a ·valid restriction· + * SPEC "For an element declaration particle to be a `valid restriction` * of a wildcard particle all of the following must be true:" * - * SPEC (1) "The element declaration's {target namespace} is ·valid· + * SPEC (1) "The element declaration's {target namespace} is `valid` * with respect to the wildcard's {namespace constraint} as defined by - * Wildcard allows Namespace Name (§3.10.4)." + * Wildcard allows Namespace Name ($3.10.4)." */ if (xmlSchemaCheckCVCWildcardNamespace((xmlSchemaWildcardPtr) b->children, ((xmlSchemaElementPtr) r->children)->targetNamespace) != 0) return (1); /* * SPEC (2) "R's occurrence range is a valid restriction of B's - * occurrence range as defined by Occurrence Range OK (§3.9.6)." + * occurrence range as defined by Occurrence Range OK ($3.9.6)." */ if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs, b->minOccurs, b->maxOccurs) != 0) @@ -16876,21 +16986,21 @@ xmlSchemaCheckRCaseNSSubset(xmlSchemaParserCtxtPtr ctxt, /* TODO: Error codes (rcase-NSSubset). */ /* * SPEC (1) "R's occurrence range is a valid restriction of B's - * occurrence range as defined by Occurrence Range OK (§3.9.6)." + * occurrence range as defined by Occurrence Range OK ($3.9.6)." */ if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs, b->minOccurs, b->maxOccurs)) return (1); /* * SPEC (2) "R's {namespace constraint} must be an intensional subset - * of B's {namespace constraint} as defined by Wildcard Subset (§3.10.6)." + * of B's {namespace constraint} as defined by Wildcard Subset ($3.10.6)." */ if (xmlSchemaCheckCOSNSSubset((xmlSchemaWildcardPtr) r->children, (xmlSchemaWildcardPtr) b->children)) return (1); /* - * SPEC (3) "Unless B is the content model wildcard of the ·ur-type - * definition·, R's {process contents} must be identical to or stronger + * SPEC (3) "Unless B is the content model wildcard of the `ur-type + * definition`, R's {process contents} must be identical to or stronger * than B's {process contents}, where strict is stronger than lax is * stronger than skip." */ @@ -16940,6 +17050,7 @@ xmlSchemaCheckCOSParticleRestrict(xmlSchemaParserCtxtPtr ctxt, return (0); } +#if 0 /** * xmlSchemaCheckRCaseNSRecurseCheckCardinality: * @ctxt: the schema parser context @@ -16967,12 +17078,12 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt, if ((r->children == NULL) || (r->children->children == NULL)) return (-1); /* - * SPEC "For a group particle to be a ·valid restriction· of a + * SPEC "For a group particle to be a `valid restriction` of a * wildcard particle..." * - * SPEC (1) "Every member of the {particles} of the group is a ·valid - * restriction· of the wildcard as defined by - * Particle Valid (Restriction) (§3.9.6)." + * SPEC (1) "Every member of the {particles} of the group is a `valid + * restriction` of the wildcard as defined by + * Particle Valid (Restriction) ($3.9.6)." */ part = (xmlSchemaParticlePtr) r->children->children; do { @@ -16983,7 +17094,7 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt, /* * SPEC (2) "The effective total range of the group [...] is a * valid restriction of B's occurrence range as defined by - * Occurrence Range OK (§3.9.6)." + * Occurrence Range OK ($3.9.6)." */ if (xmlSchemaCheckParticleRangeOK( xmlSchemaGetParticleTotalRangeMin(r), @@ -16992,6 +17103,7 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt, return (1); return (0); } +#endif /** * xmlSchemaCheckRCaseRecurse: @@ -17022,11 +17134,11 @@ xmlSchemaCheckRCaseRecurse(xmlSchemaParserCtxtPtr ctxt, (r->children->type != b->children->type)) return (-1); /* - * SPEC "For an all or sequence group particle to be a ·valid - * restriction· of another group particle with the same {compositor}..." + * SPEC "For an all or sequence group particle to be a `valid + * restriction` of another group particle with the same {compositor}..." * * SPEC (1) "R's occurrence range is a valid restriction of B's - * occurrence range as defined by Occurrence Range OK (§3.9.6)." + * occurrence range as defined by Occurrence Range OK ($3.9.6)." */ if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs, b->minOccurs, b->maxOccurs)) @@ -17123,7 +17235,7 @@ xmlSchemaDeriveAndValidateFacets(xmlSchemaParserCtxtPtr pctxt, /* * SPEC st-restrict-facets 1: - * "The {variety} of R is the same as that of B." + * "The {variety} of R is the same as that of B." */ /* * SPEC st-restrict-facets 2: @@ -17277,7 +17389,7 @@ xmlSchemaDeriveAndValidateFacets(xmlSchemaParserCtxtPtr pctxt, flength = bflength; if (flength) { if (! fminlen) - flength = bflength; + fminlen = bfminlen; if (fminlen) { /* (1.1) length >= minLength */ res = xmlSchemaCompareValues(flength->val, fminlen->val); @@ -17595,7 +17707,7 @@ xmlSchemaDeriveAndValidateFacets(xmlSchemaParserCtxtPtr pctxt, * The whitespace must be stronger. */ if (facet->whitespace < bfacet->whitespace) { - FACET_RESTR_ERR(flength, + FACET_RESTR_ERR(facet, "The 'whitespace' value has to be equal to " "or stronger than the 'whitespace' value of " "the base type") @@ -17650,7 +17762,7 @@ xmlSchemaFinishMemberTypeDefinitionsProperty(xmlSchemaParserCtxtPtr pctxt, xmlSchemaTypeLinkPtr link, lastLink, prevLink, subLink, newLink; /* * The actual value is then formed by replacing any union type - * definition in the ·explicit members· with the members of their + * definition in the `explicit members` with the members of their * {member type definitions}, in order. * * TODO: There's a bug entry at @@ -17696,7 +17808,7 @@ xmlSchemaFinishMemberTypeDefinitionsProperty(xmlSchemaParserCtxtPtr pctxt, static void xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type) -{ +{ int has = 0, needVal = 0, normVal = 0; has = (type->baseType->flags & XML_SCHEMAS_TYPE_HAS_FACETS) ? 1 : 0; @@ -17708,7 +17820,7 @@ xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type) } if (type->facets != NULL) { xmlSchemaFacetPtr fac; - + for (fac = type->facets; fac != NULL; fac = fac->next) { switch (fac->type) { case XML_SCHEMA_FACET_WHITESPACE: @@ -17726,7 +17838,7 @@ xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type) has = 1; break; } - } + } } if (normVal) type->flags |= XML_SCHEMAS_TYPE_NORMVALUENEEDED; @@ -17743,24 +17855,24 @@ xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type) if ((prim->builtInType != XML_SCHEMAS_ANYSIMPLETYPE) && (prim->builtInType != XML_SCHEMAS_STRING)) { type->flags |= XML_SCHEMAS_TYPE_FACETSNEEDVALUE; - } - } + } + } } static int xmlSchemaTypeFixupWhitespace(xmlSchemaTypePtr type) { - - + + /* * Evaluate the whitespace-facet value. - */ + */ if (WXS_IS_LIST(type)) { type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE; return (0); } else if (WXS_IS_UNION(type)) return (0); - + if (type->facetSet != NULL) { xmlSchemaFacetLinkPtr lin; @@ -17784,23 +17896,23 @@ xmlSchemaTypeFixupWhitespace(xmlSchemaTypePtr type) } } /* - * For all ·atomic· datatypes other than string (and types ·derived· - * by ·restriction· from it) the value of whiteSpace is fixed to + * For all `atomic` datatypes other than string (and types `derived` + * by `restriction` from it) the value of whiteSpace is fixed to * collapse */ { xmlSchemaTypePtr anc; - for (anc = type->baseType; anc != NULL && + for (anc = type->baseType; anc != NULL && anc->builtInType != XML_SCHEMAS_ANYTYPE; anc = anc->baseType) { if (anc->type == XML_SCHEMA_TYPE_BASIC) { - if (anc->builtInType == XML_SCHEMAS_NORMSTRING) { + if (anc->builtInType == XML_SCHEMAS_NORMSTRING) { type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_REPLACE; } else if ((anc->builtInType == XML_SCHEMAS_STRING) || - (anc->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) { + (anc->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) { type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE; } else @@ -17837,7 +17949,7 @@ xmlSchemaFixupSimpleTypeStageOne(xmlSchemaParserCtxtPtr pctxt, } else if (WXS_IS_UNION(type)) { /* * Corresponds to <simpleType><union>... - */ + */ if (type->memberTypes == NULL) { /* * This one is really needed, so get out. @@ -17845,8 +17957,8 @@ xmlSchemaFixupSimpleTypeStageOne(xmlSchemaParserCtxtPtr pctxt, PERROR_INT("xmlSchemaFixupSimpleTypeStageOne", "union type has no member-types assigned"); return(-1); - } - } else { + } + } else { /* * Corresponds to <simpleType><restriction>... */ @@ -17961,7 +18073,7 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt, } if (WXS_IS_TYPE_NOT_FIXED(type->baseType)) xmlSchemaTypeFixup(type->baseType, ACTXT_CAST pctxt); - /* + /* * If a member type of a union is a union itself, we need to substitute * that member type for its member types. * NOTE that this might change in WXS 1.1; i.e. we will keep the union @@ -17969,12 +18081,12 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt, */ if ((type->memberTypes != NULL) && (xmlSchemaFinishMemberTypeDefinitionsProperty(pctxt, type) == -1)) - return(-1); + return(-1); /* - * SPEC src-simple-type 1 + * SPEC src-simple-type 1 * "The corresponding simple type definition, if any, must satisfy * the conditions set out in Constraints on Simple Type Definition - * Schema Components (§3.14.6)." + * Schema Components ($3.14.6)." */ /* * Schema Component Constraint: Simple Type Definition Properties Correct @@ -17982,7 +18094,7 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt, */ res = xmlSchemaCheckSTPropsCorrect(pctxt, type); HFAILURE HERROR - /* + /* * Schema Component Constraint: Derivation Valid (Restriction, Simple) * (cos-st-restricts) */ @@ -18015,7 +18127,7 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt, */ res = xmlSchemaTypeFixupWhitespace(type); HFAILURE HERROR - xmlSchemaTypeFixupOptimFacets(type); + xmlSchemaTypeFixupOptimFacets(type); exit_error: #ifdef DEBUG_TYPE @@ -18046,7 +18158,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, PERROR_INT("xmlSchemaFixupComplexType", "missing baseType"); goto exit_failure; - } + } /* * Fixup the base type. */ @@ -18058,12 +18170,12 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, * TODO: Generate a warning! */ return(0); - } + } /* * This basically checks if the base type can be derived. */ res = xmlSchemaCheckSRCCT(pctxt, type); - HFAILURE HERROR + HFAILURE HERROR /* * Fixup the content type. */ @@ -18137,7 +18249,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, type->facets = NULL; content->facetSet = type->facetSet; type->facetSet = NULL; - + type->contentTypeDef = content; if (WXS_IS_TYPE_NOT_FIXED(contentBase)) xmlSchemaTypeFixup(contentBase, ACTXT_CAST pctxt); @@ -18146,10 +18258,10 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, * for circularity here. */ res = xmlSchemaFixupSimpleTypeStageOne(pctxt, content); - HFAILURE HERROR + HFAILURE HERROR res = xmlSchemaFixupSimpleTypeStageTwo(pctxt, content); - HFAILURE HERROR - + HFAILURE HERROR + } else if ((WXS_IS_COMPLEX(baseType)) && (baseType->contentType == XML_SCHEMA_CONTENT_MIXED) && (WXS_IS_RESTRICTION(type))) { @@ -18234,7 +18346,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, ( ((xmlSchemaTreeItemPtr) particle->children)->children == NULL))) { if (type->flags & XML_SCHEMAS_TYPE_MIXED) { /* - * SPEC (2.1.4) "If the ·effective mixed· is true, then + * SPEC (2.1.4) "If the `effective mixed` is true, then * a particle whose properties are as follows:..." * * Empty sequence model group with @@ -18259,7 +18371,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, XML_SCHEMA_TYPE_SEQUENCE, type->node); if (particle->children == NULL) goto exit_failure; - + type->subtypes = (xmlSchemaTypePtr) particle; } dummySequence = 1; @@ -18296,7 +18408,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, if (type->contentType == XML_SCHEMA_CONTENT_EMPTY) { /* * SPEC (3.2.1) - * "If the ·effective content· is empty, then the + * "If the `effective content` is empty, then the * {content type} of the [...] base ..." */ type->contentType = baseType->contentType; @@ -18394,8 +18506,8 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, particle->children->children = (xmlSchemaTreeItemPtr) xmlSchemaAddParticle(pctxt, type->node, - ((xmlSchemaParticlePtr) type->subtypes)->minOccurs, - ((xmlSchemaParticlePtr) type->subtypes)->maxOccurs); + ((xmlSchemaParticlePtr) baseType->subtypes)->minOccurs, + ((xmlSchemaParticlePtr) baseType->subtypes)->maxOccurs); if (particle->children->children == NULL) goto exit_failure; particle = (xmlSchemaParticlePtr) @@ -18403,7 +18515,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt, particle->children = ((xmlSchemaParticlePtr) baseType->subtypes)->children; /* - * SPEC "followed by the ·effective content·." + * SPEC "followed by the `effective content`." */ particle->next = effectiveContent; /* @@ -18547,12 +18659,12 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet, /* 4.3.5.5 Constraints on enumeration Schema Components * Schema Component Constraint: enumeration valid restriction - * It is an ·error· if any member of {value} is not in the - * ·value space· of {base type definition}. + * It is an `error` if any member of {value} is not in the + * `value space` of {base type definition}. * * minInclusive, maxInclusive, minExclusive, maxExclusive: - * The value ·must· be in the - * ·value space· of the ·base type·. + * The value `must` be in the + * `value space` of the `base type`. */ /* * This function is intended to deliver a compiled value @@ -18572,11 +18684,11 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet, } } else base = typeDecl; - + if (! ctxtGiven) { /* * A context is needed if called from RelaxNG. - */ + */ pctxt = xmlSchemaNewParserCtxt("*"); if (pctxt == NULL) return (-1); @@ -18587,17 +18699,17 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet, * facet->node is just the node holding the facet * definition, *not* the attribute holding the *value* * of the facet. - */ + */ ret = xmlSchemaVCheckCVCSimpleType( ACTXT_CAST pctxt, facet->node, base, facet->value, &(facet->val), 1, 1, 0); if (ret != 0) { if (ret < 0) { /* No error message for RelaxNG. */ - if (ctxtGiven) { + if (ctxtGiven) { xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_INTERNAL, facet->node, NULL, - "Internal error: xmlSchemaCheckFacet, " + "Internal error: xmlSchemaCheckFacet, " "failed to validate the value '%s' of the " "facet '%s' against the base type", facet->value, xmlSchemaFacetTypeToString(facet->type)); @@ -18672,17 +18784,17 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet, /* error code */ xmlSchemaCustomErr4(ACTXT_CAST pctxt, ret, facet->node, WXS_BASIC_CAST typeDecl, - "The value '%s' of the facet '%s' is not a valid '%s'", + "The value '%s' of the facet '%s' is not a valid '%s'", facet->value, xmlSchemaFacetTypeToString(facet->type), - (facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ? + (facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ? BAD_CAST "nonNegativeInteger" : BAD_CAST "positiveInteger", NULL); } } break; - + case XML_SCHEMA_FACET_WHITESPACE:{ if (xmlStrEqual(facet->value, BAD_CAST "preserve")) { facet->whitespace = XML_SCHEMAS_FACET_PRESERVE; @@ -18895,7 +19007,7 @@ xmlSchemaModelGroupToModelGroupDefFixup( { particle = WXS_PTC_CAST particle->next; continue; - } + } if (WXS_MODELGROUPDEF_MODEL(WXS_PARTICLE_TERM(particle)) == NULL) { /* * TODO: Remove the particle. @@ -18945,7 +19057,7 @@ xmlSchemaCheckAttrGroupCircularRecur(xmlSchemaAttributeGroupPtr ctxtGr, if (gr == ctxtGr) return(ref); if (gr->flags & XML_SCHEMAS_ATTRGROUP_MARKED) - continue; + continue; /* * Mark as visited to avoid infinite recursion on * circular references not yet examined. @@ -18955,12 +19067,12 @@ xmlSchemaCheckAttrGroupCircularRecur(xmlSchemaAttributeGroupPtr ctxtGr, { gr->flags |= XML_SCHEMAS_ATTRGROUP_MARKED; circ = xmlSchemaCheckAttrGroupCircularRecur(ctxtGr, - (xmlSchemaItemListPtr) gr->attrUses); + (xmlSchemaItemListPtr) gr->attrUses); gr->flags ^= XML_SCHEMAS_ATTRGROUP_MARKED; if (circ != NULL) return (circ); } - + } } return (NULL); @@ -18987,9 +19099,9 @@ xmlSchemaCheckAttrGroupCircular(xmlSchemaAttributeGroupPtr attrGr, * not be an <attributeGroup> with ref [attribute] which resolves * to the component corresponding to this <attributeGroup>. Indirect * circularity is also ruled out. That is, when QName resolution - * (Schema Document) (§3.15.3) is applied to a ·QName· arising from + * (Schema Document) ($3.15.3) is applied to a `QName` arising from * any <attributeGroup>s with a ref [attribute] among the [children], - * it must not be the case that a ·QName· is encountered at any depth + * it must not be the case that a `QName` is encountered at any depth * which resolves to the component corresponding to this <attributeGroup>. */ if (attrGr->attrUses == NULL) @@ -18998,9 +19110,9 @@ xmlSchemaCheckAttrGroupCircular(xmlSchemaAttributeGroupPtr attrGr, return(0); else { xmlSchemaQNameRefPtr circ; - + circ = xmlSchemaCheckAttrGroupCircularRecur(attrGr, - (xmlSchemaItemListPtr) attrGr->attrUses); + (xmlSchemaItemListPtr) attrGr->attrUses); if (circ != NULL) { xmlChar *str = NULL; /* @@ -19032,7 +19144,7 @@ xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt, * xmlSchemaExpandAttributeGroupRefs: * @pctxt: the parser context * @node: the node of the component holding the attribute uses - * @completeWild: the intersected wildcard to be returned + * @completeWild: the intersected wildcard to be returned * @list: the attribute uses * * Substitutes contained attribute group references @@ -19061,7 +19173,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt, for (i = 0; i < list->nbItems; i++) { use = list->items[i]; - if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) { + if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) { if (prohibs == NULL) { PERROR_INT("xmlSchemaExpandAttributeGroupRefs", "unexpected attr prohibition found"); @@ -19076,7 +19188,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt, /* * Note that duplicate prohibitions were already * handled at parsing time. - */ + */ /* * Add to list of prohibitions. */ @@ -19129,7 +19241,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt, *completeWild = tmpWild; created = 1; } - + if (xmlSchemaIntersectWildcards(pctxt, *completeWild, gr->attributeWildcard) == -1) return(-1); @@ -19139,7 +19251,8 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt, * Just remove the reference if the referenced group does not * contain any attribute uses. */ - if (gr->attrUses == NULL) { + sublist = ((xmlSchemaItemListPtr) gr->attrUses); + if ((sublist == NULL) || sublist->nbItems == 0) { if (xmlSchemaItemListRemove(list, i) == -1) return(-1); i--; @@ -19148,18 +19261,15 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt, /* * Add the attribute uses. */ - sublist = ((xmlSchemaItemListPtr) gr->attrUses); - if (sublist->nbItems != 0) { - list->items[i] = sublist->items[0]; - if (sublist->nbItems != 1) { - for (j = 1; j < sublist->nbItems; j++) { - i++; - if (xmlSchemaItemListInsert(list, - sublist->items[j], i) == -1) - return(-1); - } + list->items[i] = sublist->items[0]; + if (sublist->nbItems != 1) { + for (j = 1; j < sublist->nbItems; j++) { + i++; + if (xmlSchemaItemListInsert(list, + sublist->items[j], i) == -1) + return(-1); } - } + } } } @@ -19205,7 +19315,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt, /** * xmlSchemaAttributeGroupExpandRefs: * @pctxt: the parser context - * @attrGr: the attribute group definition + * @attrGr: the attribute group definition * * Computation of: * {attribute uses} property @@ -19217,7 +19327,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt, static int xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt, xmlSchemaAttributeGroupPtr attrGr) -{ +{ if ((attrGr->attrUses == NULL) || (attrGr->flags & XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED)) return(0); @@ -19225,33 +19335,33 @@ xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt, attrGr->flags |= XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED; if (xmlSchemaExpandAttributeGroupRefs(pctxt, WXS_BASIC_CAST attrGr, &(attrGr->attributeWildcard), attrGr->attrUses, NULL) == -1) - return(-1); + return(-1); return(0); } /** * xmlSchemaAttributeGroupExpandRefs: * @pctxt: the parser context - * @attrGr: the attribute group definition + * @attrGr: the attribute group definition * * Substitutes contained attribute group references * for their attribute uses. Wilcards are intersected. - * + * * Schema Component Constraint: - * Attribute Group Definition Properties Correct (ag-props-correct) + * Attribute Group Definition Properties Correct (ag-props-correct) */ static int xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt, xmlSchemaAttributeGroupPtr attrGr) -{ +{ /* * SPEC ag-props-correct * (1) "The values of the properties of an attribute group definition * must be as described in the property tableau in The Attribute - * Group Definition Schema Component (§3.6.1), modulo the impact of - * Missing Sub-components (§5.3);" + * Group Definition Schema Component ($3.6.1), modulo the impact of + * Missing Sub-components ($5.3);" */ - + if ((attrGr->attrUses != NULL) && (WXS_LIST_CAST attrGr->attrUses)->nbItems > 1) { @@ -19260,7 +19370,7 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt, int i, j, hasId = 0; for (i = uses->nbItems -1; i >= 0; i--) { - use = uses->items[i]; + use = uses->items[i]; /* * SPEC ag-props-correct * (2) "Two distinct members of the {attribute uses} must not have @@ -19276,7 +19386,7 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt, WXS_ATTRUSE_DECL_TNS(tmp))) { xmlChar *str = NULL; - + xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_AG_PROPS_CORRECT, attrGr->node, WXS_BASIC_CAST attrGr, @@ -19300,13 +19410,13 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt, * are derived from ID." * TODO: Does 'derived' include member-types of unions? */ - if (WXS_ATTRUSE_TYPEDEF(use) != NULL) { + if (WXS_ATTRUSE_TYPEDEF(use) != NULL) { if (xmlSchemaIsDerivedFromBuiltInType( WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID)) - { + { if (hasId) { xmlChar *str = NULL; - + xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_AG_PROPS_CORRECT, attrGr->node, WXS_BASIC_CAST attrGr, @@ -19319,7 +19429,7 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt, FREE_AND_NULL(str); if (xmlSchemaItemListRemove(uses, i) == -1) return(-1); - } + } hasId = 1; } } @@ -19383,10 +19493,10 @@ xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt, * SPEC a-props-correct (1) * "The values of the properties of an attribute declaration must * be as described in the property tableau in The Attribute - * Declaration Schema Component (§3.2.1), modulo the impact of - * Missing Sub-components (§5.3)." + * Declaration Schema Component ($3.2.1), modulo the impact of + * Missing Sub-components ($5.3)." */ - + if (WXS_ATTR_TYPEDEF(attr) == NULL) return(0); @@ -19412,9 +19522,9 @@ xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt, /* * SPEC a-props-correct (2) * "if there is a {value constraint}, the canonical lexical - * representation of its value must be ·valid· with respect - * to the {type definition} as defined in String Valid (§3.14.4)." - * TODO: Don't care about the *cononical* stuff here, this requirement + * representation of its value must be `valid` with respect + * to the {type definition} as defined in String Valid ($3.14.4)." + * TODO: Don't care about the *canonical* stuff here, this requirement * will be removed in WXS 1.1 anyway. */ ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, @@ -19435,7 +19545,7 @@ xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt, return(pctxt->err); } } - + return(0); } @@ -19481,15 +19591,15 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt, /* * SPEC (1) "The values of the properties of an element declaration * must be as described in the property tableau in The Element - * Declaration Schema Component (§3.3.1), modulo the impact of Missing - * Sub-components (§5.3)." + * Declaration Schema Component ($3.3.1), modulo the impact of Missing + * Sub-components ($5.3)." */ if (WXS_SUBST_HEAD(elemDecl) != NULL) { xmlSchemaElementPtr head = WXS_SUBST_HEAD(elemDecl), circ; xmlSchemaCheckElementDeclComponent(head, pctxt); /* - * SPEC (3) "If there is a non-·absent· {substitution group + * SPEC (3) "If there is a non-`absent` {substitution group * affiliation}, then {scope} must be global." */ if ((elemDecl->flags & XML_SCHEMAS_ELEM_GLOBAL) == 0) { @@ -19533,9 +19643,9 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt, * of the element declaration must be validly derived from the {type * definition} of the {substitution group affiliation}, given the value * of the {substitution group exclusions} of the {substitution group - * affiliation}, as defined in Type Derivation OK (Complex) (§3.4.6) + * affiliation}, as defined in Type Derivation OK (Complex) ($3.4.6) * (if the {type definition} is complex) or as defined in - * Type Derivation OK (Simple) (§3.14.6) (if the {type definition} is + * Type Derivation OK (Simple) ($3.14.6) (if the {type definition} is * simple)." * * NOTE: {substitution group exclusions} means the values of the @@ -19599,9 +19709,9 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt, /* * SPEC (2) "If there is a {value constraint}, the canonical lexical - * representation of its value must be ·valid· with respect to the + * representation of its value must be `valid` with respect to the * {type definition} as defined in Element Default Valid (Immediate) - * (§3.3.6)." + * ($3.3.6)." */ if (typeDef == NULL) { xmlSchemaPErr(pctxt, elemDecl->node, @@ -19669,7 +19779,7 @@ xmlSchemaCheckElemSubstGroup(xmlSchemaParserCtxtPtr ctxt, /* * SPEC (2) "It is validly substitutable for HEAD subject to HEAD's * {disallowed substitutions} as the blocking constraint, as defined in - * Substitution Group OK (Transitive) (§3.3.6)." + * Substitution Group OK (Transitive) ($3.3.6)." */ for (head = WXS_SUBST_HEAD(elemDecl); head != NULL; head = WXS_SUBST_HEAD(head)) { @@ -19761,12 +19871,12 @@ add_member: * @ctxtParticle: the first particle of the context component * @searchParticle: the element declaration particle to be analysed * - * Schema Component Constraint: Element Declarations Consistent + * Schema Component Constraint: Element Declarations Consistent */ static int xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt, xmlSchemaBasicItemPtr ctxtComponent, - xmlSchemaParticlePtr ctxtParticle, + xmlSchemaParticlePtr ctxtParticle, xmlSchemaParticlePtr searchParticle, xmlSchemaParticlePtr curParticle, int search) @@ -19775,7 +19885,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt, int ret = 0; xmlSchemaParticlePtr cur = curParticle; - if (curParticle == NULL) { + if (curParticle == NULL) { return(0); } if (WXS_PARTICLE_TERM(curParticle) == NULL) { @@ -19784,7 +19894,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt, * might arise due to an invalid "term" component. */ return(0); - } + } while (cur != NULL) { switch (WXS_PARTICLE_TERM(cur)->type) { case XML_SCHEMA_TYPE_ANY: @@ -19794,7 +19904,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt, ret = xmlSchemaCheckElementDeclConsistent(pctxt, ctxtComponent, ctxtParticle, cur, ctxtParticle, 1); if (ret != 0) - return(ret); + return(ret); } else { xmlSchemaElementPtr elem = WXS_ELEM_CAST(WXS_PARTICLE_TERM(cur)); @@ -19802,7 +19912,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt, * SPEC Element Declarations Consistent: * "If the {particles} contains, either directly, * indirectly (that is, within the {particles} of a - * contained model group, recursively) or ·implicitly· + * contained model group, recursively) or `implicitly` * two or more element declaration particles with * the same {name} and {target namespace}, then * all their type definitions must be the same @@ -19814,7 +19924,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt, WXS_PARTICLE_TERM_AS_ELEM(searchParticle)->targetNamespace)) { xmlChar *strA = NULL, *strB = NULL; - + xmlSchemaCustomErr(ACTXT_CAST pctxt, /* TODO: error code */ XML_SCHEMAP_COS_NONAMBIG, @@ -19831,16 +19941,16 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt, FREE_AND_NULL(strB); return(XML_SCHEMAP_COS_NONAMBIG); } - } + } break; - case XML_SCHEMA_TYPE_SEQUENCE: { + case XML_SCHEMA_TYPE_SEQUENCE: { break; } case XML_SCHEMA_TYPE_CHOICE:{ /* xmlSchemaTreeItemPtr sub; - - sub = WXS_PARTICLE_TERM(particle)->children; (xmlSchemaParticlePtr) + + sub = WXS_PARTICLE_TERM(particle)->children; (xmlSchemaParticlePtr) while (sub != NULL) { ret = xmlSchemaCheckElementDeclConsistent(pctxt, ctxtComponent, ctxtParticle, ctxtElem); @@ -19877,7 +19987,7 @@ exit: * @name: the name of the attribute * * Validates the value constraints of an element declaration. - * Adds substitution group members. + * Adds substitution group members. */ static void xmlSchemaCheckElementDeclComponent(xmlSchemaElementPtr elemDecl, @@ -19892,7 +20002,7 @@ xmlSchemaCheckElementDeclComponent(xmlSchemaElementPtr elemDecl, /* * Adds substitution group members. */ - xmlSchemaCheckElemSubstGroup(ctxt, elemDecl); + xmlSchemaCheckElemSubstGroup(ctxt, elemDecl); } } @@ -19922,7 +20032,7 @@ xmlSchemaResolveModelGroupParticleReferences( XML_SCHEMA_EXTRA_QNAMEREF)) { goto next_particle; - } + } ref = WXS_QNAME_CAST WXS_PARTICLE_TERM(particle); /* * Resolve the reference. @@ -19938,7 +20048,7 @@ xmlSchemaResolveModelGroupParticleReferences( ref->targetNamespace, ref->itemType, NULL); /* TODO: remove the particle. */ goto next_particle; - } + } if (refItem->type == XML_SCHEMA_TYPE_GROUP) { if (WXS_MODELGROUPDEF_MODEL(refItem) == NULL) /* TODO: remove the particle. */ @@ -19988,9 +20098,9 @@ next_particle: static int xmlSchemaAreValuesEqual(xmlSchemaValPtr x, - xmlSchemaValPtr y) -{ - xmlSchemaTypePtr tx, ty, ptx, pty; + xmlSchemaValPtr y) +{ + xmlSchemaTypePtr tx, ty, ptx, pty; int ret; while (x != NULL) { @@ -20000,12 +20110,12 @@ xmlSchemaAreValuesEqual(xmlSchemaValPtr x, ptx = xmlSchemaGetPrimitiveType(tx); pty = xmlSchemaGetPrimitiveType(ty); /* - * (1) if a datatype T' is ·derived· by ·restriction· from an - * atomic datatype T then the ·value space· of T' is a subset of - * the ·value space· of T. */ + * (1) if a datatype T' is `derived` by `restriction` from an + * atomic datatype T then the `value space` of T' is a subset of + * the `value space` of T. */ /* - * (2) if datatypes T' and T'' are ·derived· by ·restriction· - * from a common atomic ancestor T then the ·value space·s of T' + * (2) if datatypes T' and T'' are `derived` by `restriction` + * from a common atomic ancestor T then the `value space`s of T' * and T'' may overlap. */ if (ptx != pty) @@ -20036,7 +20146,7 @@ xmlSchemaAreValuesEqual(xmlSchemaValPtr x, if (x != NULL) { y = xmlSchemaValueGetNext(y); if (y == NULL) - return (0); + return (0); } else if (xmlSchemaValueGetNext(y) != NULL) return (0); else @@ -20073,7 +20183,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); @@ -20086,11 +20196,11 @@ xmlSchemaResolveAttrUseReferences(xmlSchemaAttributeUsePtr ause, /** * xmlSchemaCheckAttrUsePropsCorrect: * @ctxt: a parser context - * @use: an attribute use + * @use: an attribute use * * Schema Component Constraint: * Attribute Use Correct (au-props-correct) - * + * */ static int xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt, @@ -20100,16 +20210,16 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt, return(-1); if ((use->defValue == NULL) || (WXS_ATTRUSE_DECL(use) == NULL) || ((WXS_ATTRUSE_DECL(use))->type != XML_SCHEMA_TYPE_ATTRIBUTE)) - return(0); + return(0); /* * SPEC au-props-correct (1) * "The values of the properties of an attribute use must be as * described in the property tableau in The Attribute Use Schema - * Component (§3.5.1), modulo the impact of Missing - * Sub-components (§5.3)." + * Component ($3.5.1), modulo the impact of Missing + * Sub-components ($5.3)." */ - + if (((WXS_ATTRUSE_DECL(use))->defValue != NULL) && ((WXS_ATTRUSE_DECL(use))->flags & XML_SCHEMAS_ATTR_FIXED) && ((use->flags & XML_SCHEMA_ATTR_USE_FIXED) == 0)) @@ -20129,7 +20239,7 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt, if ((use->defVal != NULL) && (WXS_ATTRUSE_TYPEDEF(use) != NULL)) { int ret; /* - * TODO: The spec seems to be missing a check of the + * TODO: The spec seems to be missing a check of the * value constraint of the attribute use. We will do it here. */ /* @@ -20146,7 +20256,7 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt, NULL, NULL); return(ctxt->err); } - + ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST ctxt, use->node, WXS_ATTRUSE_TYPEDEF(use), use->defValue, &(use->defVal), @@ -20197,7 +20307,7 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt, /** * xmlSchemaResolveAttrTypeReferences: * @item: an attribute declaration - * @ctxt: a parser context + * @ctxt: a parser context * * Resolves the referenced type definition component. */ @@ -20208,8 +20318,8 @@ xmlSchemaResolveAttrTypeReferences(xmlSchemaAttributePtr item, /* * The simple type definition corresponding to the <simpleType> element * information item in the [children], if present, otherwise the simple - * type definition ·resolved· to by the ·actual value· of the type - * [attribute], if present, otherwise the ·simple ur-type definition·. + * type definition `resolved` to by the `actual value` of the type + * [attribute], if present, otherwise the `simple ur-type definition`. */ if (item->flags & XML_SCHEMAS_ATTR_INTERNAL_RESOLVED) return(0); @@ -20288,7 +20398,7 @@ xmlSchemaResolveIDCKeyReferences(xmlSchemaIDCPtr idc, ((xmlSchemaIDCPtr) idc->ref->item)->nbFields) { xmlChar *str = NULL; xmlSchemaIDCPtr refer; - + refer = (xmlSchemaIDCPtr) idc->ref->item; /* * SPEC c-props-correct(2) @@ -20347,7 +20457,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) int wasRedefined; if (redef == NULL) - return(0); + return(0); do { item = redef->item; @@ -20362,7 +20472,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) * <redefine>d schema. Currenlty we latter approach is used. * SUPPLEMENT: It seems that the WG moves towards the latter * approach, so we are doing it right. - * + * */ prev = xmlSchemaFindRedefCompInGraph( redef->targetBucket, item->type, @@ -20373,11 +20483,11 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) /* * SPEC src-redefine: - * (6.2.1) "The ·actual value· of its own name attribute plus - * target namespace must successfully ·resolve· to a model + * (6.2.1) "The `actual value` of its own name attribute plus + * target namespace must successfully `resolve` to a model * group definition in I." - * (7.2.1) "The ·actual value· of its own name attribute plus - * target namespace must successfully ·resolve· to an attribute + * (7.2.1) "The `actual value` of its own name attribute plus + * target namespace must successfully `resolve` to an attribute * group definition in I." * @@ -20394,7 +20504,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) /* * TODO: error code. * Probably XML_SCHEMAP_SRC_RESOLVE, if this is using the - * reference kind. + * reference kind. */ XML_SCHEMAP_SRC_REDEFINE, node, NULL, "The %s '%s' to be redefined could not be found in " @@ -20402,7 +20512,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) WXS_ITEM_TYPE_NAME(item), xmlSchemaFormatQName(&str, redef->refTargetNs, redef->refName)); - FREE_AND_NULL(str); + FREE_AND_NULL(str); err = pctxt->err; redef = redef->next; continue; @@ -20428,7 +20538,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) * base type of the redefining type. * TODO: How */ - ((xmlSchemaTypePtr) item)->baseType = + ((xmlSchemaTypePtr) item)->baseType = (xmlSchemaTypePtr) prev; break; case XML_SCHEMA_TYPE_GROUP: @@ -20483,7 +20593,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) default: PERROR_INT("xmlSchemaResolveRedefReferences", "Unexpected redefined component type"); - return(-1); + return(-1); } if (wasRedefined) { xmlChar *str = NULL; @@ -20493,7 +20603,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) node = WXS_ITEM_NODE(redef->reference); else node = WXS_ITEM_NODE(redef->item); - + xmlSchemaCustomErr(ACTXT_CAST pctxt, /* TODO: error code. */ XML_SCHEMAP_SRC_REDEFINE, @@ -20502,12 +20612,12 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt) "redefinition of the same component is not supported", xmlSchemaGetComponentDesignation(&str, prev), NULL); - FREE_AND_NULL(str) + FREE_AND_NULL(str) err = pctxt->err; redef = redef->next; continue; } - redef = redef->next; + redef = redef->next; } while (redef != NULL); return(err); @@ -20521,7 +20631,7 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt) xmlSchemaBasicItemPtr item; if (redef == NULL) - return(0); + return(0); do { if (redef->target == NULL) { @@ -20529,7 +20639,7 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt) continue; } item = redef->item; - + switch (item->type) { case XML_SCHEMA_TYPE_SIMPLE: case XML_SCHEMA_TYPE_COMPLEX: @@ -20538,7 +20648,7 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt) * type to be 'absent', we'll NULL it. */ (WXS_TYPE_CAST redef->target)->name = NULL; - + /* * TODO: Seems like there's nothing more to do. The normal * inheritance mechanism is used. But not 100% sure. @@ -20550,10 +20660,10 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt) * SPEC src-redefine: * (6.2.2) "The {model group} of the model group definition * which corresponds to it per XML Representation of Model - * Group Definition Schema Components (§3.7.2) must be a - * ·valid restriction· of the {model group} of that model + * Group Definition Schema Components ($3.7.2) must be a + * `valid restriction` of the {model group} of that model * group definition in I, as defined in Particle Valid - * (Restriction) (§3.9.6)." + * (Restriction) ($3.9.6)." */ break; case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: @@ -20562,11 +20672,11 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt) * (7.2.2) "The {attribute uses} and {attribute wildcard} of * the attribute group definition which corresponds to it * per XML Representation of Attribute Group Definition Schema - * Components (§3.6.2) must be ·valid restrictions· of the + * Components ($3.6.2) must be `valid restrictions` of the * {attribute uses} and {attribute wildcard} of that attribute * group definition in I, as defined in clause 2, clause 3 and * clause 4 of Derivation Valid (Restriction, Complex) - * (§3.4.6) (where references to the base type definition are + * ($3.4.6) (where references to the base type definition are * understood as references to the attribute group definition * in I)." */ @@ -20587,7 +20697,7 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt) } while (redef != NULL); return(0); } - + static int xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt, @@ -20621,8 +20731,8 @@ xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt, return(-1); if (bucket->flags & XML_SCHEMA_BUCKET_COMPS_ADDED) return(0); - bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED; - + bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED; + for (i = 0; i < bucket->globals->nbItems; i++) { item = bucket->globals->items[i]; table = NULL; @@ -20663,12 +20773,12 @@ xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt, case XML_SCHEMA_TYPE_NOTATION: name = ((xmlSchemaNotationPtr) item)->name; WXS_GET_GLOBAL_HASH(bucket, notaDecl) - break; + break; default: PERROR_INT("xmlSchemaAddComponents", "Unexpected global component type"); - continue; - } + continue; + } if (*table == NULL) { *table = xmlHashCreateDict(10, pctxt->dict); if (*table == NULL) { @@ -20676,11 +20786,11 @@ xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt, "failed to create a component hash table"); return(-1); } - } + } err = xmlHashAddEntry(*table, name, item); - if (err != 0) { + if (err != 0) { xmlChar *str = NULL; - + xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_REDEFINED_TYPE, WXS_ITEM_NODE(item), @@ -20688,7 +20798,7 @@ xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt, "A global %s '%s' does already exist", WXS_ITEM_TYPE_NAME(item), xmlSchemaGetComponentQName(&str, item)); - FREE_AND_NULL(str); + FREE_AND_NULL(str); } } /* @@ -20722,34 +20832,34 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, if ((con->pending == NULL) || (con->pending->nbItems == 0)) - return(0); + return(0); /* * Since xmlSchemaFixupComplexType() will create new particles * (local components), and those particle components need a bucket * on the constructor, we'll assure here that the constructor has * a bucket. - * TODO: Think about storing locals _only_ on the main bucket. - */ + * TODO: Think about storing locals _only_ on the main bucket. + */ if (con->bucket == NULL) - con->bucket = rootBucket; + con->bucket = rootBucket; /* TODO: * SPEC (src-redefine): * (6.2) "If it has no such self-reference, then all of the * following must be true:" - + * (6.2.2) The {model group} of the model group definition which * corresponds to it per XML Representation of Model Group - * Definition Schema Components (§3.7.2) must be a ·valid - * restriction· of the {model group} of that model group definition - * in I, as defined in Particle Valid (Restriction) (§3.9.6)." + * Definition Schema Components ($3.7.2) must be a `valid + * restriction` of the {model group} of that model group definition + * in I, as defined in Particle Valid (Restriction) ($3.9.6)." */ xmlSchemaCheckSRCRedefineFirst(pctxt); /* * Add global components to the schemata's hash tables. - */ + */ xmlSchemaAddComponents(pctxt, rootBucket); pctxt->ctxtType = NULL; @@ -20759,7 +20869,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, * Now that we have parsed *all* the schema document(s) and converted * them to schema components, we can resolve references, apply component * constraints, create the FSA from the content model, etc. - */ + */ /* * Resolve references of.. * @@ -20780,7 +20890,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, * 6. IDC key-references: * - the referenced IDC 'key' or 'unique' definition * 7. Attribute prohibitions which had a "ref" attribute. - */ + */ for (i = 0; i < nbItems; i++) { item = items[i]; switch (item->type) { @@ -20806,7 +20916,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, FIXHFAILURE; break; case XML_SCHEMA_EXTRA_QNAMEREF: - if ((WXS_QNAME_CAST item)->itemType == + if ((WXS_QNAME_CAST item)->itemType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) { xmlSchemaResolveAttrGroupReferences( @@ -20843,11 +20953,11 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, } if (pctxt->nberrors != 0) goto exit_error; - + /* * Now that all references are resolved we * can check for circularity of... - * 1. the base axis of type definitions + * 1. the base axis of type definitions * 2. nested model group definitions * 3. nested attribute group definitions * TODO: check for circual substitution groups. @@ -20882,7 +20992,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, break; default: break; - } + } } if (pctxt->nberrors != 0) goto exit_error; @@ -20898,7 +21008,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, item = items[i]; switch (item->type) { case XML_SCHEMA_TYPE_SEQUENCE: - case XML_SCHEMA_TYPE_CHOICE: + case XML_SCHEMA_TYPE_CHOICE: xmlSchemaModelGroupToModelGroupDefFixup(pctxt, WXS_MODEL_GROUP_CAST item); break; @@ -20929,7 +21039,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, } if (pctxt->nberrors != 0) goto exit_error; - /* + /* * First compute the variety of simple types. This is needed as * a seperate step, since otherwise we won't be able to detect * circular union types in all cases. @@ -20959,7 +21069,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, switch (item->type) { case XML_SCHEMA_TYPE_SIMPLE: if (((xmlSchemaTypePtr) item)->memberTypes != NULL) { - xmlSchemaCheckUnionTypeDefCircular(pctxt, + xmlSchemaCheckUnionTypeDefCircular(pctxt, (xmlSchemaTypePtr) item); FIXHFAILURE; } @@ -20970,7 +21080,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, } if (pctxt->nberrors != 0) goto exit_error; - + /* * Do the complete type fixup for simple types. */ @@ -20998,10 +21108,10 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, for (i = 0; i < nbItems; i++) { item = items[i]; switch (item->type) { - case XML_SCHEMA_TYPE_ATTRIBUTE: + case XML_SCHEMA_TYPE_ATTRIBUTE: xmlSchemaCheckAttrPropsCorrect(pctxt, WXS_ATTR_CAST item); FIXHFAILURE; - break; + break; default: break; } @@ -21010,7 +21120,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, goto exit_error; /* * Apply constraints for attribute uses. - */ + */ for (i = 0; i < nbItems; i++) { item = items[i]; switch (item->type) { @@ -21057,7 +21167,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, if (pctxt->nberrors != 0) goto exit_error; - /* + /* * Complex types are builded and checked. */ for (i = 0; i < nbItems; i++) { @@ -21081,8 +21191,8 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, * will create particles and model groups in some cases. */ items = (xmlSchemaTreeItemPtr *) con->pending->items; - nbItems = con->pending->nbItems; - + nbItems = con->pending->nbItems; + /* * Apply some constraints for element declarations. */ @@ -21091,7 +21201,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, switch (item->type) { case XML_SCHEMA_TYPE_ELEMENT: elemDecl = (xmlSchemaElementPtr) item; - + if ((elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_CHECKED) == 0) { xmlSchemaCheckElementDeclComponent( @@ -21121,7 +21231,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, } if (pctxt->nberrors != 0) goto exit_error; - + /* * Finally we can build the automaton from the content model of * complex types. @@ -21142,10 +21252,10 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt, goto exit_error; /* * URGENT TODO: cos-element-consistent - */ - goto exit; + */ + goto exit; -exit_error: +exit_error: ret = pctxt->err; goto exit; @@ -21159,12 +21269,12 @@ exit: * if not cleared here. */ con->bucket = oldbucket; - con->pending->nbItems = 0; + con->pending->nbItems = 0; if (con->substGroups != NULL) { xmlHashFree(con->substGroups, (xmlHashDeallocator) xmlSchemaSubstGroupFree); con->substGroups = NULL; - } + } if (con->redefs != NULL) { xmlSchemaRedefListFree(con->redefs); con->redefs = NULL; @@ -21227,11 +21337,11 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt) if (res == -1) goto exit_failure; if (res != 0) - goto exit; + goto exit; if (bucket == NULL) { /* TODO: Error code, actually we failed to *locate* the schema. */ - if (ctxt->URL) + if (ctxt->URL) xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_FAILED_LOAD, NULL, NULL, "Failed to locate the main schema resource at '%s'", @@ -21242,16 +21352,16 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt) "Failed to locate the main schema resource", NULL, NULL); goto exit; - } + } /* Then do the parsing for good. */ if (xmlSchemaParseNewDocWithContext(ctxt, mainSchema, bucket) == -1) goto exit_failure; if (ctxt->nberrors != 0) goto exit; - + mainSchema->doc = bucket->doc; mainSchema->preserve = ctxt->preserve; - + ctxt->schema = mainSchema; if (xmlSchemaFixupComponents(ctxt, WXS_CONSTRUCTOR(ctxt)->mainBucket) == -1) @@ -21261,8 +21371,8 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt) * TODO: This is not nice, since we cannot distinguish from the * result if there was an internal error or not. */ -exit: - if (ctxt->nberrors != 0) { +exit: + if (ctxt->nberrors != 0) { if (mainSchema) { xmlSchemaFree(mainSchema); mainSchema = NULL; @@ -21276,7 +21386,7 @@ exit: ctxt->schema = NULL; return(mainSchema); exit_failure: - /* + /* * Quite verbose, but should catch internal errors, which were * not communitated. */ @@ -21290,7 +21400,7 @@ exit_failure: ctxt->ownsConstructor = 0; } PERROR_INT2("xmlSchemaParse", - "An internal error occured"); + "An internal error occured"); ctxt->schema = NULL; return(NULL); } @@ -21427,8 +21537,8 @@ xmlSchemaGetWhiteSpaceFacetValue(xmlSchemaTypePtr type) return(XML_SCHEMA_WHITESPACE_REPLACE); else { /* - * For all ·atomic· datatypes other than string (and types ·derived· - * by ·restriction· from it) the value of whiteSpace is fixed to + * For all `atomic` datatypes other than string (and types `derived` + * by `restriction` from it) the value of whiteSpace is fixed to * collapse * Note that this includes built-in list datatypes. */ @@ -21453,16 +21563,16 @@ xmlSchemaGetWhiteSpaceFacetValue(xmlSchemaTypePtr type) } /************************************************************************ - * * - * Simple type validation * - * * + * * + * Simple type validation * + * * ************************************************************************/ /************************************************************************ - * * - * DOM Validation code * - * * + * * + * DOM Validation code * + * * ************************************************************************/ /** @@ -21515,11 +21625,11 @@ xmlSchemaAssembleByLocation(xmlSchemaValidCtxtPtr vctxt, * XML_SCHEMA_SCHEMA_MAIN if it is the first schema document. */ ret = xmlSchemaAddSchemaDoc(pctxt, XML_SCHEMA_SCHEMA_IMPORT, - location, NULL, NULL, 0, node, NULL, nsName, + location, NULL, NULL, 0, node, NULL, nsName, &bucket); if (ret != 0) - return(ret); - if (bucket == NULL) { + return(ret); + if (bucket == NULL) { /* * Generate a warning that the document could not be located. */ @@ -21549,17 +21659,17 @@ xmlSchemaAssembleByLocation(xmlSchemaValidCtxtPtr vctxt, pctxt->nberrors = 0; pctxt->err = 0; pctxt->doc = bucket->doc; - - ret = xmlSchemaParseNewDocWithContext(pctxt, schema, bucket); + + ret = xmlSchemaParseNewDocWithContext(pctxt, schema, bucket); if (ret == -1) { pctxt->doc = NULL; goto exit_failure; } /* Paranoid error channelling. */ if ((ret == 0) && (pctxt->nberrors != 0)) - ret = pctxt->err; - if (pctxt->nberrors == 0) { - /* + ret = pctxt->err; + if (pctxt->nberrors == 0) { + /* * Only bother to fixup pending components, if there was * no error yet. * For every XSI acquired schema (and its sub-schemata) we will @@ -21575,7 +21685,7 @@ xmlSchemaAssembleByLocation(xmlSchemaValidCtxtPtr vctxt, vctxt->err = ret; vctxt->nberrors += pctxt->nberrors; } else { - /* Add to validation error sum. */ + /* Add to validation error sum. */ vctxt->nberrors += pctxt->nberrors; } pctxt->doc = NULL; @@ -21586,7 +21696,7 @@ exit_failure: } static xmlSchemaAttrInfoPtr -xmlSchemaGetMetaAttrInfo(xmlSchemaValidCtxtPtr vctxt, +xmlSchemaGetMetaAttrInfo(xmlSchemaValidCtxtPtr vctxt, int metaType) { if (vctxt->nbAttrInfos == 0) @@ -21676,7 +21786,7 @@ xmlSchemaAssembleByXSI(xmlSchemaValidCtxtPtr vctxt) /* * If using @schemaLocation then tuples are expected. * I.e. the namespace name *and* the document's URI. - */ + */ xmlSchemaCustomWarning(ACTXT_CAST vctxt, XML_SCHEMAV_MISC, iattr->node, NULL, "The value must consist of tuples: the target namespace " @@ -21705,7 +21815,7 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt, if (vctxt->sax != NULL) { int i, j; xmlSchemaNodeInfoPtr inode; - + for (i = vctxt->depth; i >= 0; i--) { if (vctxt->elemInfos[i]->nbNsBindings != 0) { inode = vctxt->elemInfos[i]; @@ -21719,16 +21829,16 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt, * Note that the namespace bindings are already * in a string dict. */ - return (inode->nsBindings[j+1]); + return (inode->nsBindings[j+1]); } } } } return (NULL); -#ifdef LIBXML_WRITER_ENABLED +#ifdef LIBXML_READER_ENABLED } else if (vctxt->reader != NULL) { xmlChar *nsName; - + nsName = xmlTextReaderLookupNamespace(vctxt->reader, prefix); if (nsName != NULL) { const xmlChar *ret; @@ -21760,7 +21870,7 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt, * This one works on the schema of the validation context. */ static int -xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt, +xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt, xmlSchemaPtr schema, xmlNodePtr node, const xmlChar *value, @@ -21785,7 +21895,7 @@ xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt, if (prefix != NULL) { const xmlChar *nsName = NULL; - if (vctxt != NULL) + if (vctxt != NULL) nsName = xmlSchemaLookupNamespace(vctxt, BAD_CAST prefix); else if (node != NULL) { xmlNsPtr ns = xmlSearchNs(node->doc, node, prefix); @@ -21802,9 +21912,9 @@ xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt, return (1); } if (xmlSchemaGetNotation(schema, localName, nsName) != NULL) { - if (valNeeded && (val != NULL)) { - (*val) = xmlSchemaNewNOTATIONValue(BAD_CAST localName, - BAD_CAST xmlStrdup(nsName)); + if ((valNeeded) && (val != NULL)) { + (*val) = xmlSchemaNewNOTATIONValue(xmlStrdup(localName), + xmlStrdup(nsName)); if (*val == NULL) ret = -1; } @@ -21856,9 +21966,9 @@ xmlSchemaVAddNodeQName(xmlSchemaValidCtxtPtr vctxt, } /************************************************************************ - * * + * * * Validation of identity-constraints (IDC) * - * * + * * ************************************************************************/ /** @@ -21900,6 +22010,20 @@ xmlSchemaAugmentIDC(xmlSchemaIDCPtr idcDef, } /** + * xmlSchemaAugmentImportedIDC: + * @imported: the imported schema + * + * Creates an augmented IDC definition for the imported schema. + */ +static void +xmlSchemaAugmentImportedIDC(xmlSchemaImportPtr imported, xmlSchemaValidCtxtPtr vctxt) { + if (imported->schema->idcDef != NULL) { + xmlHashScan(imported->schema->idcDef , + (xmlHashScanner) xmlSchemaAugmentIDC, vctxt); + } +} + +/** * xmlSchemaIDCNewBinding: * @idcDef: the IDC definition of this binding * @@ -22123,7 +22247,7 @@ xmlSchemaIDCFreeBinding(xmlSchemaPSVIIDCBindingPtr bind) if (bind->nodeTable != NULL) xmlFree(bind->nodeTable); if (bind->dupls != NULL) - xmlSchemaItemListFree(bind->dupls); + xmlSchemaItemListFree(bind->dupls); xmlFree(bind); } @@ -22158,12 +22282,12 @@ xmlSchemaIDCFreeMatcherList(xmlSchemaIDCMatcherPtr matcher) while (matcher != NULL) { next = matcher->next; - if (matcher->keySeqs != NULL) { + if (matcher->keySeqs != NULL) { int i; for (i = 0; i < matcher->sizeKeySeqs; i++) if (matcher->keySeqs[i] != NULL) xmlFree(matcher->keySeqs[i]); - xmlFree(matcher->keySeqs); + xmlFree(matcher->keySeqs); } if (matcher->targets != NULL) { if (matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) { @@ -22203,7 +22327,7 @@ xmlSchemaIDCReleaseMatcherList(xmlSchemaValidCtxtPtr vctxt, while (matcher != NULL) { next = matcher->next; - if (matcher->keySeqs != NULL) { + if (matcher->keySeqs != NULL) { int i; /* * Don't free the array, but only the content. @@ -22232,7 +22356,7 @@ xmlSchemaIDCReleaseMatcherList(xmlSchemaValidCtxtPtr vctxt, } xmlSchemaItemListFree(matcher->targets); matcher->targets = NULL; - } + } matcher->next = NULL; /* * Cache the matcher. @@ -22274,7 +22398,7 @@ xmlSchemaIDCAddStateObject(xmlSchemaValidCtxtPtr vctxt, sto = vctxt->xpathStatePool; vctxt->xpathStatePool = sto->next; sto->next = NULL; - } else { + } else { /* * Create a new state object. */ @@ -22285,10 +22409,10 @@ xmlSchemaIDCAddStateObject(xmlSchemaValidCtxtPtr vctxt, return (-1); } memset(sto, 0, sizeof(xmlSchemaIDCStateObj)); - } + } /* - * Add to global list. - */ + * Add to global list. + */ if (vctxt->xpathStates != NULL) sto->next = vctxt->xpathStates; vctxt->xpathStates = sto; @@ -22308,13 +22432,13 @@ xmlSchemaIDCAddStateObject(xmlSchemaValidCtxtPtr vctxt, VERROR_INT("xmlSchemaIDCAddStateObject", "failed to create an XPath validation context"); return (-1); - } + } sto->type = type; sto->depth = vctxt->depth; sto->matcher = matcher; sto->sel = sel; sto->nbHistory = 0; - + #ifdef DEBUG_IDC xmlGenericError(xmlGenericErrorContext, "IDC: STO push '%s'\n", sto->sel->xpath); @@ -22338,7 +22462,7 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt, { xmlSchemaIDCStateObjPtr sto, head = NULL, first; int res, resolved = 0, depth = vctxt->depth; - + if (vctxt->xpathStates == NULL) return (0); @@ -22347,8 +22471,8 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt, #ifdef DEBUG_IDC { xmlChar *str = NULL; - xmlGenericError(xmlGenericErrorContext, - "IDC: EVAL on %s, depth %d, type %d\n", + xmlGenericError(xmlGenericErrorContext, + "IDC: EVAL on %s, depth %d, type %d\n", xmlSchemaFormatQName(&str, vctxt->inode->nsName, vctxt->inode->localName), depth, nodeType); FREE_AND_NULL(str) @@ -22362,10 +22486,10 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt, while (sto != head) { #ifdef DEBUG_IDC if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) - xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] selector '%s'\n", + xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] selector '%s'\n", sto->matcher->aidc->def->name, sto->sel->xpath); else - xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] field '%s'\n", + xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] field '%s'\n", sto->matcher->aidc->def->name, sto->sel->xpath); #endif if (nodeType == XML_ELEMENT_NODE) @@ -22395,7 +22519,7 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt, if (sto->history == NULL) { sto->history = (int *) xmlMalloc(5 * sizeof(int)); if (sto->history == NULL) { - xmlSchemaVErrMemory(NULL, + xmlSchemaVErrMemory(NULL, "allocating the state object history", NULL); return(-1); } @@ -22405,11 +22529,11 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt, sto->history = (int *) xmlRealloc(sto->history, sto->sizeHistory * sizeof(int)); if (sto->history == NULL) { - xmlSchemaVErrMemory(NULL, + xmlSchemaVErrMemory(NULL, "re-allocating the state object history", NULL); return(-1); } - } + } sto->history[sto->nbHistory++] = depth; #ifdef DEBUG_IDC @@ -22478,7 +22602,7 @@ xmlSchemaFormatIDCKeySequence(xmlSchemaValidCtxtPtr vctxt, *buf = xmlStrdup(BAD_CAST "["); for (i = 0; i < count; i++) { *buf = xmlStrcat(*buf, BAD_CAST "'"); - res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val, + res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val, xmlSchemaGetWhiteSpaceFacetValue(seq[i]->type), &value); if (res == 0) @@ -22536,7 +22660,7 @@ xmlSchemaXPathPop(xmlSchemaValidCtxtPtr vctxt) * * Processes and pops the history items of the IDC state objects. * IDC key-sequences are validated/created on IDC bindings. - * + * * Returns 0 on success and -1 on internal errors. */ static int @@ -22555,13 +22679,13 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, #ifdef DEBUG_IDC { xmlChar *str = NULL; - xmlGenericError(xmlGenericErrorContext, + xmlGenericError(xmlGenericErrorContext, "IDC: BACK on %s, depth %d\n", xmlSchemaFormatQName(&str, vctxt->inode->nsName, vctxt->inode->localName), vctxt->depth); FREE_AND_NULL(str) } -#endif +#endif /* * Evaluate the state objects. */ @@ -22587,14 +22711,14 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, if (matchDepth != depth) { sto = sto->next; continue; - } + } if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_FIELD) { /* * NOTE: According to * http://www.w3.org/Bugs/Public/show_bug.cgi?id=2198 * ... the simple-content of complex types is also allowed. */ - + if (WXS_IS_COMPLEX(type)) { if (WXS_HAS_SIMPLE_CONTENT(type)) { /* @@ -22609,17 +22733,17 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, } } else simpleType = NULL; - } else + } else simpleType = type; if (simpleType == NULL) { xmlChar *str = NULL; - + /* * Not qualified if the field resolves to a node of non * simple type. - */ + */ xmlSchemaCustomErr(ACTXT_CAST vctxt, - XML_SCHEMAV_CVC_IDC, NULL, + XML_SCHEMAV_CVC_IDC, NULL, WXS_BASIC_CAST sto->matcher->aidc->def, "The XPath '%s' of a field of %s does evaluate to a node of " "non-simple type", @@ -22629,7 +22753,7 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, sto->nbHistory--; goto deregister_check; } - + if ((key == NULL) && (vctxt->inode->val == NULL)) { /* * Failed to provide the normalized value; maybe @@ -22645,13 +22769,13 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, xmlSchemaIDCMatcherPtr matcher = sto->matcher; xmlSchemaPSVIIDCKeyPtr *keySeq; int pos, idx; - + /* * The key will be anchored on the matcher's list of * key-sequences. The position in this list is determined * by the target node's depth relative to the matcher's * depth of creation (i.e. the depth of the scope element). - * + * * Element Depth Pos List-entries * <scope> 0 NULL * <bar> 1 NULL @@ -22662,23 +22786,23 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, * The size of the list is only dependant on the depth of * the tree. * An entry will be NULLed in selector_leave, i.e. when - * we hit the target's - */ + * we hit the target's + */ pos = sto->depth - matcher->depth; idx = sto->sel->index; - + /* * Create/grow the array of key-sequences. */ if (matcher->keySeqs == NULL) { - if (pos > 9) + if (pos > 9) matcher->sizeKeySeqs = pos * 2; else matcher->sizeKeySeqs = 10; - matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **) + matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **) xmlMalloc(matcher->sizeKeySeqs * - sizeof(xmlSchemaPSVIIDCKeyPtr *)); - if (matcher->keySeqs == NULL) { + sizeof(xmlSchemaPSVIIDCKeyPtr *)); + if (matcher->keySeqs == NULL) { xmlSchemaVErrMemory(NULL, "allocating an array of key-sequences", NULL); @@ -22687,9 +22811,9 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, memset(matcher->keySeqs, 0, matcher->sizeKeySeqs * sizeof(xmlSchemaPSVIIDCKeyPtr *)); - } else if (pos >= matcher->sizeKeySeqs) { + } else if (pos >= matcher->sizeKeySeqs) { int i = matcher->sizeKeySeqs; - + matcher->sizeKeySeqs *= 2; matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **) xmlRealloc(matcher->keySeqs, @@ -22705,29 +22829,29 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, * The array needs to be NULLed. * TODO: Use memset? */ - for (; i < matcher->sizeKeySeqs; i++) - matcher->keySeqs[i] = NULL; + for (; i < matcher->sizeKeySeqs; i++) + matcher->keySeqs[i] = NULL; } - + /* * Get/create the key-sequence. */ - keySeq = matcher->keySeqs[pos]; - if (keySeq == NULL) { + keySeq = matcher->keySeqs[pos]; + if (keySeq == NULL) { goto create_sequence; } else if (keySeq[idx] != NULL) { xmlChar *str = NULL; /* * cvc-identity-constraint: - * 3 For each node in the ·target node set· all + * 3 For each node in the `target node set` all * of the {fields}, with that node as the context * node, evaluate to either an empty node-set or * a node-set with exactly one member, which must * have a simple type. - * + * * The key was already set; report an error. */ - xmlSchemaCustomErr(ACTXT_CAST vctxt, + xmlSchemaCustomErr(ACTXT_CAST vctxt, XML_SCHEMAV_CVC_IDC, NULL, WXS_BASIC_CAST matcher->aidc->def, "The XPath '%s' of a field of %s evaluates to a " @@ -22738,27 +22862,27 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt, sto->nbHistory--; goto deregister_check; } else - goto create_key; - + goto create_key; + create_sequence: /* * Create a key-sequence. */ keySeq = (xmlSchemaPSVIIDCKeyPtr *) xmlMalloc( - matcher->aidc->def->nbFields * + matcher->aidc->def->nbFields * sizeof(xmlSchemaPSVIIDCKeyPtr)); if (keySeq == NULL) { - xmlSchemaVErrMemory(NULL, + xmlSchemaVErrMemory(NULL, "allocating an IDC key-sequence", NULL); - return(-1); - } - memset(keySeq, 0, matcher->aidc->def->nbFields * + return(-1); + } + memset(keySeq, 0, matcher->aidc->def->nbFields * sizeof(xmlSchemaPSVIIDCKeyPtr)); matcher->keySeqs[pos] = keySeq; create_key: /* * Create a key once per node only. - */ + */ if (key == NULL) { key = (xmlSchemaPSVIIDCKeyPtr) xmlMalloc( sizeof(xmlSchemaPSVIIDCKey)); @@ -22767,7 +22891,7 @@ create_key: "allocating a IDC key", NULL); xmlFree(keySeq); matcher->keySeqs[pos] = NULL; - return(-1); + return(-1); } /* * Consume the compiled value. @@ -22783,10 +22907,10 @@ create_key: return (-1); } } - keySeq[idx] = key; + keySeq[idx] = key; } } else if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) { - + xmlSchemaPSVIIDCKeyPtr **keySeq = NULL; /* xmlSchemaPSVIIDCBindingPtr bind; */ xmlSchemaPSVIIDCNodePtr ntItem; @@ -22797,22 +22921,22 @@ create_key: /* * Here we have the following scenario: * An IDC 'selector' state object resolved to a target node, - * during the time this target node was in the - * ancestor-or-self axis, the 'field' state object(s) looked - * out for matching nodes to create a key-sequence for this + * during the time this target node was in the + * ancestor-or-self axis, the 'field' state object(s) looked + * out for matching nodes to create a key-sequence for this * target node. Now we are back to this target node and need - * to put the key-sequence, together with the target node - * itself, into the node-table of the corresponding IDC + * to put the key-sequence, together with the target node + * itself, into the node-table of the corresponding IDC * binding. */ matcher = sto->matcher; idc = matcher->aidc->def; nbKeys = idc->nbFields; - pos = depth - matcher->depth; + pos = depth - matcher->depth; /* * Check if the matcher has any key-sequences at all, plus * if it has a key-sequence for the current target node. - */ + */ if ((matcher->keySeqs == NULL) || (matcher->sizeKeySeqs <= pos)) { if (idc->type == XML_SCHEMA_TYPE_IDC_KEY) @@ -22820,15 +22944,15 @@ create_key: else goto selector_leave; } - - keySeq = &(matcher->keySeqs[pos]); + + keySeq = &(matcher->keySeqs[pos]); if (*keySeq == NULL) { if (idc->type == XML_SCHEMA_TYPE_IDC_KEY) goto selector_key_error; else goto selector_leave; } - + for (i = 0; i < nbKeys; i++) { if ((*keySeq)[i] == NULL) { /* @@ -22839,18 +22963,18 @@ create_key: * All fields of a "key" IDC must resolve. */ goto selector_key_error; - } + } goto selector_leave; } } /* * All fields did resolve. */ - + /* * 4.1 If the {identity-constraint category} is unique(/key), - * then no two members of the ·qualified node set· have - * ·key-sequences· whose members are pairwise equal, as + * then no two members of the `qualified node set` have + * `key-sequences` whose members are pairwise equal, as * defined by Equal in [XML Schemas: Datatypes]. * * Get the IDC binding from the matcher and check for @@ -22860,10 +22984,10 @@ create_key: bind = xmlSchemaIDCAcquireBinding(vctxt, matcher); #endif targets = xmlSchemaIDCAcquireTargetList(vctxt, matcher); - if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) && + if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) && (targets->nbItems != 0)) { xmlSchemaPSVIIDCKeyPtr ckey, bkey, *bkeySeq; - + i = 0; res = 0; /* @@ -22874,7 +22998,7 @@ create_key: ((xmlSchemaPSVIIDCNodePtr) targets->items[i])->keys; for (j = 0; j < nbKeys; j++) { ckey = (*keySeq)[j]; - bkey = bkeySeq[j]; + bkey = bkeySeq[j]; res = xmlSchemaAreValuesEqual(ckey->val, bkey->val); if (res == -1) { return (-1); @@ -22896,10 +23020,10 @@ create_key: } while (i < targets->nbItems); if (i != targets->nbItems) { xmlChar *str = NULL, *strB = NULL; - /* + /* * TODO: Try to report the key-sequence. */ - xmlSchemaCustomErr(ACTXT_CAST vctxt, + xmlSchemaCustomErr(ACTXT_CAST vctxt, XML_SCHEMAV_CVC_IDC, NULL, WXS_BASIC_CAST idc, "Duplicate key-sequence %s in %s", @@ -22917,15 +23041,15 @@ create_key: ntItem = (xmlSchemaPSVIIDCNodePtr) xmlMalloc( sizeof(xmlSchemaPSVIIDCNode)); if (ntItem == NULL) { - xmlSchemaVErrMemory(NULL, + xmlSchemaVErrMemory(NULL, "allocating an IDC node-table item", NULL); xmlFree(*keySeq); *keySeq = NULL; return(-1); - } + } memset(ntItem, 0, sizeof(xmlSchemaPSVIIDCNode)); - - /* + + /* * Store the node-table item in a global list. */ if (idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) { @@ -22947,7 +23071,7 @@ create_key: xmlFree(ntItem); xmlFree(*keySeq); *keySeq = NULL; - return (-1); + return (-1); } } /* @@ -22959,11 +23083,11 @@ create_key: ntItem->keys = *keySeq; *keySeq = NULL; #if 0 - if (xmlSchemaIDCAppendNodeTableItem(bind, ntItem) == -1) { + if (xmlSchemaIDCAppendNodeTableItem(bind, ntItem) == -1) #endif if (xmlSchemaItemListAdd(targets, ntItem) == -1) { if (idc->type == XML_SCHEMA_TYPE_IDC_KEYREF) { - /* + /* * Free the item, since keyref items won't be * put on a global list. */ @@ -22972,18 +23096,18 @@ create_key: } return (-1); } - + goto selector_leave; selector_key_error: { xmlChar *str = NULL; /* - * 4.2.1 (KEY) The ·target node set· and the - * ·qualified node set· are equal, that is, every - * member of the ·target node set· is also a member - * of the ·qualified node set· and vice versa. + * 4.2.1 (KEY) The `target node set` and the + * `qualified node set` are equal, that is, every + * member of the `target node set` is also a member + * of the `qualified node set` and vice versa. */ - xmlSchemaCustomErr(ACTXT_CAST vctxt, + xmlSchemaCustomErr(ACTXT_CAST vctxt, XML_SCHEMAV_CVC_IDC, NULL, WXS_BASIC_CAST idc, "Not all fields of %s evaluate to a node", @@ -22999,7 +23123,7 @@ selector_leave: *keySeq = NULL; } } /* if selector */ - + sto->nbHistory--; deregister_check: @@ -23050,15 +23174,15 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt, xmlSchemaIDCMatcherPtr matcher, last = NULL; xmlSchemaIDCPtr idc, refIdc; xmlSchemaIDCAugPtr aidc; - + idc = (xmlSchemaIDCPtr) elemDecl->idcs; if (idc == NULL) return (0); - + #ifdef DEBUG_IDC { xmlChar *str = NULL; - xmlGenericError(xmlGenericErrorContext, + xmlGenericError(xmlGenericErrorContext, "IDC: REGISTER on %s, depth %d\n", (char *) xmlSchemaFormatQName(&str, vctxt->inode->nsName, vctxt->inode->localName), vctxt->depth); @@ -23099,7 +23223,7 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt, "Could not find an augmented IDC item for an IDC " "definition"); return (-1); - } + } if ((aidc->keyrefDepth == -1) || (vctxt->depth < aidc->keyrefDepth)) aidc->keyrefDepth = vctxt->depth; @@ -23130,10 +23254,10 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt, vctxt->idcMatcherCache = matcher->nextCached; matcher->nextCached = NULL; } else { - matcher = (xmlSchemaIDCMatcherPtr) + matcher = (xmlSchemaIDCMatcherPtr) xmlMalloc(sizeof(xmlSchemaIDCMatcher)); if (matcher == NULL) { - xmlSchemaVErrMemory(vctxt, + xmlSchemaVErrMemory(vctxt, "allocating an IDC matcher", NULL); return (-1); } @@ -23146,16 +23270,16 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt, last = matcher; matcher->type = IDC_MATCHER; - matcher->depth = vctxt->depth; + matcher->depth = vctxt->depth; matcher->aidc = aidc; matcher->idcType = aidc->def->type; -#ifdef DEBUG_IDC +#ifdef DEBUG_IDC xmlGenericError(xmlGenericErrorContext, "IDC: register matcher\n"); -#endif +#endif /* - * Init the automaton state object. + * Init the automaton state object. */ - if (xmlSchemaIDCAddStateObject(vctxt, matcher, + if (xmlSchemaIDCAddStateObject(vctxt, matcher, idc->selector, XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) == -1) return (-1); @@ -23172,7 +23296,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt, int res, i, j, k, nbTargets, nbFields, nbDupls, nbNodeTable; xmlSchemaPSVIIDCKeyPtr *keys, *ntkeys; xmlSchemaPSVIIDCNodePtr *targets, *dupls; - + xmlSchemaIDCMatcherPtr matcher = ielem->idcMatchers; /* vctxt->createIDCNodeTables */ while (matcher != NULL) { @@ -23206,7 +23330,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt, nbDupls = bind->dupls->nbItems; } else { dupls = NULL; - nbDupls = 0; + nbDupls = 0; } if (bind->nodeTable != NULL) { nbNodeTable = bind->nbNodes; @@ -23219,29 +23343,29 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt, * Transfer all IDC target-nodes to the IDC node-table. */ bind->nodeTable = - (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items; + (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items; bind->sizeNodes = matcher->targets->sizeItems; bind->nbNodes = matcher->targets->nbItems; matcher->targets->items = NULL; matcher->targets->sizeItems = 0; - matcher->targets->nbItems = 0; + matcher->targets->nbItems = 0; } else { /* * Compare the key-sequences and add to the IDC node-table. */ nbTargets = matcher->targets->nbItems; - targets = (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items; + targets = (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items; nbFields = matcher->aidc->def->nbFields; i = 0; do { keys = targets[i]->keys; - if (nbDupls) { + if (nbDupls) { /* * Search in already found duplicates first. */ j = 0; - do { + do { if (nbFields == 1) { res = xmlSchemaAreValuesEqual(keys[0]->val, dupls[j]->keys[0]->val); @@ -23276,11 +23400,11 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt, } } j++; - } while (j < nbDupls); + } while (j < nbDupls); } if (nbNodeTable) { j = 0; - do { + do { if (nbFields == 1) { res = xmlSchemaAreValuesEqual(keys[0]->val, bind->nodeTable[j]->keys[0]->val); @@ -23307,7 +23431,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt, goto next_node_table_entry; } } - } + } /* * Add the duplicate to the list of duplicates. */ @@ -23315,7 +23439,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt, bind->dupls = xmlSchemaItemListCreate(); if (bind->dupls == NULL) goto internal_error; - } + } if (xmlSchemaItemListAdd(bind->dupls, bind->nodeTable[j]) == -1) goto internal_error; /* @@ -23350,12 +23474,12 @@ internal_error: } /** - * xmlSchemaBubbleIDCNodeTables: + * xmlSchemaBubbleIDCNodeTables: * @depth: the current tree depth * - * Merges IDC bindings of an element at @depth into the corresponding IDC - * bindings of its parent element. If a duplicate note-table entry is found, - * both, the parent node-table entry and child entry are discarded from the + * Merges IDC bindings of an element at @depth into the corresponding IDC + * bindings of its parent element. If a duplicate note-table entry is found, + * both, the parent node-table entry and child entry are discarded from the * node-table of the parent. * * Returns 0 if OK and -1 on internal errors. @@ -23369,19 +23493,19 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) xmlSchemaIDCAugPtr aidc; int i, j, k, ret = 0, nbFields, oldNum, oldDupls; - bind = vctxt->inode->idcTable; + bind = vctxt->inode->idcTable; if (bind == NULL) { /* Fine, no table, no bubbles. */ return (0); } - + parTable = &(vctxt->elemInfos[vctxt->depth -1]->idcTable); /* * Walk all bindings; create new or add to existing bindings. * Remove duplicate key-sequences. */ while (bind != NULL) { - + if ((bind->nbNodes == 0) && WXS_ILIST_IS_EMPTY(bind->dupls)) goto next_binding; /* @@ -23391,7 +23515,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) aidc = vctxt->aidcs; do { if (aidc->def == bind->definition) { - if ((aidc->keyrefDepth == -1) || + if ((aidc->keyrefDepth == -1) || (aidc->keyrefDepth >= vctxt->depth)) { goto next_binding; } @@ -23407,7 +23531,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) * Search a matching parent binding for the * IDC definition. */ - while (parBind != NULL) { + while (parBind != NULL) { if (parBind->definition == bind->definition) break; parBind = parBind->next; @@ -23415,7 +23539,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) if (parBind != NULL) { /* - * Compare every node-table entry of the child node, + * Compare every node-table entry of the child node, * i.e. the key-sequence within, ... */ oldNum = parBind->nbNodes; /* Skip newly added items. */ @@ -23425,12 +23549,12 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) dupls = (xmlSchemaPSVIIDCNodePtr *) parBind->dupls->items; } else { dupls = NULL; - oldDupls = 0; + oldDupls = 0; } - + parNodes = parBind->nodeTable; nbFields = bind->definition->nbFields; - + for (i = 0; i < bind->nbNodes; i++) { node = bind->nodeTable[i]; if (node == NULL) @@ -23440,7 +23564,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) * evaluated to be a duplicate key-sequence. */ if (oldDupls) { - j = 0; + j = 0; while (j < oldDupls) { if (nbFields == 1) { ret = xmlSchemaAreValuesEqual( @@ -23473,12 +23597,12 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) /* Duplicate found. Skip this entry. */ continue; } - } + } /* * ... and with every key-sequence of the parent node. */ if (oldNum) { - j = 0; + j = 0; while (j < oldNum) { parNode = parNodes[j]; if (nbFields == 1) { @@ -23491,7 +23615,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) j++; continue; } - } else { + } else { for (k = 0; k < nbFields; k++) { ret = xmlSchemaAreValuesEqual( node->keys[k]->val, @@ -23512,20 +23636,20 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) * Handle duplicates. Move the duplicate in * the parent's node-table to the list of * duplicates. - */ + */ oldNum--; parBind->nbNodes--; /* * Move last old item to pos of duplicate. */ parNodes[j] = parNodes[oldNum]; - + if (parBind->nbNodes != oldNum) { /* - * If new items exist, move last new item to + * If new items exist, move last new item to * last of old items. */ - parNodes[oldNum] = + parNodes[oldNum] = parNodes[parBind->nbNodes]; } if (parBind->dupls == NULL) { @@ -23533,31 +23657,31 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) if (parBind->dupls == NULL) goto internal_error; } - xmlSchemaItemListAdd(parBind->dupls, parNode); + xmlSchemaItemListAdd(parBind->dupls, parNode); } else { /* - * Add the node-table entry (node and key-sequence) of + * Add the node-table entry (node and key-sequence) of * the child node to the node table of the parent node. */ - if (parBind->nodeTable == NULL) { - parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) + if (parBind->nodeTable == NULL) { + parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) xmlMalloc(10 * sizeof(xmlSchemaPSVIIDCNodePtr)); if (parBind->nodeTable == NULL) { - xmlSchemaVErrMemory(NULL, + xmlSchemaVErrMemory(NULL, "allocating IDC list of node-table items", NULL); goto internal_error; } parBind->sizeNodes = 1; } else if (parBind->nbNodes >= parBind->sizeNodes) { parBind->sizeNodes *= 2; - parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) - xmlRealloc(parBind->nodeTable, parBind->sizeNodes * + parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) + xmlRealloc(parBind->nodeTable, parBind->sizeNodes * sizeof(xmlSchemaPSVIIDCNodePtr)); if (parBind->nodeTable == NULL) { - xmlSchemaVErrMemory(NULL, + xmlSchemaVErrMemory(NULL, "re-allocating IDC list of node-table items", NULL); goto internal_error; - } + } } parNodes = parBind->nodeTable; /* @@ -23567,9 +23691,9 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) parNodes[parBind->nbNodes++] = node; } - } - - } + } + + } } else { /* * No binding for the IDC was found: create a new one and @@ -23578,7 +23702,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) parBind = xmlSchemaIDCNewBinding(bind->definition); if (parBind == NULL) goto internal_error; - + /* * TODO: Hmm, how to optimize the initial number of * allocated entries? @@ -23604,11 +23728,11 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) /* * Copy the entries. */ - parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) + parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) xmlMalloc(bind->nbNodes * sizeof(xmlSchemaPSVIIDCNodePtr)); if (parBind->nodeTable == NULL) { - xmlSchemaVErrMemory(NULL, + xmlSchemaVErrMemory(NULL, "allocating an array of IDC node-table " "items", NULL); xmlSchemaIDCFreeBinding(parBind); @@ -23627,15 +23751,17 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt) if (parBind->dupls != NULL) xmlSchemaItemListFree(parBind->dupls); parBind->dupls = bind->dupls; - bind->dupls = NULL; - } - if (*parTable == NULL) - *parTable = parBind; - else { - parBind->next = *parTable; - *parTable = parBind; - } - } + bind->dupls = NULL; + } + if (parTable != NULL) { + if (*parTable == NULL) + *parTable = parBind; + else { + parBind->next = *parTable; + *parTable = parBind; + } + } + } next_binding: bind = bind->next; @@ -23658,7 +23784,7 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt) { xmlSchemaIDCMatcherPtr matcher; xmlSchemaPSVIIDCBindingPtr bind; - + matcher = vctxt->inode->idcMatchers; /* * Find a keyref. @@ -23679,7 +23805,7 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt) */ bind = vctxt->inode->idcTable; while (bind != NULL) { - if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item == + if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item == bind->definition) break; bind = bind->next; @@ -23748,7 +23874,7 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt) } } } - + if (res == 0) { xmlChar *str = NULL, *strB = NULL; xmlSchemaKeyrefErr(vctxt, @@ -23770,9 +23896,9 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt) } /************************************************************************ - * * - * XML Reader validation code * - * * + * * + * XML Reader validation code * + * * ************************************************************************/ static xmlSchemaAttrInfoPtr @@ -23832,7 +23958,7 @@ xmlSchemaValidatorPushAttribute(xmlSchemaValidCtxtPtr vctxt, xmlNodePtr attrNode, int nodeLine, const xmlChar *localName, - const xmlChar *nsName, + const xmlChar *nsName, int ownedNames, xmlChar *value, int ownedValue) @@ -23858,7 +23984,7 @@ xmlSchemaValidatorPushAttribute(xmlSchemaValidCtxtPtr vctxt, if (nsName != NULL) { if (xmlStrEqual(localName, BAD_CAST "nil")) { if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) { - attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_NIL; + attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_NIL; } } else if (xmlStrEqual(localName, BAD_CAST "type")) { if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) { @@ -24060,6 +24186,7 @@ xmlSchemaValidateFacets(xmlSchemaAbstractCtxtPtr actxt, else goto pattern_and_enum; } + /* * Whitespace handling is only of importance for string-based * types. @@ -24070,16 +24197,15 @@ xmlSchemaValidateFacets(xmlSchemaAbstractCtxtPtr actxt, ws = xmlSchemaGetWhiteSpaceFacetValue(type); } else ws = XML_SCHEMA_WHITESPACE_COLLAPSE; + /* * If the value was not computed (for string or * anySimpleType based types), then use the provided * type. */ - if (val == NULL) - valType = valType; - else + if (val != NULL) valType = xmlSchemaGetValType(val); - + ret = 0; for (facetLink = type->facetSet; facetLink != NULL; facetLink = facetLink->next) { @@ -24128,11 +24254,11 @@ WXS_IS_LIST: ret = 0; for (facetLink = type->facetSet; facetLink != NULL; facetLink = facetLink->next) { - + switch (facetLink->facet->type) { case XML_SCHEMA_FACET_LENGTH: case XML_SCHEMA_FACET_MINLENGTH: - case XML_SCHEMA_FACET_MAXLENGTH: + case XML_SCHEMA_FACET_MAXLENGTH: ret = xmlSchemaValidateListSimpleTypeFacet(facetLink->facet, value, length, NULL); break; @@ -24144,7 +24270,7 @@ WXS_IS_LIST: "validating against a list type facet"); return (-1); } else if (ret > 0) { - if (fireErrors) + if (fireErrors) xmlSchemaFacetErr(actxt, ret, node, value, length, type, facetLink->facet, NULL, NULL, NULL); else @@ -24221,7 +24347,7 @@ pattern_and_enum: if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN) continue; found = 1; - /* + /* * NOTE that for patterns, @value needs to be the * normalized vaule. */ @@ -24233,7 +24359,7 @@ pattern_and_enum: "validating against a pattern facet"); return (-1); } else { - /* + /* * Save the last non-validating facet. */ facet = facetLink->facet; @@ -24256,12 +24382,12 @@ pattern_and_enum: return (error); } - + static xmlChar * xmlSchemaNormalizeValue(xmlSchemaTypePtr type, const xmlChar *value) { - switch (xmlSchemaGetWhiteSpaceFacetValue(type)) { + switch (xmlSchemaGetWhiteSpaceFacetValue(type)) { case XML_SCHEMA_WHITESPACE_COLLAPSE: return (xmlSchemaCollapseString(value)); case XML_SCHEMA_WHITESPACE_REPLACE: @@ -24280,7 +24406,7 @@ xmlSchemaValidateQName(xmlSchemaValidCtxtPtr vctxt, int ret; const xmlChar *nsName; xmlChar *local, *prefix = NULL; - + ret = xmlValidateQName(value, 1); if (ret != 0) { if (ret == -1) { @@ -24303,7 +24429,7 @@ xmlSchemaValidateQName(xmlSchemaValidCtxtPtr vctxt, * - is there a default namespace? */ nsName = xmlSchemaLookupNamespace(vctxt, prefix); - + if (prefix != NULL) { xmlFree(prefix); /* @@ -24360,7 +24486,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, value = normValue; \ isNormalized = 1; \ } - + if ((retVal != NULL) && (*retVal != NULL)) { xmlSchemaFreeValue(*retVal); *retVal = NULL; @@ -24375,14 +24501,14 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, */ /* * 2.1 If The definition is ENTITY or is validly derived from ENTITY given - * the empty set, as defined in Type Derivation OK (Simple) (§3.14.6), then - * the string must be a ·declared entity name·. + * the empty set, as defined in Type Derivation OK (Simple) ($3.14.6), then + * the string must be a `declared entity name`. */ /* * 2.2 If The definition is ENTITIES or is validly derived from ENTITIES - * given the empty set, as defined in Type Derivation OK (Simple) (§3.14.6), - * then every whitespace-delimited substring of the string must be a ·declared - * entity name·. + * given the empty set, as defined in Type Derivation OK (Simple) ($3.14.6), + * then every whitespace-delimited substring of the string must be a `declared + * entity name`. */ /* * 2.3 otherwise no further condition applies. @@ -24394,8 +24520,8 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, if (WXS_IS_ANY_SIMPLE_TYPE(type) || WXS_IS_ATOMIC(type)) { xmlSchemaTypePtr biType; /* The built-in type. */ /* - * SPEC (1.2.1) "if {variety} is ·atomic· then the string must ·match· - * a literal in the ·lexical space· of {base type definition}" + * SPEC (1.2.1) "if {variety} is `atomic` then the string must `match` + * a literal in the `lexical space` of {base type definition}" */ /* * Whitespace-normalize. @@ -24421,9 +24547,9 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, * NOTATIONs need to be processed here, since they need * to lookup in the hashtable of NOTATION declarations of the schema. */ - if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) { - switch (biType->builtInType) { - case XML_SCHEMAS_NOTATION: + if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) { + switch (biType->builtInType) { + case XML_SCHEMAS_NOTATION: ret = xmlSchemaValidateNotation( (xmlSchemaValidCtxtPtr) actxt, ((xmlSchemaValidCtxtPtr) actxt)->schema, @@ -24437,14 +24563,14 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, /* ws = xmlSchemaGetWhiteSpaceFacetValue(type); */ if (valNeeded) ret = xmlSchemaValPredefTypeNodeNoNorm(biType, - value, &val, NULL); + value, &val, node); else ret = xmlSchemaValPredefTypeNodeNoNorm(biType, - value, NULL, NULL); + value, NULL, node); break; } - } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) { - switch (biType->builtInType) { + } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) { + switch (biType->builtInType) { case XML_SCHEMAS_NOTATION: ret = xmlSchemaValidateNotation(NULL, ((xmlSchemaParserCtxtPtr) actxt)->schema, node, @@ -24459,7 +24585,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, ret = xmlSchemaValPredefTypeNodeNoNorm(biType, value, NULL, node); break; - } + } } else { /* * Validation via a public API is not implemented yet. @@ -24476,7 +24602,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, if (WXS_IS_LIST(type)) ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; else - ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1; + ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1; } if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) { /* @@ -24491,10 +24617,10 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, "validating facets of atomic simple type"); goto internal_error; } - if (WXS_IS_LIST(type)) + if (WXS_IS_LIST(type)) ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; else - ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1; + ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1; } } if (fireErrors && (ret > 0)) @@ -24506,9 +24632,9 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, xmlChar *tmpValue = NULL; unsigned long len = 0; xmlSchemaValPtr prevVal = NULL, curVal = NULL; - /* 1.2.2 if {variety} is ·list· then the string must be a sequence - * of white space separated tokens, each of which ·match·es a literal - * in the ·lexical space· of {item type definition} + /* 1.2.2 if {variety} is `list` then the string must be a sequence + * of white space separated tokens, each of which `match`es a literal + * in the `lexical space` of {item type definition} */ /* * Note that XML_SCHEMAS_TYPE_NORMVALUENEEDED will be set if @@ -24519,7 +24645,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, * VAL TODO: Optimize validation of empty values. * VAL TODO: We do not have computed values for lists. */ - itemType = WXS_LIST_ITEMTYPE(type); + itemType = WXS_LIST_ITEMTYPE(type); cur = value; do { while (IS_BLANK_CH(*cur)) @@ -24558,7 +24684,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, } ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2; break; - } + } cur = end; } while (*cur != 0); FREE_AND_NULL(tmpValue); @@ -24579,7 +24705,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, } } if (fireErrors && (ret > 0)) { - /* + /* * Report the normalized value. */ normalize = 1; @@ -24589,10 +24715,10 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, } else if (WXS_IS_UNION(type)) { xmlSchemaTypeLinkPtr memberLink; /* - * TODO: For all datatypes ·derived· by ·union· whiteSpace does - * not apply directly; however, the normalization behavior of ·union· + * TODO: For all datatypes `derived` by `union` whiteSpace does + * not apply directly; however, the normalization behavior of `union` * types is controlled by the value of whiteSpace on that one of the - * ·memberTypes· against which the ·union· is successfully validated. + * `memberTypes` against which the `union` is successfully validated. * * This means that the value is normalized by the first validating * member type, then the facets of the union type are applied. This @@ -24600,8 +24726,8 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, */ /* - * 1.2.3 if {variety} is ·union· then the string must ·match· a - * literal in the ·lexical space· of at least one member of + * 1.2.3 if {variety} is `union` then the string must `match` a + * literal in the `lexical space` of at least one member of * {member type definitions} */ memberLink = xmlSchemaGetUnionSimpleTypeMemberTypes(type); @@ -24609,7 +24735,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, AERROR_INT("xmlSchemaVCheckCVCSimpleType", "union simple type has no member types"); goto internal_error; - } + } /* * Always normalize union type values, since we currently * cannot store the whitespace information with the value @@ -24617,7 +24743,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, * not possible. */ while (memberLink != NULL) { - if (valNeeded) + if (valNeeded) ret = xmlSchemaVCheckCVCSimpleType(actxt, node, memberLink->type, value, &val, 0, 1, 0); else @@ -24640,9 +24766,9 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, */ if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) { /* - * The normalization behavior of ·union· types is controlled by - * the value of whiteSpace on that one of the ·memberTypes· - * against which the ·union· is successfully validated. + * The normalization behavior of `union` types is controlled by + * the value of whiteSpace on that one of the `memberTypes` + * against which the `union` is successfully validated. */ NORMALIZE(memberLink->type); ret = xmlSchemaValidateFacets(actxt, node, type, @@ -24654,7 +24780,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt, "validating facets of union simple type"); goto internal_error; } - ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3; + ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3; } } if (fireErrors && (ret > 0)) @@ -24802,14 +24928,14 @@ xmlSchemaProcessXSIType(xmlSchemaValidCtxtPtr vctxt, /* * SPEC cvc-elt (3.3.4) : (4.3) (Type Derivation OK) - * "The ·local type definition· must be validly + * "The `local type definition` must be validly * derived from the {type definition} given the union of * the {disallowed substitutions} and the {type definition}'s * {prohibited substitutions}, as defined in - * Type Derivation OK (Complex) (§3.4.6) + * Type Derivation OK (Complex) ($3.4.6) * (if it is a complex type definition), * or given {disallowed substitutions} as defined in Type - * Derivation OK (Simple) (§3.14.6) (if it is a simple type + * Derivation OK (Simple) ($3.14.6) (if it is a simple type * definition)." * * {disallowed substitutions}: the "block" on the element decl. @@ -24892,9 +25018,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; @@ -24984,9 +25110,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. @@ -25069,19 +25195,19 @@ xmlSchemaClearAttrInfos(xmlSchemaValidCtxtPtr vctxt) static int xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) { - xmlSchemaTypePtr type = vctxt->inode->typeDef; + xmlSchemaTypePtr type = vctxt->inode->typeDef; xmlSchemaItemListPtr attrUseList; xmlSchemaAttributeUsePtr attrUse = NULL; xmlSchemaAttributePtr attrDecl = NULL; - xmlSchemaAttrInfoPtr iattr, tmpiattr; + xmlSchemaAttrInfoPtr iattr, tmpiattr; int i, j, found, nbAttrs, nbUses; int xpathRes = 0, res, wildIDs = 0, fixed; xmlNodePtr defAttrOwnerElem = NULL; /* * SPEC (cvc-attribute) - * (1) "The declaration must not be ·absent· (see Missing - * Sub-components (§5.3) for how this can fail to be + * (1) "The declaration must not be `absent` (see Missing + * Sub-components ($5.3) for how this can fail to be * the case)." * (2) "Its {type definition} must not be absent." * @@ -25131,15 +25257,15 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) * use with an {attribute declaration} whose {name} matches * the attribute information item's [local name] and whose * {target namespace} is identical to the attribute information - * item's [namespace name] (where an ·absent· {target namespace} + * item's [namespace name] (where an `absent` {target namespace} * is taken to be identical to a [namespace name] with no value), - * then the attribute information must be ·valid· with respect + * then the attribute information must be `valid` with respect * to that attribute use as per Attribute Locally Valid (Use) - * (§3.5.4). In this case the {attribute declaration} of that - * attribute use is the ·context-determined declaration· for the + * ($3.5.4). In this case the {attribute declaration} of that + * attribute use is the `context-determined declaration` for the * attribute information item with respect to Schema-Validity - * Assessment (Attribute) (§3.2.4) and - * Assessment Outcome (Attribute) (§3.2.5). + * Assessment (Attribute) ($3.2.4) and + * Assessment Outcome (Attribute) ($3.2.5). */ iattr->state = XML_SCHEMAS_ATTR_ASSESSED; iattr->use = attrUse; @@ -25173,7 +25299,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) } tmpiattr->state = XML_SCHEMAS_ATTR_ERR_MISSING; tmpiattr->use = attrUse; - tmpiattr->decl = attrDecl; + tmpiattr->decl = attrDecl; } else if ((attrUse->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) && ((attrUse->defValue != NULL) || (attrDecl->defValue != NULL))) { @@ -25198,7 +25324,6 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) if (vctxt->nbAttrInfos == 0) return (0); - nbUses = vctxt->nbAttrInfos; /* * Validate against the wildcard. */ @@ -25217,13 +25342,13 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) continue; /* * SPEC (cvc-complex-type) - * (3.2.2) "The attribute information item must be ·valid· with - * respect to it as defined in Item Valid (Wildcard) (§3.10.4)." + * (3.2.2) "The attribute information item must be `valid` with + * respect to it as defined in Item Valid (Wildcard) ($3.10.4)." * * SPEC Item Valid (Wildcard) (cvc-wildcard) - * "... its [namespace name] must be ·valid· with respect to + * "... its [namespace name] must be `valid` with respect to * the wildcard constraint, as defined in Wildcard allows - * Namespace Name (§3.10.4)." + * Namespace Name ($3.10.4)." */ if (xmlSchemaCheckCVCWildcardNamespace(type->attributeWildcard, iattr->nsName) == 0) { @@ -25259,11 +25384,11 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) * SPEC (cvc-complex-type) * (5) "Let [Definition:] the wild IDs be the set of * all attribute information item to which clause 3.2 - * applied and whose ·validation· resulted in a - * ·context-determined declaration· of mustFind or no - * ·context-determined declaration· at all, and whose + * applied and whose `validation` resulted in a + * `context-determined declaration` of mustFind or no + * `context-determined declaration` at all, and whose * [local name] and [namespace name] resolve (as - * defined by QName resolution (Instance) (§3.15.4)) to + * defined by QName resolution (Instance) ($3.15.4)) to * an attribute declaration whose {type definition} is * or is derived from ID. Then all of the following * must be true:" @@ -25273,7 +25398,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) iattr->typeDef, XML_SCHEMAS_ID)) { /* * SPEC (5.1) "There must be no more than one - * item in ·wild IDs·." + * item in `wild IDs`." */ if (wildIDs != 0) { /* VAL TODO */ @@ -25284,21 +25409,23 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) wildIDs++; /* * SPEC (cvc-complex-type) - * (5.2) "If ·wild IDs· is non-empty, there must not + * (5.2) "If `wild IDs` is non-empty, there must not * be any attribute uses among the {attribute uses} * whose {attribute declaration}'s {type definition} * is or is derived from ID." */ - for (j = 0; j < attrUseList->nbItems; j++) { - if (xmlSchemaIsDerivedFromBuiltInType( - WXS_ATTRUSE_TYPEDEF(attrUseList->items[j]), - XML_SCHEMAS_ID)) { - /* URGENT VAL TODO: implement */ - iattr->state = XML_SCHEMAS_ATTR_ERR_WILD_AND_USE_ID; - TODO - break; - } - } + if (attrUseList != NULL) { + for (j = 0; j < attrUseList->nbItems; j++) { + if (xmlSchemaIsDerivedFromBuiltInType( + WXS_ATTRUSE_TYPEDEF(attrUseList->items[j]), + XML_SCHEMAS_ID)) { + /* URGENT VAL TODO: implement */ + iattr->state = XML_SCHEMAS_ATTR_ERR_WILD_AND_USE_ID; + TODO + break; + } + } + } } } else if (type->attributeWildcard->processContents == XML_SCHEMAS_ANY_LAX) { @@ -25401,7 +25528,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) * VAL TODO: Should we use the *normalized* value? This currently * uses the *initial* value. */ - + if (defAttrOwnerElem) { xmlChar *normValue; const xmlChar *value; @@ -25419,7 +25546,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) if (xmlNewProp(defAttrOwnerElem, iattr->localName, value) == NULL) { VERROR_INT("xmlSchemaVAttributesComplex", - "callling xmlNewProp()"); + "calling xmlNewProp()"); if (normValue != NULL) xmlFree(normValue); goto internal_error; @@ -25492,9 +25619,9 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) fixed = 0; /* * SPEC (cvc-attribute) - * (3) "The item's ·normalized value· must be locally ·valid· - * with respect to that {type definition} as per - * String Valid (§3.14.4)." + * (3) "The item's `normalized value` must be locally `valid` + * with respect to that {type definition} as per + * String Valid ($3.14.4)." * * VAL TODO: Do we already have the * "normalized attribute value" here? @@ -25514,7 +25641,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) iattr->node, iattr->typeDef, iattr->value, NULL, 1, 0, 0); } - + if (res != 0) { if (res == -1) { VERROR_INT("xmlSchemaVAttributesComplex", @@ -25529,12 +25656,12 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) goto eval_idcs; } - if (fixed) { + if (fixed) { /* * SPEC Attribute Locally Valid (Use) (cvc-au) - * "For an attribute information item to be·valid· + * "For an attribute information item to be `valid` * with respect to an attribute use its *normalized* - * value· must match the *canonical* lexical + * value must match the *canonical* lexical * representation of the attribute use's {value * constraint}value, if it is present and fixed." * @@ -25543,7 +25670,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt) */ /* * SPEC Attribute Locally Valid (cvc-attribute) - * (4) "The item's *actual* value· must match the *value* of + * (4) "The item's *actual* value must match the *value* of * the {value constraint}, if it is present and fixed." */ if (iattr->val == NULL) { @@ -25635,8 +25762,8 @@ eval_idcs: xmlSchemaCustomErr(ACTXT_CAST vctxt, XML_SCHEMAV_CVC_AU, NULL, NULL, "The value '%s' does not match the fixed " - "value constraint '%s'", - iattr->value, iattr->vcValue); + "value constraint '%s'", + iattr->value, iattr->vcValue); break; case XML_SCHEMAS_ATTR_ERR_WILD_STRICT_NO_DECL: VERROR(XML_SCHEMAV_CVC_WILDCARD, NULL, @@ -25698,7 +25825,7 @@ xmlSchemaValidateElemWildcard(xmlSchemaValidCtxtPtr vctxt, xmlSchemaElementPtr decl = NULL; decl = xmlSchemaGetElem(vctxt->schema, - vctxt->inode->localName, vctxt->inode->nsName); + vctxt->inode->localName, vctxt->inode->nsName); if (decl != NULL) { vctxt->inode->decl = decl; return (0); @@ -25756,16 +25883,16 @@ static int xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt, const xmlChar *value, xmlSchemaValPtr *val) -{ +{ int ret = 0; xmlSchemaNodeInfoPtr inode = vctxt->inode; /* * cos-valid-default: * Schema Component Constraint: Element Default Valid (Immediate) - * For a string to be a valid default with respect to a type + * For a string to be a valid default with respect to a type * definition the appropriate case among the following must be true: - */ + */ if WXS_IS_COMPLEX(inode->typeDef) { /* * Complex type. @@ -25773,8 +25900,8 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt, * SPEC (2.1) "its {content type} must be a simple type definition * or mixed." * SPEC (2.2.2) "If the {content type} is mixed, then the {content - * type}'s particle must be ·emptiable· as defined by - * Particle Emptiable (§3.9.6)." + * type}'s particle must be `emptiable` as defined by + * Particle Emptiable ($3.9.6)." */ if ((! WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) && ((! WXS_HAS_MIXED_CONTENT(inode->typeDef)) || @@ -25787,18 +25914,18 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt, "or mixed content and a particle emptiable"); return(ret); } - } + } /* - * 1 If the type definition is a simple type definition, then the string - * must be ·valid· with respect to that definition as defined by String - * Valid (§3.14.4). + * 1 If the type definition is a simple type definition, then the string + * must be `valid` with respect to that definition as defined by String + * Valid ($3.14.4). * * AND * - * 2.2.1 If the {content type} is a simple type definition, then the - * string must be ·valid· with respect to that simple type definition - * as defined by String Valid (§3.14.4). - */ + * 2.2.1 If the {content type} is a simple type definition, then the + * string must be `valid` with respect to that simple type definition + * as defined by String Valid ($3.14.4). + */ if (WXS_IS_SIMPLE(inode->typeDef)) { ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST vctxt, @@ -25812,7 +25939,7 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt, if (ret < 0) { VERROR_INT("xmlSchemaCheckCOSValidDefault", "calling xmlSchemaVCheckCVCSimpleType()"); - } + } return (ret); } @@ -25846,13 +25973,13 @@ xmlSchemaVContentModelCallback(xmlSchemaValidCtxtPtr vctxt ATTRIBUTE_UNUSED, static int xmlSchemaValidatorPushElem(xmlSchemaValidCtxtPtr vctxt) -{ +{ vctxt->inode = xmlSchemaGetFreshElemInfo(vctxt); if (vctxt->inode == NULL) { VERROR_INT("xmlSchemaValidatorPushElem", "calling xmlSchemaGetFreshElemInfo()"); return (-1); - } + } vctxt->nbAttrInfos = 0; return (0); } @@ -25875,7 +26002,7 @@ xmlSchemaVCheckINodeDataType(xmlSchemaValidCtxtPtr vctxt, -/* +/* * Process END of element. */ static int @@ -25894,7 +26021,7 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt) */ vctxt->skipDepth = vctxt->depth -1; goto end_elem; - } + } if ((inode->typeDef == NULL) || (inode->flags & XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE)) { /* @@ -25914,8 +26041,8 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt) * Workaround for "anyType". */ if (inode->typeDef->builtInType == XML_SCHEMAS_ANYTYPE) - goto character_content; - + goto character_content; + if ((inode->flags & XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT) == 0) { xmlChar *values[10]; int terminal, nbval = 10, nbneg; @@ -25936,16 +26063,30 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt) #ifdef DEBUG_AUTOMATA xmlGenericError(xmlGenericErrorContext, "AUTOMATON create on '%s'\n", inode->localName); -#endif +#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. - */ + */ xmlRegExecNextValues(inode->regexCtxt, &nbval, &nbneg, &values[0], &terminal); ret = xmlRegExecPushString(inode->regexCtxt, NULL, NULL); - if (ret <= 0) { + if ((ret<0) || ((ret==0) && (!INODE_NILLED(inode)))) { /* * Still missing something. */ @@ -25975,6 +26116,9 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt) } } + +skip_nilled: + if (inode->typeDef->contentType == XML_SCHEMA_CONTENT_ELEMENTS) goto end_elem; @@ -25991,14 +26135,14 @@ character_content: /* * Speedup if no declaration exists. */ - if (WXS_IS_SIMPLE(inode->typeDef)) { + if (WXS_IS_SIMPLE(inode->typeDef)) { ret = xmlSchemaVCheckINodeDataType(vctxt, inode, inode->typeDef, inode->value); } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { ret = xmlSchemaVCheckINodeDataType(vctxt, inode, inode->typeDef->contentTypeDef, inode->value); - } + } if (ret < 0) { VERROR_INT("xmlSchemaValidatorPopElem", "calling xmlSchemaVCheckCVCSimpleType()"); @@ -26007,26 +26151,26 @@ character_content: goto end_elem; } /* - * cvc-elt (3.3.4) : 5 + * cvc-elt (3.3.4) : 5 * The appropriate case among the following must be true: */ /* - * cvc-elt (3.3.4) : 5.1 - * If the declaration has a {value constraint}, - * the item has neither element nor character [children] and + * cvc-elt (3.3.4) : 5.1 + * If the declaration has a {value constraint}, + * the item has neither element nor character [children] and * clause 3.2 has not applied, then all of the following must be true: */ if ((inode->decl->value != NULL) && - (inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) && + (inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) && (! INODE_NILLED(inode))) { /* - * cvc-elt (3.3.4) : 5.1.1 - * If the ·actual type definition· is a ·local type definition· + * cvc-elt (3.3.4) : 5.1.1 + * If the `actual type definition` is a `local type definition` * then the canonical lexical representation of the {value constraint} - * value must be a valid default for the ·actual type definition· as - * defined in Element Default Valid (Immediate) (§3.3.6). + * value must be a valid default for the `actual type definition` as + * defined in Element Default Valid (Immediate) ($3.3.6). */ - /* + /* * NOTE: 'local' above means types acquired by xsi:type. * NOTE: Although the *canonical* value is stated, it is not * relevant if canonical or not. Additionally XML Schema 1.1 @@ -26049,22 +26193,22 @@ character_content: * (see following). */ goto default_psvi; - } - /* - * cvc-elt (3.3.4) : 5.1.2 - * The element information item with the canonical lexical - * representation of the {value constraint} value used as its - * ·normalized value· must be ·valid· with respect to the - * ·actual type definition· as defined by Element Locally Valid (Type) - * (§3.3.4). - */ + } + /* + * cvc-elt (3.3.4) : 5.1.2 + * The element information item with the canonical lexical + * representation of the {value constraint} value used as its + * `normalized value` must be `valid` with respect to the + * `actual type definition` as defined by Element Locally Valid (Type) + * ($3.3.4). + */ if (WXS_IS_SIMPLE(inode->typeDef)) { ret = xmlSchemaVCheckINodeDataType(vctxt, inode, inode->typeDef, inode->decl->value); } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { ret = xmlSchemaVCheckINodeDataType(vctxt, inode, inode->typeDef->contentTypeDef, - inode->decl->value); + inode->decl->value); } if (ret != 0) { if (ret < 0) { @@ -26085,7 +26229,7 @@ default_psvi: xmlChar *normValue; /* * VAL TODO: Normalize the value. - */ + */ normValue = xmlSchemaNormalizeValue(inode->typeDef, inode->decl->value); if (normValue != NULL) { @@ -26098,42 +26242,42 @@ default_psvi: "calling xmlNewText()"); goto internal_error; } else - xmlAddChild(inode->node, textChild); + xmlAddChild(inode->node, textChild); } - - } else if (! INODE_NILLED(inode)) { + + } else if (! INODE_NILLED(inode)) { /* - * 5.2.1 The element information item must be ·valid· with respect - * to the ·actual type definition· as defined by Element Locally - * Valid (Type) (§3.3.4). - */ + * 5.2.1 The element information item must be `valid` with respect + * to the `actual type definition` as defined by Element Locally + * Valid (Type) ($3.3.4). + */ if (WXS_IS_SIMPLE(inode->typeDef)) { /* * SPEC (cvc-type) (3.1) * "If the type definition is a simple type definition, ..." * (3.1.3) "If clause 3.2 of Element Locally Valid - * (Element) (§3.3.4) did not apply, then the ·normalized value· - * must be ·valid· with respect to the type definition as defined - * by String Valid (§3.14.4). - */ + * (Element) ($3.3.4) did not apply, then the `normalized value` + * must be `valid` with respect to the type definition as defined + * by String Valid ($3.14.4). + */ ret = xmlSchemaVCheckINodeDataType(vctxt, inode, inode->typeDef, inode->value); } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { /* * SPEC (cvc-type) (3.2) "If the type definition is a complex type * definition, then the element information item must be - * ·valid· with respect to the type definition as per - * Element Locally Valid (Complex Type) (§3.4.4);" + * `valid` with respect to the type definition as per + * Element Locally Valid (Complex Type) ($3.4.4);" * * SPEC (cvc-complex-type) (2.2) - * "If the {content type} is a simple type definition, ... - * the ·normalized value· of the element information item is - * ·valid· with respect to that simple type definition as - * defined by String Valid (§3.14.4)." + * "If the {content type} is a simple type definition, ... + * the `normalized value` of the element information item is + * `valid` with respect to that simple type definition as + * defined by String Valid ($3.14.4)." */ ret = xmlSchemaVCheckINodeDataType(vctxt, inode, inode->typeDef->contentTypeDef, inode->value); - } + } if (ret != 0) { if (ret < 0) { VERROR_INT("xmlSchemaValidatorPopElem", @@ -26143,7 +26287,7 @@ default_psvi: goto end_elem; } /* - * 5.2.2 If there is a fixed {value constraint} and clause 3.2 has + * 5.2.2 If there is a fixed {value constraint} and clause 3.2 has * not applied, all of the following must be true: */ if ((inode->decl->value != NULL) && @@ -26154,7 +26298,7 @@ default_psvi: * done on computed values. */ /* - * 5.2.2.1 The element information item must have no element + * 5.2.2.1 The element information item must have no element * information item [children]. */ if (inode->flags & @@ -26166,28 +26310,28 @@ default_psvi: goto end_elem; } else { /* - * 5.2.2.2 The appropriate case among the following must + * 5.2.2.2 The appropriate case among the following must * be true: - */ + */ if (WXS_HAS_MIXED_CONTENT(inode->typeDef)) { /* - * 5.2.2.2.1 If the {content type} of the ·actual type - * definition· is mixed, then the *initial value* of the - * item must match the canonical lexical representation + * 5.2.2.2.1 If the {content type} of the `actual type + * definition` is mixed, then the *initial value* of the + * item must match the canonical lexical representation * of the {value constraint} value. * - * ... the *initial value* of an element information - * item is the string composed of, in order, the - * [character code] of each character information item in + * ... the *initial value* of an element information + * item is the string composed of, in order, the + * [character code] of each character information item in * the [children] of that element information item. - */ + */ if (! xmlStrEqual(inode->value, inode->decl->value)){ - /* + /* * VAL TODO: Report invalid & expected values as well. * VAL TODO: Implement the canonical stuff. */ ret = XML_SCHEMAV_CVC_ELT_5_2_2_2_1; - xmlSchemaCustomErr(ACTXT_CAST vctxt, + xmlSchemaCustomErr(ACTXT_CAST vctxt, ret, NULL, NULL, "The initial value '%s' does not match the fixed " "value constraint '%s'", @@ -26196,9 +26340,9 @@ default_psvi: } } else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) { /* - * 5.2.2.2.2 If the {content type} of the ·actual type - * definition· is a simple type definition, then the - * *actual value* of the item must match the canonical + * 5.2.2.2.2 If the {content type} of the `actual type + * definition` is a simple type definition, then the + * *actual value* of the item must match the canonical * lexical representation of the {value constraint} value. */ /* @@ -26213,16 +26357,16 @@ default_psvi: xmlSchemaCustomErr(ACTXT_CAST vctxt, ret, NULL, NULL, "The actual value '%s' does not match the fixed " - "value constraint '%s'", + "value constraint '%s'", inode->value, inode->decl->value); goto end_elem; - } + } } - } + } } } - + end_elem: if (vctxt->depth < 0) { /* TODO: raise error? */ @@ -26232,15 +26376,15 @@ end_elem: vctxt->skipDepth = -1; /* * Evaluate the history of XPath state objects. - */ + */ if (inode->appliedXPath && (xmlSchemaXPathProcessHistory(vctxt, vctxt->depth) == -1)) goto internal_error; /* * MAYBE TODO: - * SPEC (6) "The element information item must be ·valid· with + * SPEC (6) "The element information item must be `valid` with * respect to each of the {identity-constraint definitions} as per - * Identity-constraint Satisfied (§3.11.4)." + * Identity-constraint Satisfied ($3.11.4)." */ /* * PSVI TODO: If we expose IDC node-tables via PSVI then the tables @@ -26248,7 +26392,7 @@ end_elem: * We will currently build IDC node-tables and bubble them only if * keyrefs do exist. */ - + /* * Add the current IDC target-nodes to the IDC node-tables. */ @@ -26282,7 +26426,7 @@ end_elem: */ if (xmlSchemaBubbleIDCNodeTables(vctxt) == -1) goto internal_error; - } + } } /* * Clear the current ielem. @@ -26315,11 +26459,11 @@ end_elem: aidc = aidc->next; } while (aidc != NULL); } - vctxt->depth--; + vctxt->depth--; vctxt->inode = vctxt->elemInfos[vctxt->depth]; /* - * VAL TODO: 7 If the element information item is the ·validation root·, it must be - * ·valid· per Validation Root Valid (ID/IDREF) (§3.3.4). + * VAL TODO: 7 If the element information item is the `validation root`, it must be + * `valid` per Validation Root Valid (ID/IDREF) ($3.3.4). */ return (ret); @@ -26400,11 +26544,11 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt) * Fallback to "anyType". * * SPEC (cvc-assess-elt) - * "If the item cannot be ·strictly assessed·, [...] + * "If the item cannot be `strictly assessed`, [...] * an element information item's schema validity may be laxly - * assessed if its ·context-determined declaration· is not - * skip by ·validating· with respect to the ·ur-type - * definition· as per Element Locally Valid (Type) (§3.3.4)." + * assessed if its `context-determined declaration` is not + * skip by `validating` with respect to the `ur-type + * definition` as per Element Locally Valid (Type) ($3.3.4)." */ vctxt->inode->typeDef = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE); @@ -26476,9 +26620,9 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt) * SPEC (2.4) "If the {content type} is element-only or mixed, * then the sequence of the element information item's * element information item [children], if any, taken in - * order, is ·valid· with respect to the {content type}'s + * order, is `valid` with respect to the {content type}'s * particle, as defined in Element Sequence Locally Valid - * (Particle) (§3.9.4)." + * (Particle) ($3.9.4)." */ ret = xmlRegExecPushString2(regexCtxt, vctxt->inode->localName, @@ -26575,7 +26719,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt, if (consumed != NULL) *consumed = 0; if (INODE_NILLED(vctxt->inode)) { - /* + /* * SPEC cvc-elt (3.3.4 - 3.2.1) * "The element information item must have no character or * element information item [children]." @@ -26591,7 +26735,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt, * information item [children]." */ if (vctxt->inode->typeDef->contentType == - XML_SCHEMA_CONTENT_EMPTY) { + XML_SCHEMA_CONTENT_EMPTY) { VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, NULL, "Character content is not allowed, " "because the content type is empty"); @@ -26602,12 +26746,12 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt, XML_SCHEMA_CONTENT_ELEMENTS) { if ((nodeType != XML_TEXT_NODE) || (! xmlSchemaIsBlank((xmlChar *) value, len))) { - /* - * SPEC cvc-complex-type (2.3) - * "If the {content type} is element-only, then the - * element information item has no character information - * item [children] other than those whose [character - * code] is defined as a white space in [XML 1.0 (Second + /* + * SPEC cvc-complex-type (2.3) + * "If the {content type} is element-only, then the + * element information item has no character information + * item [children] other than those whose [character + * code] is defined as a white space in [XML 1.0 (Second * Edition)]." */ VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, NULL, @@ -26617,7 +26761,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt, } return (0); } - + if ((value == NULL) || (value[0] == 0)) return (0); /* @@ -26629,7 +26773,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt, ((vctxt->inode->decl == NULL) || (vctxt->inode->decl->value == NULL))) return (0); - + if (vctxt->inode->value == NULL) { /* * Set the value. @@ -26672,7 +26816,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt, len = xmlStrlen(value); /* * Concat the value. - */ + */ if (vctxt->inode->flags & XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES) { vctxt->inode->value = BAD_CAST xmlStrncat( (xmlChar *) vctxt->inode->value, value, len); @@ -26681,7 +26825,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt, BAD_CAST xmlStrncatNew(vctxt->inode->value, value, len); vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES; } - } + } return (0); } @@ -26698,7 +26842,7 @@ xmlSchemaValidateElem(xmlSchemaValidCtxtPtr vctxt) goto internal_error; } if (vctxt->xsiAssemble) { - /* + /* * We will stop validation if there was an error during * dynamic schema construction. * Note that we simply set @skipDepth to 0, this could @@ -26715,6 +26859,11 @@ xmlSchemaValidateElem(xmlSchemaValidCtxtPtr vctxt) vctxt->skipDepth = 0; return(ret); } + /* + * 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); } if (vctxt->depth > 0) { /* @@ -26808,15 +26957,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; } /* @@ -26897,7 +27046,7 @@ root_found: nodeType = xmlTextReaderNodeType(vctxt->reader); if (nodeType == XML_ELEMENT_NODE) { - + vctxt->depth++; if (xmlSchemaValidatorPushElem(vctxt) == -1) { VERROR_INT("xmlSchemaVReaderWalk", @@ -27063,17 +27212,17 @@ internal_error: #endif /************************************************************************ - * * - * SAX validation handlers * - * * + * * + * SAX validation handlers * + * * ************************************************************************/ /* * Process text content. */ static void -xmlSchemaSAXHandleText(void *ctx, - const xmlChar * ch, +xmlSchemaSAXHandleText(void *ctx, + const xmlChar * ch, int len) { xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx; @@ -27097,10 +27246,10 @@ xmlSchemaSAXHandleText(void *ctx, * Process CDATA content. */ static void -xmlSchemaSAXHandleCDataSection(void *ctx, - const xmlChar * ch, +xmlSchemaSAXHandleCDataSection(void *ctx, + const xmlChar * ch, int len) -{ +{ xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx; if (vctxt->depth < 0) @@ -27134,20 +27283,20 @@ xmlSchemaSAXHandleReference(void *ctx ATTRIBUTE_UNUSED, static void xmlSchemaSAXHandleStartElementNs(void *ctx, - const xmlChar * localname, - const xmlChar * prefix ATTRIBUTE_UNUSED, - const xmlChar * URI, - int nb_namespaces, - const xmlChar ** namespaces, - int nb_attributes, - int nb_defaulted ATTRIBUTE_UNUSED, + const xmlChar * localname, + const xmlChar * prefix ATTRIBUTE_UNUSED, + const xmlChar * URI, + int nb_namespaces, + const xmlChar ** namespaces, + int nb_attributes, + int nb_defaulted ATTRIBUTE_UNUSED, const xmlChar ** attributes) -{ +{ xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx; int ret; xmlSchemaNodeInfoPtr ielem; int i, j; - + /* * SAX VAL TODO: What to do with nb_defaulted? */ @@ -27175,16 +27324,16 @@ xmlSchemaSAXHandleStartElementNs(void *ctx, ielem->flags |= XML_SCHEMA_ELEM_INFO_EMPTY; /* * Register namespaces on the elem info. - */ + */ if (nb_namespaces != 0) { /* * Although the parser builds its own namespace list, * we have no access to it, so we'll use an own one. */ - for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) { + for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) { /* * Store prefix and namespace name. - */ + */ if (ielem->nsBindings == NULL) { ielem->nsBindings = (const xmlChar **) xmlMalloc(10 * @@ -27220,7 +27369,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx, } else ielem->nsBindings[ielem->nbNsBindings * 2 + 1] = namespaces[j+1]; - ielem->nbNsBindings++; + ielem->nbNsBindings++; } } /* @@ -27234,7 +27383,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx, for (j = 0, i = 0; i < nb_attributes; i++, j += 5) { /* * Duplicate the value. - */ + */ value = xmlStrndup(attributes[j+3], attributes[j+4] - attributes[j+3]); /* @@ -27261,7 +27410,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx, goto internal_error; } goto exit; - } + } exit: return; @@ -27316,9 +27465,9 @@ internal_error: } /************************************************************************ - * * - * Validation interfaces * - * * + * * + * Validation interfaces * + * * ************************************************************************/ /** @@ -27348,8 +27497,28 @@ 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: - * @ctxt: the schema validation context + * @vctxt: the schema validation context * * Free the resources associated to the schema validation context; * leaves some fields alive intended for reuse of the context. @@ -27371,7 +27540,7 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt) #ifdef LIBXML_READER_ENABLED vctxt->reader = NULL; #endif - vctxt->hasKeyrefs = 0; + vctxt->hasKeyrefs = 0; if (vctxt->value != NULL) { xmlSchemaFreeValue(vctxt->value); @@ -27441,7 +27610,7 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt) break; xmlSchemaClearElemInfo(vctxt, ei); } - } + } xmlSchemaItemListClear(vctxt->nodeQNames); /* Recreate the dict. */ xmlDictFree(vctxt->dict); @@ -27450,6 +27619,11 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt) * where the user provides the dict? */ vctxt->dict = xmlDictCreate(); + + if (vctxt->filename != NULL) { + xmlFree(vctxt->filename); + vctxt->filename = NULL; + } } /** @@ -27535,6 +27709,8 @@ xmlSchemaFreeValidCtxt(xmlSchemaValidCtxtPtr ctxt) xmlSchemaItemListFree(ctxt->nodeQNames); if (ctxt->dict != NULL) xmlDictFree(ctxt->dict); + if (ctxt->filename != NULL) + xmlFree(ctxt->filename); xmlFree(ctxt); } @@ -27543,7 +27719,7 @@ xmlSchemaFreeValidCtxt(xmlSchemaValidCtxtPtr ctxt) * @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. */ @@ -27602,7 +27778,7 @@ xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt, /** * xmlSchemaGetValidErrors: - * @ctxt: a XML-Schema validation context + * @ctxt: a XML-Schema validation context * @err: the error function result * @warn: the warning function result * @ctx: the functions context result @@ -27663,7 +27839,7 @@ xmlSchemaSetValidOptions(xmlSchemaValidCtxtPtr ctxt, /** * xmlSchemaValidCtxtGetOptions: - * @ctxt: a schema validation context + * @ctxt: a schema validation context * * Get the validation context options. * @@ -27689,7 +27865,10 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt) const xmlChar *nsName; /* DOC VAL TODO: Move this to the start function. */ - valRoot = xmlDocGetRootElement(vctxt->doc); + if (vctxt->validationRoot != NULL) + valRoot = vctxt->validationRoot; + else + valRoot = xmlDocGetRootElement(vctxt->doc); if (valRoot == NULL) { /* VAL TODO: Error code? */ VERROR(1, NULL, "The document has no document element"); @@ -27731,7 +27910,7 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt) nsName = NULL; ret = xmlSchemaValidatorPushAttribute(vctxt, (xmlNodePtr) attr, - /* + /* * Note that we give it the line number of the * parent element. */ @@ -27787,7 +27966,7 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt) (node->type == XML_ENTITY_REF_NODE)) { /* * DOC VAL TODO: What to do with entities? - */ + */ VERROR_INT("xmlSchemaVDocWalk", "there is at least one entity reference in the node-tree " "currently being validated. Processing of entities with " @@ -27847,7 +28026,7 @@ static int xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) { /* * Some initialization. - */ + */ vctxt->err = 0; vctxt->nberrors = 0; vctxt->depth = -1; @@ -27864,9 +28043,9 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) { */ if (vctxt->schema == NULL) { xmlSchemaParserCtxtPtr pctxt; - + vctxt->xsiAssemble = 1; - /* + /* * If not schema was given then we will create a schema * dynamically using XSI schema locations. * @@ -27882,8 +28061,8 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) { */ vctxt->schema = xmlSchemaNewSchema(pctxt); if (vctxt->schema == NULL) - return (-1); - /* + return (-1); + /* * Create the schema construction context. */ pctxt->constructor = xmlSchemaConstructionCtxtCreate(pctxt->dict); @@ -27894,14 +28073,13 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) { * Take ownership of the constructor to be able to free it. */ pctxt->ownsConstructor = 1; - } + } /* - * Augment the IDC definitions. + * Augment the IDC definitions for the main schema and all imported ones + * NOTE: main schema if the first in the imported list */ - if (vctxt->schema->idcDef != NULL) { - xmlHashScan(vctxt->schema->idcDef, - (xmlHashScanner) xmlSchemaAugmentIDC, vctxt); - } + xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentImportedIDC, vctxt); + return(0); } @@ -28011,9 +28189,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; @@ -28089,8 +28267,8 @@ externalSubsetSplit(void *ctx, const xmlChar *name, { xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx; if ((ctxt != NULL) && (ctxt->user_sax != NULL) && - (ctxt->user_sax->internalSubset != NULL)) - ctxt->user_sax->internalSubset(ctxt->user_data, name, ExternalID, + (ctxt->user_sax->externalSubset != NULL)) + ctxt->user_sax->externalSubset(ctxt->user_data, name, ExternalID, SystemID); } @@ -28296,8 +28474,8 @@ cdataBlockSplit(void *ctx, const xmlChar *value, int len) if (ctxt == NULL) return; if ((ctxt->user_sax != NULL) && - (ctxt->user_sax->ignorableWhitespace != NULL)) - ctxt->user_sax->ignorableWhitespace(ctxt->user_data, value, len); + (ctxt->user_sax->cdataBlock != NULL)) + ctxt->user_sax->cdataBlock(ctxt->user_data, value, len); if (ctxt->ctxt != NULL) xmlSchemaSAXHandleCDataSection(ctxt->ctxt, value, len); } @@ -28316,10 +28494,10 @@ referenceSplit(void *ctx, const xmlChar *name) } static void -startElementNsSplit(void *ctx, const xmlChar * localname, - const xmlChar * prefix, const xmlChar * URI, - int nb_namespaces, const xmlChar ** namespaces, - int nb_attributes, int nb_defaulted, +startElementNsSplit(void *ctx, const xmlChar * localname, + const xmlChar * prefix, const xmlChar * URI, + int nb_namespaces, const xmlChar ** namespaces, + int nb_attributes, int nb_defaulted, const xmlChar ** attributes) { xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx; if (ctxt == NULL) @@ -28338,7 +28516,7 @@ startElementNsSplit(void *ctx, const xmlChar * localname, } static void -endElementNsSplit(void *ctx, const xmlChar * localname, +endElementNsSplit(void *ctx, const xmlChar * localname, const xmlChar * prefix, const xmlChar * URI) { xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx; if (ctxt == NULL) @@ -28379,7 +28557,7 @@ xmlSchemaSAXPlug(xmlSchemaValidCtxtPtr ctxt, old_sax = *sax; if ((old_sax != NULL) && (old_sax->initialized != XML_SAX2_MAGIC)) return(NULL); - if ((old_sax != NULL) && + if ((old_sax != NULL) && (old_sax->startElementNs == NULL) && (old_sax->endElementNs == NULL) && ((old_sax->startElement != NULL) || (old_sax->endElement != NULL))) return(NULL); @@ -28397,7 +28575,7 @@ xmlSchemaSAXPlug(xmlSchemaValidCtxtPtr ctxt, ret->ctxt = ctxt; ret->user_sax_ptr = sax; ret->user_sax = old_sax; - if (old_sax == NULL) { + if (old_sax == NULL) { /* * go direct, no need for the split block and functions. */ @@ -28418,7 +28596,7 @@ xmlSchemaSAXPlug(xmlSchemaValidCtxtPtr ctxt, } else { /* * for each callback unused by Schemas initialize it to the Split - * routine only if non NULL in the user block, this can speed up + * routine only if non NULL in the user block, this can speed up * things at the SAX level. */ if (old_sax->internalSubset != NULL) @@ -28530,6 +28708,63 @@ 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 @@ -28571,7 +28806,8 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt, if (options) xmlCtxtUseOptions(pctxt, options); #endif - pctxt->linenumbers = 1; + pctxt->linenumbers = 1; + xmlSchemaValidateSetLocator(ctxt, xmlSchemaValidateStreamLocator, pctxt); inputStream = xmlNewIOInputStream(pctxt, input, enc);; if (inputStream == NULL) { @@ -28600,7 +28836,7 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt, ret = ctxt->parserCtxt->errNo; if (ret == 0) ret = 1; - } + } done: ctxt->parserCtxt = NULL; @@ -28639,16 +28875,33 @@ xmlSchemaValidateFile(xmlSchemaValidCtxtPtr ctxt, if ((ctxt == NULL) || (filename == NULL)) return (-1); - + input = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE); if (input == NULL) return (-1); ret = xmlSchemaValidateStream(ctxt, input, XML_CHAR_ENCODING_NONE, - NULL, NULL); + NULL, NULL); return (ret); } +/** + * xmlSchemaValidCtxtGetParserCtxt: + * @ctxt: a schema validation context + * + * allow access to the parser context of the schema validation context + * + * Returns the parser context of the schema validation context or NULL + * in case of error. + */ +xmlParserCtxtPtr +xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt) +{ + if (ctxt == NULL) + return(NULL); + return (ctxt->parserCtxt); +} + #define bottom_xmlschemas #include "elfgcchack.h" #endif /* LIBXML_SCHEMAS_ENABLED */ |