mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-10 08:58:16 +03:00
Added c-props-correct constraint to check for equal cardinality of
* xmlschemas.c: Added c-props-correct constraint to check for equal cardinality of keyref/key. * include/libxml/xmlerror.h: Added an error code.
This commit is contained in:
parent
8798b735a6
commit
c306d904c6
@ -1,3 +1,9 @@
|
||||
Fri Jul 8 23:35:00 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
||||
|
||||
* xmlschemas.c: Added c-props-correct constraint to check
|
||||
for equal cardinality of keyref/key.
|
||||
* include/libxml/xmlerror.h: Added an error code.
|
||||
|
||||
Fri Jul 8 21:56:04 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
||||
|
||||
* pattern.c: Fixed evaluation of attributes. Actually only
|
||||
|
@ -759,6 +759,7 @@ typedef enum {
|
||||
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */
|
||||
XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */
|
||||
XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */
|
||||
XML_SCHEMAP_C_PROPS_CORRECT, /* 3080 */
|
||||
XML_MODULE_OPEN = 4900, /* 4900 */
|
||||
XML_MODULE_CLOSE, /* 4901 */
|
||||
XML_CHECK_FOUND_ELEMENT = 5000,
|
||||
|
57
xmlschemas.c
57
xmlschemas.c
@ -7239,6 +7239,8 @@ xmlSchemaParseIDC(xmlSchemaParserCtxtPtr ctxt,
|
||||
item->name = name;
|
||||
item->type = idcCategory;
|
||||
item->node = node;
|
||||
if (ctxt->assemble != NULL)
|
||||
xmlSchemaAddAssembledItem(ctxt, (xmlSchemaTypePtr) item);
|
||||
/*
|
||||
* The target namespace of the parent element declaration.
|
||||
*/
|
||||
@ -17572,27 +17574,50 @@ xmlSchemaAttrFixup(xmlSchemaAttributePtr item,
|
||||
*/
|
||||
static void
|
||||
xmlSchemaResolveIDCKeyRef(xmlSchemaIDCPtr idc,
|
||||
xmlSchemaParserCtxtPtr ctxt,
|
||||
xmlSchemaParserCtxtPtr pctxt,
|
||||
const xmlChar * name ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (idc->type != XML_SCHEMA_TYPE_IDC_KEYREF)
|
||||
return;
|
||||
if (idc->ref->name != NULL) {
|
||||
idc->ref->item = (xmlSchemaBasicItemPtr) xmlHashLookup2(
|
||||
ctxt->schema->idcDef,
|
||||
pctxt->schema->idcDef,
|
||||
idc->ref->name,
|
||||
idc->ref->targetNamespace);
|
||||
if (idc->ref->item == NULL) {
|
||||
/*
|
||||
* TODO: It is actually not an error to fail to resolve.
|
||||
*/
|
||||
xmlSchemaPResCompAttrErr(ctxt,
|
||||
xmlSchemaPResCompAttrErr(pctxt,
|
||||
XML_SCHEMAP_SRC_RESOLVE,
|
||||
(xmlSchemaTypePtr) idc, idc->node,
|
||||
"refer", idc->ref->name,
|
||||
idc->ref->targetNamespace,
|
||||
XML_SCHEMA_TYPE_IDC_KEYREF, NULL);
|
||||
return;
|
||||
} else {
|
||||
if (idc->nbFields !=
|
||||
((xmlSchemaIDCPtr) idc->ref->item)->nbFields) {
|
||||
xmlChar *str = NULL;
|
||||
xmlSchemaIDCPtr refer;
|
||||
|
||||
refer = (xmlSchemaIDCPtr) idc->ref->item;
|
||||
/*
|
||||
* SPEC c-props-correct(2)
|
||||
* "If the {identity-constraint category} is keyref,
|
||||
* the cardinality of the {fields} must equal that of
|
||||
* the {fields} of the {referenced key}.
|
||||
*/
|
||||
xmlSchemaPCustomErr(pctxt,
|
||||
XML_SCHEMAP_C_PROPS_CORRECT,
|
||||
NULL, (xmlSchemaTypePtr) idc, idc->node,
|
||||
"The cardinality of the keyref differs from the "
|
||||
"cardinality of the referenced key '%s'",
|
||||
xmlSchemaFormatQName(&str, refer->targetNamespace,
|
||||
refer->name)
|
||||
);
|
||||
FREE_AND_NULL(str)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17980,16 +18005,18 @@ xmlSchemaPostSchemaAssembleFixup(xmlSchemaParserCtxtPtr ctxt)
|
||||
case XML_SCHEMA_TYPE_ATTRIBUTE:
|
||||
xmlSchemaAttrFixup((xmlSchemaAttributePtr) item, ctxt, NULL);
|
||||
break;
|
||||
case XML_SCHEMA_TYPE_ELEMENT:
|
||||
xmlSchemaElementFixup((xmlSchemaElementPtr) item, ctxt,
|
||||
NULL, NULL, NULL);
|
||||
break;
|
||||
case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:
|
||||
xmlSchemaAttrGrpFixup((xmlSchemaAttributeGroupPtr) item,
|
||||
ctxt, NULL);
|
||||
break;
|
||||
case XML_SCHEMA_TYPE_PARTICLE:
|
||||
xmlSchemaMiscRefFixup((xmlSchemaTreeItemPtr) item, ctxt, NULL);
|
||||
break;
|
||||
case XML_SCHEMA_TYPE_IDC_KEY:
|
||||
case XML_SCHEMA_TYPE_IDC_UNIQUE:
|
||||
case XML_SCHEMA_TYPE_IDC_KEYREF:
|
||||
xmlSchemaResolveIDCKeyRef((xmlSchemaIDCPtr) item, ctxt, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -18035,6 +18062,22 @@ xmlSchemaPostSchemaAssembleFixup(xmlSchemaParserCtxtPtr ctxt)
|
||||
ctxt, NULL);
|
||||
}
|
||||
}
|
||||
if (ctxt->nberrors != 0)
|
||||
return;
|
||||
for (i = 0; i < nbItems; i++) {
|
||||
item = items[i];
|
||||
switch (item->type) {
|
||||
case XML_SCHEMA_TYPE_ELEMENT:
|
||||
xmlSchemaElementFixup((xmlSchemaElementPtr) item, ctxt,
|
||||
NULL, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ctxt->nberrors != 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Fixup for simple/complex types.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user