void
xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node,
                      xmlNodePtr inst ATTRIBUTE_UNUSED,
                      const xmlChar * attributes)
{
    const xmlChar *ncname = NULL;
    const xmlChar *prefix = NULL;
    const xmlChar *attrib, *endattr;
    xsltAttrElemPtr values;
    xsltStylesheetPtr style;

    if (attributes == NULL) {
        return;
    }

    attrib = attributes;
    while (*attrib != 0) {
        while (IS_BLANK(*attrib))
            attrib++;
        if (*attrib == 0)
            break;
        endattr = attrib;
        while ((*endattr != 0) && (!IS_BLANK(*endattr)))
            endattr++;
        attrib = xmlDictLookup(ctxt->dict, attrib, endattr - attrib);
        if (attrib) {
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
            xsltGenericDebug(xsltGenericDebugContext,
                             "apply attribute set %s\n", attrib);
#endif
            ncname = xsltSplitQName(ctxt->dict, attrib, &prefix);

            style = ctxt->style;
#ifdef WITH_DEBUGGER
            if ((style != NULL) && (style->attributeSets != NULL) &&
		(ctxt->debugStatus != XSLT_DEBUG_NONE)) {
                values =
                    xmlHashLookup2(style->attributeSets, ncname, prefix);
                if ((values != NULL) && (values->attr != NULL))
                    xslHandleDebugger(values->attr->parent, node, NULL,
                                      ctxt);
            }
#endif
            while (style != NULL) {
                values =
                    xmlHashLookup2(style->attributeSets, ncname, prefix);
                while (values != NULL) {
                    if (values->attr != NULL) {
                        xsltAttributeInternal(ctxt, node, values->attr,
                                              values->attr->psvi, 1);
                    }
                    values = values->next;
                }
                style = xsltNextImport(style);
            }
        }
        attrib = endattr;
    }
}
Ejemplo n.º 2
0
/*
 * exsltFuncRegisterImportFunc
 * @data:    the exsltFuncFunctionData for the function
 * @ch:	     structure containing context and hash table
 * @URI:     the function namespace URI
 * @name:    the function name
 *
 * Checks if imported function is already registered in top-level
 * stylesheet.  If not, copies function data and registers function
 */
static void
exsltFuncRegisterImportFunc (exsltFuncFunctionData *data,
			     exsltFuncImportRegData *ch,
			     const xmlChar *URI, const xmlChar *name,
			     ATTRIBUTE_UNUSED const xmlChar *ignored) {
    exsltFuncFunctionData *func=NULL;

    if ((data == NULL) || (ch == NULL) || (URI == NULL) || (name == NULL))
            return;

    if (ch->ctxt == NULL || ch->hash == NULL)
    	return;

    /* Check if already present */
    func = (exsltFuncFunctionData*)xmlHashLookup2(ch->hash, URI, name);
    if (func == NULL) {		/* Not yet present - copy it in */
    	func = exsltFuncNewFunctionData();
	memcpy(func, data, sizeof(exsltFuncFunctionData));
	if (xmlHashAddEntry2(ch->hash, URI, name, func) < 0) {
	    xsltGenericError(xsltGenericErrorContext,
	    	    "Failed to register function {%s}%s\n",
		    URI, name);
	} else {		/* Do the registration */
	    xsltGenericDebug(xsltGenericDebugContext,
	            "exsltFuncRegisterImportFunc: register {%s}%s\n",
		    URI, name);
	    xsltRegisterExtFunction(ch->ctxt, name, URI,
		    exsltFuncFunctionFunction);
	}
    }
}
Ejemplo n.º 3
0
/**
 * xsltResolveUseAttrSets:
 * @set: the attribute set
 * @asctx:  the context for attribute set resolution
 * @depth: recursion depth
 *
 * Process "use-attribute-sets".
 */
static void
xsltResolveUseAttrSets(xsltAttrSetPtr set, xsltStylesheetPtr topStyle,
		       int depth) {
    xsltStylesheetPtr cur;
    xsltAttrSetPtr other;
    xsltUseAttrSetPtr use = set->useAttrSets;
    xsltUseAttrSetPtr next;

    while (use != NULL) {
        /*
         * Iterate top stylesheet and all imports.
         */
        cur = topStyle;
        while (cur != NULL) {
            if (cur->attributeSets) {
                other = xmlHashLookup2(cur->attributeSets, use->ncname,
                                       use->ns);
                if (other != NULL) {
                    xsltResolveAttrSet(other, topStyle, cur, use->ncname,
                                       use->ns, depth + 1);
                    xsltMergeAttrSets(set, other);
                    break;
                }
            }
            cur = xsltNextImport(cur);
        }

        next = use->next;
        /* Free useAttrSets early. */
        xsltFreeUseAttrSet(use);
        use = next;
    }

    set->useAttrSets = NULL;
}
Ejemplo n.º 4
0
/**
 * xsltMergeSASCallback,:
 * @style:  the XSLT stylesheet
 *
 * Merge an attribute set from an imported stylesheet.
 */
static void
xsltMergeSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
                     const xmlChar *name, const xmlChar *ns,
                     ATTRIBUTE_UNUSED const xmlChar *ignored) {
    int ret;
    xsltAttrElemPtr topSet;

    ret = xmlHashAddEntry2(style->attributeSets, name, ns, values);
    if (ret < 0) {
        /*
         * Add failed, this attribute set can be removed.
         */
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
        xsltGenericDebug(xsltGenericDebugContext,
                         "attribute set %s present already in top stylesheet"
                         " - merging\n", name);
#endif
        topSet = xmlHashLookup2(style->attributeSets, name, ns);
        if (topSet==NULL) {
            xsltGenericError(xsltGenericErrorContext,
                             "xsl:attribute-set : logic error merging from imports for"
                             " attribute-set %s\n", name);
        } else {
            topSet = xsltMergeAttrElemList(style, topSet, values);
            xmlHashUpdateEntry2(style->attributeSets, name, ns, topSet, NULL);
        }
        xsltFreeAttrElemList(values);
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
    } else {
        xsltGenericDebug(xsltGenericDebugContext,
                         "attribute set %s moved to top stylesheet\n",
                         name);
#endif
    }
}
Ejemplo n.º 5
0
/**
 * xsltXPathFunctionLookup:
 * @ctxt:  a void * but the XSLT transformation context actually
 * @name:  the function name
 * @ns_uri:  the function namespace URI
 *
 * This is the entry point when a function is needed by the XPath
 * interpretor.
 *
 * Returns the callback function or NULL if not found
 */
