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

Function xmlRelaxNGValidateAttribute

ThirdParty/libxml2/vtklibxml2/relaxng.c:8914–8997  ·  view source on GitHub ↗

* xmlRelaxNGValidateAttribute: * @ctxt: a Relax-NG validation context * @define: the definition to verify * * Validate the given attribute definition for that node * * Returns 0 if the validation succeeded or an error code. */

Source from the content-addressed store, hash-verified

8912 * Returns 0 if the validation succeeded or an error code.
8913 */
8914static int
8915xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
8916 xmlRelaxNGDefinePtr define)
8917{
8918 int ret = 0, i;
8919 xmlChar *value, *oldvalue;
8920 xmlAttrPtr prop = NULL, tmp;
8921 xmlNodePtr oldseq;
8922
8923 if (ctxt->state->nbAttrLeft <= 0)
8924 return (-1);
8925 if (define->name != NULL) {
8926 for (i = 0; i < ctxt->state->nbAttrs; i++) {
8927 tmp = ctxt->state->attrs[i];
8928 if ((tmp != NULL) && (xmlStrEqual(define->name, tmp->name))) {
8929 if ((((define->ns == NULL) || (define->ns[0] == 0)) &&
8930 (tmp->ns == NULL)) ||
8931 ((tmp->ns != NULL) &&
8932 (xmlStrEqual(define->ns, tmp->ns->href)))) {
8933 prop = tmp;
8934 break;
8935 }
8936 }
8937 }
8938 if (prop != NULL) {
8939 value = xmlNodeListGetString(prop->doc, prop->children, 1);
8940 oldvalue = ctxt->state->value;
8941 oldseq = ctxt->state->seq;
8942 ctxt->state->seq = (xmlNodePtr) prop;
8943 ctxt->state->value = value;
8944 ctxt->state->endvalue = NULL;
8945 ret = xmlRelaxNGValidateValueContent(ctxt, define->content);
8946 if (ctxt->state->value != NULL)
8947 value = ctxt->state->value;
8948 if (value != NULL)
8949 xmlFree(value);
8950 ctxt->state->value = oldvalue;
8951 ctxt->state->seq = oldseq;
8952 if (ret == 0) {
8953 /*
8954 * flag the attribute as processed
8955 */
8956 ctxt->state->attrs[i] = NULL;
8957 ctxt->state->nbAttrLeft--;
8958 }
8959 } else {
8960 ret = -1;
8961 }
8962 } else {
8963 for (i = 0; i < ctxt->state->nbAttrs; i++) {
8964 tmp = ctxt->state->attrs[i];
8965 if ((tmp != NULL) &&
8966 (xmlRelaxNGAttributeMatch(ctxt, define, tmp) == 1)) {
8967 prop = tmp;
8968 break;
8969 }
8970 }
8971 if (prop != NULL) {

Callers 2

xmlRelaxNGValidateStateFunction · 0.85

Calls 4

xmlStrEqualFunction · 0.85
xmlNodeListGetStringFunction · 0.85
xmlRelaxNGAttributeMatchFunction · 0.85

Tested by

no test coverage detected