MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlSchemaCheckAttrGroupCircular

Function xmlSchemaCheckAttrGroupCircular

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:19023–19071  ·  view source on GitHub ↗

* xmlSchemaCheckAttrGroupCircular: * attrGr: the attribute group definition * @ctxt: the parser context * @name: the name * * Checks for circular references of attribute groups. */

Source from the content-addressed store, hash-verified

19021 * Checks for circular references of attribute groups.
19022 */
19023static int
19024xmlSchemaCheckAttrGroupCircular(xmlSchemaAttributeGroupPtr attrGr,
19025 xmlSchemaParserCtxtPtr ctxt)
19026{
19027 /*
19028 * Schema Representation Constraint:
19029 * Attribute Group Definition Representation OK
19030 * 3 Circular group reference is disallowed outside <redefine>.
19031 * That is, unless this element information item's parent is
19032 * <redefine>, then among the [children], if any, there must
19033 * not be an <attributeGroup> with ref [attribute] which resolves
19034 * to the component corresponding to this <attributeGroup>. Indirect
19035 * circularity is also ruled out. That is, when QName resolution
19036 * (Schema Document) ($3.15.3) is applied to a `QName` arising from
19037 * any <attributeGroup>s with a ref [attribute] among the [children],
19038 * it must not be the case that a `QName` is encountered at any depth
19039 * which resolves to the component corresponding to this <attributeGroup>.
19040 */
19041 if (attrGr->attrUses == NULL)
19042 return(0);
19043 else if ((attrGr->flags & XML_SCHEMAS_ATTRGROUP_HAS_REFS) == 0)
19044 return(0);
19045 else {
19046 xmlSchemaQNameRefPtr circ;
19047
19048 circ = xmlSchemaCheckAttrGroupCircularRecur(attrGr,
19049 (xmlSchemaItemListPtr) attrGr->attrUses);
19050 if (circ != NULL) {
19051 xmlChar *str = NULL;
19052 /*
19053 * TODO: Report the referenced attr group as QName.
19054 */
19055 xmlSchemaPCustomErr(ctxt,
19056 XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3,
19057 NULL, WXS_ITEM_NODE(WXS_BASIC_CAST circ),
19058 "Circular reference to the attribute group '%s' "
19059 "defined", xmlSchemaGetComponentQName(&str, attrGr));
19060 FREE_AND_NULL(str);
19061 /*
19062 * NOTE: We will cut the reference to avoid further
19063 * confusion of the processor.
19064 * BADSPEC TODO: The spec should define how to process in this case.
19065 */
19066 circ->item = NULL;
19067 return(ctxt->err);
19068 }
19069 }
19070 return(0);
19071}
19072
19073static int
19074xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt,

Callers 1

xmlSchemaFixupComponentsFunction · 0.85

Calls 3

FREE_AND_NULLFunction · 0.85

Tested by

no test coverage detected