xmlXPathFunction
xsltXPathFunctionLookup (xmlXPathContextPtr ctxt,
			 const xmlChar *name, const xmlChar *ns_uri) {
    xmlXPathFunction ret;

    if ((ctxt == NULL) || (name == NULL) || (ns_uri == NULL))
	return (NULL);

#ifdef WITH_XSLT_DEBUG_FUNCTION
    xsltGenericDebug(xsltGenericDebugContext,
            "Lookup function {%s}%s\n", ns_uri, name);
#endif

    /* give priority to context-level functions */
    /*
    ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri);
    */
    XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri);

    if (ret == NULL)
	ret = xsltExtModuleFunctionLookup(name, ns_uri);

#ifdef WITH_XSLT_DEBUG_FUNCTION
    if (ret != NULL)
        xsltGenericDebug(xsltGenericDebugContext,
            "found function %s\n", name);
#endif
    return(ret);
}
Ejemplo n.º 6
0
/**
 * xsltGetSAS:
 * @style:  the XSLT stylesheet
 * @name:  the attribute list name
 * @ns:  the attribute list namespace
 *
 * lookup an attribute set based on the style cascade
 *
 * Returns the attribute set or NULL
 */
static xsltAttrElemPtr
xsltGetSAS(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns) {
    xsltAttrElemPtr values;

    while (style != NULL) {
        values = xmlHashLookup2(style->attributeSets, name, ns);
        if (values != NULL)
            return(values);
        style = xsltNextImport(style);
    }
    return(NULL);
}
Ejemplo n.º 7
0
/**
 * xsltResolveAttrSet:
 * @set: the attribute set
 * @asctx:  the context for attribute set resolution
 * @name: the local name of the attirbute set
 * @ns: the namespace of the attribute set
 * @depth: recursion depth
 *
 * resolve the references in an attribute set.
 */
