summaryrefslogtreecommitdiff
path: root/xmlschemas.c
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2006-06-08 10:59:26 +0200
committerMike Hommey <glandium@debian.org>2006-06-08 10:59:26 +0200
commita7e9d3f37d5e9fba4b9acaa43e7c12b6d9a669ae (patch)
treef70d9afbc2bc584860755cb0f933a4405ee3c338 /xmlschemas.c
parent07a67fa4bcc1b8bf2651ab41e5fc54a05059cf7e (diff)
downloadlibxml2-a7e9d3f37d5e9fba4b9acaa43e7c12b6d9a669ae.tar.gz
Load /tmp/libxml2-2.6.26 intoupstream/2.6.26.dfsg
libxml2/branches/upstream/current.
Diffstat (limited to 'xmlschemas.c')
-rw-r--r--xmlschemas.c97
1 files changed, 73 insertions, 24 deletions
diff --git a/xmlschemas.c b/xmlschemas.c
index 453a31c..ff89e2c 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -12551,9 +12551,21 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
*/
for (i = 0; i < substGroup->members->nbItems; i++) {
member = (xmlSchemaElementPtr) substGroup->members->items[i];
- tmp = xmlAutomataNewOnceTrans2(pctxt->am, start, NULL,
- member->name, member->targetNamespace,
- 1, 1, member);
+ /*
+ * NOTE: This fixes bug #341150. xmlAutomataNewOnceTrans2()
+ * 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
+ * intended for the above "counter" section originally. I.e.,
+ * check xs:all with subst-groups.
+ *
+ * tmp = xmlAutomataNewOnceTrans2(pctxt->am, start, NULL,
+ * member->name, member->targetNamespace,
+ * 1, 1, member);
+ */
+ tmp = xmlAutomataNewTransition2(pctxt->am, start, NULL,
+ member->name, member->targetNamespace, member);
xmlAutomataNewEpsilon(pctxt->am, tmp, end);
}
} else {
@@ -21353,12 +21365,17 @@ xmlSchemaAssembleByLocation(xmlSchemaValidCtxtPtr vctxt,
location, NULL, NULL, 0, node, NULL, nsName,
&bucket);
if (ret != 0)
+ return(ret);
+ if (bucket == NULL) {
+ /*
+ * Generate a warning that the document could not be located.
+ */
+ xmlSchemaCustomWarning(ACTXT_CAST vctxt, XML_SCHEMAV_MISC,
+ node, NULL,
+ "The document at location '%s' could not be acquired",
+ location, NULL, NULL);
return(ret);
- if (bucket == NULL) {
- PERROR_INT("xmlSchemaAssembleByLocation",
- "no schema bucket acquired");
- return(-1);
- }
+ }
/*
* The first located schema will be handled as if all other
* schemas imported by XSI were imported by this first schema.
@@ -21473,6 +21490,9 @@ xmlSchemaAssembleByXSI(xmlSchemaValidCtxtPtr vctxt)
return (0);
cur = iattr->value;
do {
+ /*
+ * TODO: Move the string parsing mechanism away from here.
+ */
if (iattr->metaType == XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC) {
/*
* Get the namespace name.
@@ -21484,7 +21504,7 @@ xmlSchemaAssembleByXSI(xmlSchemaValidCtxtPtr vctxt)
end++;
if (end == cur)
break;
- count++;
+ count++; /* TODO: Don't use the schema's dict. */
nsname = xmlDictLookup(vctxt->schema->dict, cur, end - cur);
cur = end;
}
@@ -21496,9 +21516,22 @@ xmlSchemaAssembleByXSI(xmlSchemaValidCtxtPtr vctxt)
end = cur;
while ((*end != 0) && (!(IS_BLANK_CH(*end))))
end++;
- if (end == cur)
+ if (end == cur) {
+ if (iattr->metaType ==
+ XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC)
+ {
+ /*
+ * 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 "
+ "name and the document's URI", NULL, NULL, NULL);
+ }
break;
- count++;
+ }
+ count++; /* TODO: Don't use the schema's dict. */
location = xmlDictLookup(vctxt->schema->dict, cur, end - cur);
cur = end;
ret = xmlSchemaAssembleByLocation(vctxt, vctxt->schema,
@@ -24811,9 +24844,10 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
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)
@@ -25056,6 +25090,15 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
return (0);
/*
+ * Get the owner element; needed for creation of default attributes.
+ * This fixes bug #341337, reported by David Grohmann.
+ */
+ if (vctxt->options & XML_SCHEMA_VAL_VC_I_CREATE) {
+ xmlSchemaNodeInfoPtr ielem = vctxt->elemInfos[vctxt->depth];
+ if (ielem && ielem->node && ielem->node->doc)
+ defAttrOwnerElem = ielem->node;
+ }
+ /*
* Validate values, create default attributes, evaluate IDCs.
*/
for (i = 0; i < vctxt->nbAttrInfos; i++) {
@@ -25096,8 +25139,10 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
if (iattr->state == XML_SCHEMAS_ATTR_DEFAULT) {
/*
* Default/fixed attributes.
+ * We need the value only if we need to resolve IDCs or
+ * will create default attributes.
*/
- if (xpathRes) {
+ if ((xpathRes) || (defAttrOwnerElem)) {
if (iattr->use->defValue != NULL) {
iattr->value = (xmlChar *) iattr->use->defValue;
iattr->val = iattr->use->defVal;
@@ -25127,8 +25172,8 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
* VAL TODO: Should we use the *normalized* value? This currently
* uses the *initial* value.
*/
- if ((vctxt->options & XML_SCHEMA_VAL_VC_I_CREATE) &&
- (iattr->node != NULL) && (iattr->node->doc != NULL)) {
+
+ if (defAttrOwnerElem) {
xmlChar *normValue;
const xmlChar *value;
@@ -25142,7 +25187,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
value = BAD_CAST normValue;
if (iattr->nsName == NULL) {
- if (xmlNewProp(iattr->node->parent,
+ if (xmlNewProp(defAttrOwnerElem,
iattr->localName, value) == NULL) {
VERROR_INT("xmlSchemaVAttributesComplex",
"callling xmlNewProp()");
@@ -25153,8 +25198,8 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
} else {
xmlNsPtr ns;
- ns = xmlSearchNsByHref(iattr->node->doc,
- iattr->node->parent, iattr->nsName);
+ ns = xmlSearchNsByHref(defAttrOwnerElem->doc,
+ defAttrOwnerElem, iattr->nsName);
if (ns == NULL) {
xmlChar prefix[12];
int counter = 0;
@@ -25165,8 +25210,8 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
*/
do {
snprintf((char *) prefix, 12, "p%d", counter++);
- ns = xmlSearchNs(iattr->node->doc,
- iattr->node->parent, BAD_CAST prefix);
+ ns = xmlSearchNs(defAttrOwnerElem->doc,
+ defAttrOwnerElem, BAD_CAST prefix);
if (counter > 1000) {
VERROR_INT(
"xmlSchemaVAttributesComplex",
@@ -25186,8 +25231,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
* If we have QNames: do we need to ensure there's a
* prefix defined for the QName?
*/
- xmlNewNsProp(iattr->node->parent, ns,
- iattr->localName, value);
+ xmlNewNsProp(defAttrOwnerElem, ns, iattr->localName, value);
}
if (normValue != NULL)
xmlFree(normValue);
@@ -27496,8 +27540,13 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt)
(node->type == XML_ENTITY_REF_NODE)) {
/*
* DOC VAL TODO: What to do with entities?
- */
- TODO
+ */
+ VERROR_INT("xmlSchemaVDocWalk",
+ "there is at least one entity reference in the node-tree "
+ "currently being validated. Processing of entities with "
+ "this XML Schema processor is not supported (yet). Please "
+ "substitute entities before validation.");
+ goto internal_error;
} else {
goto leave_node;
/*