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

Function xmlSchemaCheckCVCIDCKeyRef

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:23700–23844  ·  view source on GitHub ↗

* xmlSchemaCheckCVCIDCKeyRef: * @vctxt: the WXS validation context * @elemDecl: the element declaration * * Check the cvc-idc-keyref constraints. */

Source from the content-addressed store, hash-verified

23698 * Check the cvc-idc-keyref constraints.
23699 */
23700static int
23701xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
23702{
23703 xmlSchemaIDCMatcherPtr matcher;
23704 xmlSchemaPSVIIDCBindingPtr bind;
23705
23706 matcher = vctxt->inode->idcMatchers;
23707 /*
23708 * Find a keyref.
23709 */
23710 while (matcher != NULL) {
23711 if ((matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) &&
23712 matcher->targets &&
23713 matcher->targets->nbItems)
23714 {
23715 int i, j, k, res, nbFields, hasDupls;
23716 xmlSchemaPSVIIDCKeyPtr *refKeys, *keys;
23717 xmlSchemaPSVIIDCNodePtr refNode = NULL;
23718 xmlHashTablePtr table = NULL;
23719
23720 nbFields = matcher->aidc->def->nbFields;
23721
23722 /*
23723 * Find the IDC node-table for the referenced IDC key/unique.
23724 */
23725 bind = vctxt->inode->idcTable;
23726 while (bind != NULL) {
23727 if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item ==
23728 bind->definition)
23729 break;
23730 bind = bind->next;
23731 }
23732 hasDupls = (bind && bind->dupls && bind->dupls->nbItems) ? 1 : 0;
23733 /*
23734 * Search for a matching key-sequences.
23735 */
23736 if (bind) {
23737 table = xmlHashCreate(bind->nbNodes * 2);
23738 for (j = 0; j < bind->nbNodes; j++) {
23739 xmlChar *value;
23740 xmlIDCHashEntryPtr r, e;
23741 keys = bind->nodeTable[j]->keys;
23742 xmlSchemaHashKeySequence(vctxt, &value, keys, nbFields);
23743 e = xmlMalloc(sizeof *e);
23744 e->index = j;
23745 r = xmlHashLookup(table, value);
23746 if (r) {
23747 e->next = r->next;
23748 r->next = e;
23749 } else {
23750 e->next = NULL;
23751 xmlHashAddEntry(table, value, e);
23752 }
23753 FREE_AND_NULL(value);
23754 }
23755 }
23756 for (i = 0; i < matcher->targets->nbItems; i++) {
23757 res = 0;

Callers 1

Calls 9

xmlHashCreateFunction · 0.85
xmlSchemaHashKeySequenceFunction · 0.85
xmlHashLookupFunction · 0.85
xmlHashAddEntryFunction · 0.85
FREE_AND_NULLFunction · 0.85
xmlSchemaAreValuesEqualFunction · 0.85
xmlHashFreeFunction · 0.85

Tested by

no test coverage detected