static void
xsltResolveAttrSet(xsltAttrSetPtr set, xsltStylesheetPtr topStyle,
                   xsltStylesheetPtr style, const xmlChar *name,
                   const xmlChar *ns, int depth) {
    xsltStylesheetPtr cur;
    xsltAttrSetPtr other;

    if (set->state == ATTRSET_RESOLVED)
        return;
    if (set->state == ATTRSET_RESOLVING) {
	xsltTransformError(NULL, topStyle, NULL,
            "xsl:attribute-set : use-attribute-sets recursion detected"
            " on %s\n", name);
        topStyle->errors++;
        set->state = ATTRSET_RESOLVED;
        return;
    }
    if (depth > 100) {
	xsltTransformError(NULL, topStyle, NULL,
		"xsl:attribute-set : use-attribute-sets maximum recursion "
		"depth exceeded on %s\n", name);
        topStyle->errors++;
	return;
    }

    set->state = ATTRSET_RESOLVING;

    xsltResolveUseAttrSets(set, topStyle, depth);

    /* Merge imported sets. */
    cur = xsltNextImport(style);
    while (cur != NULL) {
        if (cur->attributeSets != NULL) {
            other = xmlHashLookup2(cur->attributeSets, name, ns);

            if (other != NULL) {
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
                xsltGenericDebug(xsltGenericDebugContext,
                    "xsl:attribute-set : merging import for %s\n", name);
#endif
                xsltResolveUseAttrSets(other, topStyle, depth);
                xsltMergeAttrSets(set, other);
                xmlHashRemoveEntry2(cur->attributeSets, name, ns, NULL);
                xsltFreeAttrSet(other);
            }
        }

        cur = xsltNextImport(cur);
    }

    set->state = ATTRSET_RESOLVED;
}
Ejemplo n.º 8
0
int
xsltFindElemSpaceHandling(xsltTransformContextPtr ctxt, xmlNodePtr node) {
    xsltStylesheetPtr style;
    const xmlChar *val;

    if ((ctxt == NULL) || (node == NULL))
	return(0);
    style = ctxt->style;
    while (style != NULL) {
	if (node->ns != NULL) {
	    val = (const xmlChar *)
	      xmlHashLookup2(style->stripSpaces, node->name, node->ns->href);
            if (val == NULL) {
                val = (const xmlChar *)
                    xmlHashLookup2(style->stripSpaces, BAD_CAST "*",
                                   node->ns->href);
            }
	} else {
	    val = (const xmlChar *)
		  xmlHashLookup2(style->stripSpaces, node->name, NULL);
	}
	if (val != NULL) {
	    if (xmlStrEqual(val, (xmlChar *) "strip"))
		return(1);
	    if (xmlStrEqual(val, (xmlChar *) "preserve"))
		return(0);
	}
	if (style->stripAll == 1)
	    return(1);
	if (style->stripAll == -1)
	    return(0);

	style = xsltNextImport(style);
    }
    return(0);
}
Ejemplo n.º 9
0
static void xmlsec_TransformFinalizeMethod(xmlSecTransformPtr transform) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup2(TransformFinalizeMethods, transform->id->name,
			transform->id->href);

  args = Py_BuildValue((char *) "O", wrap_xmlSecTransformPtr(transform));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  Py_XDECREF(result);
}
Ejemplo n.º 10
0
static int xmlsec_TransformCtxPreExecuteCallback(xmlSecTransformCtxPtr transformCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup2(TransformCtxPreExecuteCallbacks,
			transformCtx->uri, transformCtx->xptrExpr);

  args = Py_BuildValue((char *) "O", wrap_xmlSecTransformCtxPtr(transformCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
Ejemplo n.º 11
0
static int xmlsec_TransformInitializeMethod(xmlSecTransformPtr transform) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup2(TransformInitializeMethods, transform->id->name,
			transform->id->href);

  args = Py_BuildValue((char *) "O", wrap_xmlSecTransformPtr(transform));

  /* Protect refcount against reentrant manipulation of callback hash */
  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
Ejemplo n.º 12
0
static int xmlsec_TransformSetKeyMethod(xmlSecTransformPtr transform,
					xmlSecKeyPtr key) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup2(TransformSetKeyMethods, transform->id->name,
			transform->id->href);

  args = Py_BuildValue((char *) "OO", wrap_xmlSecTransformPtr(transform),
		       wrap_xmlSecKeyPtr(key));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
Ejemplo n.º 13
0
static xmlSecTransformDataType xmlsec_TransformGetDataTypeMethod(xmlSecTransformPtr transform,
								 xmlSecTransformMode mode,
								 xmlSecTransformCtxPtr transformCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup2(TransformGetDataTypeMethods, transform->id->name,
			transform->id->href);

  args = Py_BuildValue((char *) "OiO", wrap_xmlSecTransformPtr(transform),
		       mode, wrap_xmlSecTransformCtxPtr(transformCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
Ejemplo n.º 14
0
static int xmlsec_NodeSetWalkCallback(xmlSecNodeSetPtr nset, xmlNodePtr cur,
				      xmlNodePtr parent, void *data) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup2(NodeSetWalkCallbacks, (const xmlChar *)nset->doc->name,
			nset->doc->URL);

  args = Py_BuildValue((char *) "OOOO", wrap_xmlSecNodeSetPtr(nset),
		       wrap_xmlNodePtr(cur), wrap_xmlNodePtr(parent),
		       PyCObject_FromVoidPtr((void *) data, NULL));

  /* Protect refcount against reentrant manipulation of callback hash */
  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
Ejemplo n.º 15
0
static int xmlsec_TransformVerifyMethod(xmlSecTransformPtr transform,
					const xmlSecByte *data,
					xmlSecSize dataSize,
					xmlSecTransformCtxPtr transformCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup2(TransformVerifyMethods, transform->id->name,
			transform->id->href);

  args = Py_BuildValue((char *) "OsiO", wrap_xmlSecTransformPtr(transform),
		       data, dataSize,
		       wrap_xmlSecTransformCtxPtr(transformCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
Ejemplo n.º 16
0
void
xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) {
    const xmlChar *ncname;
    const xmlChar *prefix;
    xmlChar *value;
    xmlNodePtr child;
    xsltAttrElemPtr attrItems;

    if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
        return;

    value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL);
    if ((value == NULL) || (*value == 0)) {
        xsltGenericError(xsltGenericErrorContext,
                         "xsl:attribute-set : name is missing\n");
        if (value)
            xmlFree(value);
        return;
    }

    ncname = xsltSplitQName(style->dict, value, &prefix);
    xmlFree(value);
    value = NULL;

    if (style->attributeSets == NULL) {
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
        xsltGenericDebug(xsltGenericDebugContext,
                         "creating attribute set table\n");
#endif
        style->attributeSets = xmlHashCreate(10);
    }
    if (style->attributeSets == NULL)
        return;

    attrItems = xmlHashLookup2(style->attributeSets, ncname, prefix);

    /*
    * Parse the content. Only xsl:attribute elements are allowed.
    */
    child = cur->children;
    while (child != NULL) {
        /*
        * Report invalid nodes.
        */
        if ((child->type != XML_ELEMENT_NODE) ||
                (child->ns == NULL) ||
                (! IS_XSLT_ELEM(child)))
        {
            if (child->type == XML_ELEMENT_NODE)
                xsltTransformError(NULL, style, child,
                                   "xsl:attribute-set : unexpected child %s\n",
                                   child->name);
            else
                xsltTransformError(NULL, style, child,
                                   "xsl:attribute-set : child of unexpected type\n");
        } else if (!IS_XSLT_NAME(child, "attribute")) {
            xsltTransformError(NULL, style, child,
                               "xsl:attribute-set : unexpected child xsl:%s\n",
                               child->name);
        } else {
#ifdef XSLT_REFACTORED
            xsltAttrElemPtr nextAttr, curAttr;

            /*
            * Process xsl:attribute
            * ---------------------
            */

#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
            xsltGenericDebug(xsltGenericDebugContext,
                             "add attribute to list %s\n", ncname);
#endif
            /*
            * The following was taken over from
            * xsltAddAttrElemList().
            */
            if (attrItems == NULL) {
                attrItems = xsltNewAttrElem(child);
            } else {
                curAttr = attrItems;
                while (curAttr != NULL) {
                    nextAttr = curAttr->next;
                    if (curAttr->attr == child) {
                        /*
                        * URGENT TODO: Can somebody explain
                        *  why attrItems is set to curAttr
                        *  here? Is this somehow related to
                        *  avoidance of recursions?
                        */
                        attrItems = curAttr;
                        goto next_child;
                    }
                    if (curAttr->next == NULL)
                        curAttr->next = xsltNewAttrElem(child);
                    curAttr = nextAttr;
                }
            }
            /*
            * Parse the xsl:attribute and its content.
            */
            xsltParseAnyXSLTElem(XSLT_CCTXT(style), child);
#else
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
            xsltGenericDebug(xsltGenericDebugContext,
                             "add attribute to list %s\n", ncname);
#endif
            /*
            * OLD behaviour:
            */
            attrItems = xsltAddAttrElemList(attrItems, child);
#endif
        }

#ifdef XSLT_REFACTORED
next_child:
#endif
        child = child->next;
    }

    /*
    * Process attribue "use-attribute-sets".
    */
    /* TODO check recursion */
    value = xmlGetNsProp(cur, (const xmlChar *)"use-attribute-sets",
                         NULL);
    if (value != NULL) {
        const xmlChar *curval, *endval;
        curval = value;
        while (*curval != 0) {
            while (IS_BLANK(*curval)) curval++;
            if (*curval == 0)
                break;
            endval = curval;
            while ((*endval != 0) && (!IS_BLANK(*endval))) endval++;
            curval = xmlDictLookup(style->dict, curval, endval - curval);
            if (curval) {
                const xmlChar *ncname2 = NULL;
                const xmlChar *prefix2 = NULL;
                xsltAttrElemPtr refAttrItems;

#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
                xsltGenericDebug(xsltGenericDebugContext,
                                 "xsl:attribute-set : %s adds use %s\n", ncname, curval);
#endif
                ncname2 = xsltSplitQName(style->dict, curval, &prefix2);
                refAttrItems = xsltNewAttrElem(NULL);
                if (refAttrItems != NULL) {
                    refAttrItems->set = ncname2;
                    refAttrItems->ns = prefix2;
                    attrItems = xsltMergeAttrElemList(style,
                                                      attrItems, refAttrItems);
                    xsltFreeAttrElem(refAttrItems);
                }
            }
            curval = endval;
        }
        xmlFree(value);
        value = NULL;
    }

    /*
     * Update the value
     */
    /*
    * TODO: Why is this dummy entry needed.?
    */
    if (attrItems == NULL)
        attrItems = xsltNewAttrElem(NULL);
    xmlHashUpdateEntry2(style->attributeSets, ncname, prefix, attrItems, NULL);
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
    xsltGenericDebug(xsltGenericDebugContext,
                     "updated attribute list %s\n", ncname);
#endif
}
Ejemplo n.º 17
0
int
xslDbgShellSetVariable(xsltTransformContextPtr styleCtxt, xmlChar * arg)
{
    int result = 0, showUsage = 0;
    xmlChar *name, *nameURI, *selectExpr, *opts[3];

    if (!styleCtxt) {
	
        xsldbgGenericErrorFunc(i18n("Error: Stylesheet is not valid.\n"));
        return result;
    }

    if (!arg) {
#ifdef WITH_XSLDBG_DEBUG_PROCESS
        xsltGenericError(xsltGenericErrorContext,
                         "Error: NULL argument provided\n");
#endif
        return result;
    }

    if (xmlStrLen(arg) > 1) {
        if (splitString(arg, 2, opts) == 2) {
            nameURI = NULL;
	    /* ignore any "$" prefix as user probably didn't mean that 
	       "$" is part of variable name*/
	    if (*opts[0] =='$'){
	      opts[0] = opts[0] + 1;
	    }
            name = xmlSplitQName2(opts[0], &nameURI);
            if (name == NULL)
                name = xmlStrdup(opts[0]);
            selectExpr = xmlStrdup(opts[1]);
            if (name && selectExpr) {
                xsltStackElemPtr def = NULL;

                if (styleCtxt->varsBase) {
                    /* try finding varaible in stack */
                    xsltStackElemPtr item =
                        styleCtxt->varsTab[styleCtxt->varsBase];
                    while (item) {
                        if ((xmlStrCmp(name, item->name) == 0) &&
                            (item->nameURI == NULL
                             || (xmlStrCmp(name, item->nameURI) == 0))) {
                            def = item;
                            break;
                        }
                        item = item->next;
                    }
                }

                if (def == NULL)
                    def = (xsltStackElemPtr)
                        xmlHashLookup2(styleCtxt->globalVars,
                                       name, nameURI);
                if (def != NULL) {
                    if (def->select) {
                        /* we've found the variable so change it */
                        xmlFree((void*)def->select);
                        def->select = selectExpr;
                        if (def->comp->comp)
                            xmlXPathFreeCompExpr(def->comp->comp);
                        def->comp->comp = xmlXPathCompile(def->select);
                        if (def->value)
                            xmlXPathFreeObject(def->value);
                        def->value =
                            xmlXPathEval(def->select,
                                         styleCtxt->xpathCtxt);
                        result = 1;
                    } else {
                        xmlFree(selectExpr);
                        xsldbgGenericErrorFunc(i18n("Error: Cannot change a variable that does not use the select attribute.\n"));
                    }
                } else
                    xsldbgGenericErrorFunc(i18n("Error: Variable %1 was not found.\n").arg(xsldbgText(name)));
                xmlFree(name);
            } else
                xsldbgGenericErrorFunc(i18n("Error: Out of memory.\n"));
        } else {
            showUsage = 1;
        }

        if (showUsage == 1)
            xsldbgGenericErrorFunc(i18n("Error: Invalid arguments to command %1.\n").arg("set"));
    }
    return result;
}
Ejemplo n.º 18
0
void
xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) {
    const xmlChar *ncname;
    const xmlChar *prefix;
    const xmlChar *nsUri = NULL;
    xmlChar *value;
    xmlNodePtr child;
    xsltAttrSetPtr set;

    if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
	return;

    value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL);
    if ((value == NULL) || (*value == 0)) {
	xsltGenericError(xsltGenericErrorContext,
	     "xsl:attribute-set : name is missing\n");
        if (value)
	    xmlFree(value);
	return;
    }

    if (xmlValidateQName(value, 0)) {
        xsltTransformError(NULL, style, cur,
            "xsl:attribute-set : The name '%s' is not a valid QName.\n",
            value);
        style->errors++;
        xmlFree(value);
        return;
    }

    ncname = xsltSplitQName(style->dict, value, &prefix);
    xmlFree(value);
    value = NULL;
    if (prefix != NULL) {
        xmlNsPtr ns = xmlSearchNs(style->doc, cur, prefix);
        if (ns == NULL) {
            xsltTransformError(NULL, style, cur,
                "xsl:attribute-set : No namespace found for QName '%s:%s'\n",
                prefix, ncname);
            style->errors++;
            return;
        }
        nsUri = ns->href;
    }

    if (style->attributeSets == NULL) {
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
	xsltGenericDebug(xsltGenericDebugContext,
	    "creating attribute set table\n");
#endif
	style->attributeSets = xmlHashCreate(10);
    }
    if (style->attributeSets == NULL)
	return;

    set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
    if (set == NULL) {
        set = xsltNewAttrSet();
        if (set == NULL)
            return;
        xmlHashAddEntry2(style->attributeSets, ncname, nsUri, set);
    }

    /*
    * Parse the content. Only xsl:attribute elements are allowed.
    */
    child = cur->children;
    while (child != NULL) {
	/*
	* Report invalid nodes.
	*/
	if ((child->type != XML_ELEMENT_NODE) ||
	    (child->ns == NULL) ||
	    (! IS_XSLT_ELEM(child)))
	{
	    if (child->type == XML_ELEMENT_NODE)
		xsltTransformError(NULL, style, child,
			"xsl:attribute-set : unexpected child %s\n",
		                 child->name);
	    else
		xsltTransformError(NULL, style, child,
			"xsl:attribute-set : child of unexpected type\n");
	} else if (!IS_XSLT_NAME(child, "attribute")) {
	    xsltTransformError(NULL, style, child,
		"xsl:attribute-set : unexpected child xsl:%s\n",
		child->name);
	} else {
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
	    xsltGenericDebug(xsltGenericDebugContext,
		"add attribute to list %s\n", ncname);
#endif
            if (child->psvi == NULL) {
                xsltTransformError(NULL, style, child,
                    "xsl:attribute-set : internal error, attribute %s not "
                    "compiled\n", child->name);
            }
            else {
	        set->attrs = xsltAddAttrElemList(set->attrs, child);
            }
	}

	child = child->next;
    }

    /*
    * Process attribute "use-attribute-sets".
    */
    value = xmlGetNsProp(cur, BAD_CAST "use-attribute-sets", NULL);
    if (value != NULL) {
	const xmlChar *curval, *endval;
	curval = value;
	while (*curval != 0) {
	    while (IS_BLANK(*curval)) curval++;
	    if (*curval == 0)
		break;
	    endval = curval;
	    while ((*endval != 0) && (!IS_BLANK(*endval))) endval++;
	    curval = xmlDictLookup(style->dict, curval, endval - curval);
	    if (curval) {
		const xmlChar *ncname2 = NULL;
		const xmlChar *prefix2 = NULL;
                const xmlChar *nsUri2 = NULL;

#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
		xsltGenericDebug(xsltGenericDebugContext,
		    "xsl:attribute-set : %s adds use %s\n", ncname, curval);
#endif

                if (xmlValidateQName(curval, 0)) {
                    xsltTransformError(NULL, style, cur,
                        "xsl:attribute-set : The name '%s' in "
                        "use-attribute-sets is not a valid QName.\n", curval);
                    style->errors++;
                    xmlFree(value);
                    return;
                }

		ncname2 = xsltSplitQName(style->dict, curval, &prefix2);
                if (prefix2 != NULL) {
                    xmlNsPtr ns2 = xmlSearchNs(style->doc, cur, prefix2);
                    if (ns2 == NULL) {
                        xsltTransformError(NULL, style, cur,
                            "xsl:attribute-set : No namespace found for QName "
                            "'%s:%s' in use-attribute-sets\n",
                            prefix2, ncname2);
                        style->errors++;
                        xmlFree(value);
                        return;
                    }
                    nsUri2 = ns2->href;
                }
                set->useAttrSets = xsltAddUseAttrSetList(set->useAttrSets,
                                                         ncname2, nsUri2);
	    }
	    curval = endval;
	}
	xmlFree(value);
	value = NULL;
    }

#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
    xsltGenericDebug(xsltGenericDebugContext,
	"updated attribute list %s\n", ncname);
#endif
}
Ejemplo n.º 19
0
/**
 * xsltApplyAttributeSet:
 * @ctxt:  the XSLT stylesheet
 * @node:  the node in the source tree.
 * @inst:  the attribute node "xsl:use-attribute-sets"
 * @attrSets:  the list of QNames of the attribute-sets to be applied
 *
 * Apply the xsl:use-attribute-sets.
 * If @attrSets is NULL, then @inst will be used to exctract this
 * value.
 * If both, @attrSets and @inst, are NULL, then this will do nothing.
 */
void
xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node,
                      xmlNodePtr inst,
                      const xmlChar *attrSets)
{
    const xmlChar *ncname = NULL;
    const xmlChar *prefix = NULL;
    const xmlChar *curstr, *endstr;
    xsltAttrSetPtr set;
    xsltStylesheetPtr style;

    if (attrSets == NULL) {
	if (inst == NULL)
	    return;
	else {
	    /*
	    * Extract the value from @inst.
	    */
	    if (inst->type == XML_ATTRIBUTE_NODE) {
		if ( ((xmlAttrPtr) inst)->children != NULL)
		    attrSets = ((xmlAttrPtr) inst)->children->content;

	    }
	    if (attrSets == NULL) {
		/*
		* TODO: Return an error?
		*/
		return;
	    }
	}
    }
    /*
    * Parse/apply the list of QNames.
    */
    curstr = attrSets;
    while (*curstr != 0) {
        while (IS_BLANK(*curstr))
            curstr++;
        if (*curstr == 0)
            break;
        endstr = curstr;
        while ((*endstr != 0) && (!IS_BLANK(*endstr)))
            endstr++;
        curstr = xmlDictLookup(ctxt->dict, curstr, endstr - curstr);
        if (curstr) {
            xmlNsPtr ns;
            const xmlChar *nsUri = NULL;

#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
            xsltGenericDebug(xsltGenericDebugContext,
                             "apply attribute set %s\n", curstr);
#endif

            if (xmlValidateQName(curstr, 0)) {
                xsltTransformError(ctxt, NULL, inst,
                    "The name '%s' in use-attribute-sets is not a valid "
                    "QName.\n", curstr);
                return;
            }

            ncname = xsltSplitQName(ctxt->dict, curstr, &prefix);
            if (prefix != NULL) {
	        ns = xmlSearchNs(inst->doc, inst, prefix);
                if (ns == NULL) {
                    xsltTransformError(ctxt, NULL, inst,
                        "use-attribute-set : No namespace found for QName "
                        "'%s:%s'\n", prefix, ncname);
                    return;
                }
                nsUri = ns->href;
            }

            style = ctxt->style;

#ifdef WITH_DEBUGGER
            if ((style != NULL) &&
		(style->attributeSets != NULL) &&
		(ctxt->debugStatus != XSLT_DEBUG_NONE))
	    {
                set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
                if ((set != NULL) && (set->attrs != NULL) &&
                    (set->attrs->attr != NULL))
                    xslHandleDebugger(set->attrs->attr->parent, node, NULL,
			ctxt);
            }
#endif
	    /*
	    * Lookup the referenced attribute-set. All attribute sets were
            * moved to the top stylesheet so there's no need to iterate
            * imported stylesheets
	    */
            set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
            if (set != NULL) {
                xsltAttrElemPtr cur = set->attrs;
                while (cur != NULL) {
                    if (cur->attr != NULL) {
                        xsltAttribute(ctxt, node, cur->attr,
                            cur->attr->psvi);
                    }
                    cur = cur->next;
                }
            }
        }
        curstr = endstr;
    }
}
Ejemplo n.º 20
0
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}

static int xmlsec_TransformPushBinMethod(xmlSecTransformPtr transform,
					 const xmlSecByte *data,
					 xmlSecSize dataSize,
					 int final,
					 xmlSecTransformCtxPtr transformCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;
  
  func = xmlHashLookup2(TransformPushBinMethods, transform->id->name,
			transform->id->href);

  args = Py_BuildValue((char *) "OsiiO", wrap_xmlSecTransformPtr(transform),
		       data, dataSize, final,
		       wrap_xmlSecTransformCtxPtr(transformCtx));
  
  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}

static int xmlsec_TransformPopBinMethod(xmlSecTransformPtr transform,
					xmlSecByte *data,
Ejemplo n.º 21
0
void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
{
    PGresult * 		res;
    const char *	paramValues[14];
    char *			place_id;
    char *			partionQueryName;
    int i, namePos, lineTypeLen, lineValueLen;

    if (xmlStrEqual(name, BAD_CAST "feature"))
    {
        featureCount++;
        if (featureCount % 1000 == 0) printf("feature %i(k)\n", featureCount/1000);
/*
        if (fileMode == FILEMODE_ADD)
        {
            resPlaceID = PQexecPrepared(conn, "get_new_place_id", 0, NULL, NULL, NULL, 0);
            if (PQresultStatus(resPlaceID) != PGRES_TUPLES_OK)
            {
                fprintf(stderr, "get_place_id: INSERT failed: %s", PQerrorMessage(conn));
                PQclear(resPlaceID);
                exit(EXIT_FAILURE);
            }
        }
        else
        {
            paramValues[0] = (const char *)feature.type;
            paramValues[1] = (const char *)feature.id;
            paramValues[2] = (const char *)feature.key;
            paramValues[3] = (const char *)feature.value;
            resPlaceID = PQexecPrepared(conn, "get_new_place_id", 4, paramValues, NULL, NULL, 0);
            if (PQresultStatus(resPlaceID) != PGRES_TUPLES_OK)
            {
                fprintf(stderr, "index_placex: INSERT failed: %s", PQerrorMessage(conn));
                PQclear(resPlaceID);
                exit(EXIT_FAILURE);
            }
        }
*/
        place_id = (char *)feature.placeID;

        if (fileMode == FILEMODE_UPDATE || fileMode == FILEMODE_DELETE || fileMode == FILEMODE_ADD)
        {
            paramValues[0] = (const char *)place_id;
            if (verbose) fprintf(stderr, "placex_delete: %s\n", paramValues[0]);
            res = PQexecPrepared(conn, "placex_delete", 1, paramValues, NULL, NULL, 0);
            if (PQresultStatus(res) != PGRES_COMMAND_OK)
            {
                fprintf(stderr, "placex_delete: DELETE failed: %s", PQerrorMessage(conn));
                PQclear(res);
                exit(EXIT_FAILURE);
            }
            PQclear(res);

            if (verbose) fprintf(stderr, "search_name_delete: %s\n", paramValues[0]);
            res = PQexecPrepared(conn, "search_name_delete", 1, paramValues, NULL, NULL, 0);
            if (PQresultStatus(res) != PGRES_COMMAND_OK)
            {
                fprintf(stderr, "search_name_delete: DELETE failed: %s", PQerrorMessage(conn));
                PQclear(res);
                exit(EXIT_FAILURE);
            }
            PQclear(res);

            if (verbose) fprintf(stderr, "place_addressline_delete: %s\n", paramValues[0]);
            res = PQexecPrepared(conn, "place_addressline_delete", 1, paramValues, NULL, NULL, 0);
            if (PQresultStatus(res) != PGRES_COMMAND_OK)
            {
                fprintf(stderr, "place_addressline_delete: DELETE failed: %s", PQerrorMessage(conn));
                PQclear(res);
                exit(EXIT_FAILURE);
            }
            PQclear(res);

            partionQueryName = xmlHashLookup2(partionTableTagsHashDelete, feature.key, feature.value);
            if (partionQueryName)
            {
                res = PQexecPrepared(conn, partionQueryName, 1, paramValues, NULL, NULL, 0);
                if (PQresultStatus(res) != PGRES_COMMAND_OK)
                {
                    fprintf(stderr, "%s: DELETE failed: %s", partionQueryName, PQerrorMessage(conn));
                    PQclear(res);
                    exit(EXIT_FAILURE);
                }
                PQclear(res);
            }
        }

        if (fileMode == FILEMODE_UPDATE || fileMode == FILEMODE_ADD)
        {
            // Insert into placex
            paramValues[0] = (const char *)place_id;
            paramValues[1] = (const char *)feature.type;
            paramValues[2] = (const char *)feature.id;
            paramValues[3] = (const char *)feature.key;
            paramValues[4] = (const char *)feature.value;

            featureNameString[0] = 0;
            if (featureNameLines)
            {
                namePos = 0;
                lineTypeLen = 0;
                lineValueLen = 0;
                for (i = 0; i < featureNameLines; i++)
                {
                    lineTypeLen = (int)strlen((char *) featureName[i].type);
                    lineValueLen = (int)strlen((char *) featureName[i].value);
                    if (namePos+lineTypeLen+lineValueLen+7 > MAX_FEATURENAMESTRING)
                    {
                        fprintf(stderr, "feature name too long: %s", (const char *)featureName[i].value);
                        break;
                    }
                    if (namePos) strcpy(featureNameString+(namePos++), ",");
                    strcpy(featureNameString+(namePos++), "\"");
                    strcpy(featureNameString+namePos, (char*) featureName[i].type);
                    namePos += lineTypeLen;
                    strcpy(featureNameString+namePos, "\"=>\"");
                    namePos += 4;
                    strcpy(featureNameString+namePos, (char *) featureName[i].value);
                    namePos += lineValueLen;
                    strcpy(featureNameString+(namePos++), "\"");

                    xmlFree(featureName[i].type);
                    xmlFree(featureName[i].value);
                }
            }
            paramValues[5] = (const char *)featureNameString;

            paramValues[6] = (const char *)feature.countryCode;

            featureExtraTagString[0] = 0;
            if (featureExtraTagLines)
            {
                namePos = 0;
                lineTypeLen = 0;
                lineValueLen = 0;
                for (i = 0; i < featureExtraTagLines; i++)
                {
                    lineTypeLen = strlen((char *) featureExtraTag[i].type);
                    lineValueLen = strlen((char *) featureExtraTag[i].value);
                    if (namePos+lineTypeLen+lineValueLen+7 > MAX_FEATUREEXTRATAGSTRING)
                    {
                        fprintf(stderr, "feature extra tag too long: %s", (const char *)featureExtraTag[i].value);
                        break;
                    }
                    if (namePos) strcpy(featureExtraTagString+(namePos++),",");
                    strcpy(featureExtraTagString+(namePos++), "\"");
                    strcpy(featureExtraTagString+namePos, (char *) featureExtraTag[i].type);
                    namePos += lineTypeLen;
                    strcpy(featureExtraTagString+namePos, "\"=>\"");
                    namePos += 4;
                    strcpy(featureExtraTagString+namePos, (char *) featureExtraTag[i].value);
                    namePos += lineValueLen;
                    strcpy(featureExtraTagString+(namePos++), "\"");

                    xmlFree(featureExtraTag[i].type);
                    xmlFree(featureExtraTag[i].value);
                }
            }
            paramValues[7] = (const char *)featureExtraTagString;

            if (strlen(feature.parentPlaceID) == 0)
                paramValues[8] = "0";
            else
                paramValues[8] = (const char *)feature.parentPlaceID;

            paramValues[9] = (const char *)feature.adminLevel;
            paramValues[10] = (const char *)feature.houseNumber;
            paramValues[11] = (const char *)feature.rankAddress;
            paramValues[12] = (const char *)feature.rankSearch;
            paramValues[13] = (const char *)feature.geometry;
            if (strlen(paramValues[3]) && strlen(paramValues[13]))
            {
                if (verbose) fprintf(stderr, "placex_insert: %s\n", paramValues[0]);
                res = PQexecPrepared(conn, "placex_insert", 14, paramValues, NULL, NULL, 0);
                if (PQresultStatus(res) != PGRES_COMMAND_OK)
                {
                    fprintf(stderr, "index_placex: INSERT failed: %s", PQerrorMessage(conn));
                    fprintf(stderr, "index_placex: INSERT failed: %s %s %s", paramValues[0], paramValues[1], paramValues[2]);
                    PQclear(res);
                    exit(EXIT_FAILURE);
               }
               PQclear(res);
            }

            for (i = 0; i < featureAddressLines; i++)
            {
                // insert into place_address
                paramValues[0] = (const char *)place_id;
                paramValues[1] = (const char *)featureAddress[i].distance;
                if (paramValues[1] == NULL || strlen(paramValues[1]) == 0) paramValues[1] = "0";
                paramValues[2] = (const char *)featureAddress[i].type;
                paramValues[3] = (const char *)featureAddress[i].id;
                paramValues[4] = (const char *)featureAddress[i].key;
                paramValues[5] = (const char *)featureAddress[i].value;
                paramValues[6] = (const char *)featureAddress[i].isAddress;
                if (verbose) fprintf(stderr, "placex_insert: %s %s\n", paramValues[2], paramValues[3]);
                res = PQexecPrepared(conn, "place_addressline_insert", 7, paramValues, NULL, NULL, 0);
                if (PQresultStatus(res) != PGRES_COMMAND_OK)
                {
                    fprintf(stderr, "place_addressline_insert: INSERT failed: %s", PQerrorMessage(conn));
                    fprintf(stderr, "(%s,%s,%s,%s,%s,%s,%s)",paramValues[0],paramValues[1],paramValues[2],paramValues[3],paramValues[4],paramValues[5],paramValues[6]);
                    PQclear(res);
                    exit(EXIT_FAILURE);
                }
                PQclear(res);

                xmlFree(featureAddress[i].type);
                xmlFree(featureAddress[i].id);
                xmlFree(featureAddress[i].key);
                xmlFree(featureAddress[i].value);
                xmlFree(featureAddress[i].distance);
            }

            if (featureNameLines)
            {
                if (strlen(feature.parentPlaceID) > 0 && featureAddressLines == 0)
		{
                    paramValues[0] = (const char *)place_id;
                    paramValues[1] = feature.parentPlaceID;
                    if (verbose) fprintf(stderr, "search_name_from_parent_insert: INSERT %s %s\n", paramValues[0], paramValues[1]);
                    res = PQexecPrepared(conn, "search_name_from_parent_insert", 2, paramValues, NULL, NULL, 0);
                    if (PQresultStatus(res) != PGRES_COMMAND_OK)
                    {
                        fprintf(stderr, "search_name_from_parent_insert: INSERT failed: %s", PQerrorMessage(conn));
                        PQclear(res);
                        exit(EXIT_FAILURE);
                    }
                    PQclear(res);
		}
		else
		{
                    paramValues[0] = (const char *)place_id;
                    if (verbose) fprintf(stderr, "search_name_insert: INSERT %s\n", paramValues[0]);
                    res = PQexecPrepared(conn, "search_name_insert", 1, paramValues, NULL, NULL, 0);
                    if (PQresultStatus(res) != PGRES_COMMAND_OK)
                    {
                        fprintf(stderr, "search_name_insert: INSERT failed: %s", PQerrorMessage(conn));
                        PQclear(res);
                        exit(EXIT_FAILURE);
                    }
                    PQclear(res);
                }
            }

            partionQueryName = xmlHashLookup2(partionTableTagsHash, feature.key, feature.value);
            if (partionQueryName)
            {
                // insert into partition table
                paramValues[0] = (const char *)place_id;
                paramValues[1] = (const char *)feature.geometry;
                res = PQexecPrepared(conn, partionQueryName, 2, paramValues, NULL, NULL, 0);
                if (PQresultStatus(res) != PGRES_COMMAND_OK)
                {
                    fprintf(stderr, "%s: INSERT failed: %s", partionQueryName, PQerrorMessage(conn));
                    PQclear(res);
                    exit(EXIT_FAILURE);
                }
                PQclear(res);
            }

        }
        else
        {
            for (i = 0; i < featureAddressLines; i++)
            {
                xmlFree(featureAddress[i].type);
                xmlFree(featureAddress[i].id);
                xmlFree(featureAddress[i].key);
                xmlFree(featureAddress[i].value);
                xmlFree(featureAddress[i].distance);
            }
        }

        xmlFree(feature.placeID);
        xmlFree(feature.type);
        xmlFree(feature.id);
        xmlFree(feature.key);
        xmlFree(feature.value);
        xmlFree(feature.rankAddress);
        xmlFree(feature.rankSearch);
        if (feature.countryCode) xmlFree(feature.countryCode);
	if (feature.parentPlaceID) xmlFree(feature.parentPlaceID);
	if (feature.parentType) xmlFree(feature.parentType);
	if (feature.parentID) xmlFree(feature.parentID);
//		if (feature.name) xmlFree(feature.name);
        if (feature.adminLevel) xmlFree(feature.adminLevel);
        if (feature.houseNumber) xmlFree(feature.houseNumber);
        if (feature.geometry) xmlFree(feature.geometry);

//        PQclear(resPlaceID);
    }
}
Ejemplo n.º 22
0
/**
 * xsltApplyAttributeSet:
 * @ctxt:  the XSLT stylesheet
 * @node:  the node in the source tree.
 * @inst:  the attribute node "xsl:use-attribute-sets"
 * @attrSets:  the list of QNames of the attribute-sets to be applied
 *
 * Apply the xsl:use-attribute-sets.
 * If @attrSets is NULL, then @inst will be used to exctract this
 * value.
 * If both, @attrSets and @inst, are NULL, then this will do nothing.
 */
void
xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node,
                      xmlNodePtr inst,
                      const xmlChar *attrSets)
{
    const xmlChar *ncname = NULL;
    const xmlChar *prefix = NULL;
    const xmlChar *curstr, *endstr;
    xsltAttrElemPtr attrs;
    xsltStylesheetPtr style;

    if (attrSets == NULL) {
        if (inst == NULL)
            return;
        else {
            /*
            * Extract the value from @inst.
            */
            if (inst->type == XML_ATTRIBUTE_NODE) {
                if ( ((xmlAttrPtr) inst)->children != NULL)
                    attrSets = ((xmlAttrPtr) inst)->children->content;

            }
            if (attrSets == NULL) {
                /*
                * TODO: Return an error?
                */
                return;
            }
        }
    }
    /*
    * Parse/apply the list of QNames.
    */
    curstr = attrSets;
    while (*curstr != 0) {
        while (IS_BLANK(*curstr))
            curstr++;
        if (*curstr == 0)
            break;
        endstr = curstr;
        while ((*endstr != 0) && (!IS_BLANK(*endstr)))
            endstr++;
        curstr = xmlDictLookup(ctxt->dict, curstr, endstr - curstr);
        if (curstr) {
            /*
            * TODO: Validate the QName.
            */

#ifdef WITH_XSLT_DEBUG_curstrUTES
            xsltGenericDebug(xsltGenericDebugContext,
                             "apply curstrute set %s\n", curstr);
#endif
            ncname = xsltSplitQName(ctxt->dict, curstr, &prefix);

            style = ctxt->style;

#ifdef WITH_DEBUGGER
            if ((style != NULL) &&
                    (style->attributeSets != NULL) &&
                    (ctxt->debugStatus != XSLT_DEBUG_NONE))
            {
                attrs =
                    xmlHashLookup2(style->attributeSets, ncname, prefix);
                if ((attrs != NULL) && (attrs->attr != NULL))
                    xslHandleDebugger(attrs->attr->parent, node, NULL,
                                      ctxt);
            }
#endif
            /*
            * Lookup the referenced curstrute-set.
            */
            while (style != NULL) {
                attrs =
                    xmlHashLookup2(style->attributeSets, ncname, prefix);
                while (attrs != NULL) {
                    if (attrs->attr != NULL) {
                        xsltAttributeInternal(ctxt, node, attrs->attr,
                                              attrs->attr->psvi, 1);
                    }
                    attrs = attrs->next;
                }
                style = xsltNextImport(style);
            }
        }
        curstr = endstr;
    }
}