/* * attributes.c: Implementation of the XSLT attributes handling * * Reference: * http://www.w3.org/TR/1999/REC-xslt-19991116 * * See Copyright for the status of this software. * * [email protected] */ #define IN_LIBXSLT #include "libxslt.h" #include <string.h> #include <libxml/xmlmemory.h> #include <libxml/tree.h> #include <libxml/hash.h> #include <libxml/xmlerror.h> #include <libxml/uri.h> #include <libxml/parserInternals.h> #include "xslt.h" #include "xsltInternals.h" #include "xsltutils.h" #include "attributes.h" #include "namespaces.h" #include "templates.h" #include "imports.h" #include "transform.h" #include "preproc.h" #define WITH_XSLT_DEBUG_ATTRIBUTES #ifdef WITH_XSLT_DEBUG #define WITH_XSLT_DEBUG_ATTRIBUTES #endif /* * Useful macros */ #ifdef IS_BLANK #undef IS_BLANK #endif #define IS_BLANK(c) … #define IS_BLANK_NODE(n) … #define ATTRSET_UNRESOLVED … #define ATTRSET_RESOLVING … #define ATTRSET_RESOLVED … /* * The in-memory structure corresponding to an XSLT Attribute in * an attribute set */ xsltAttrElem; xsltAttrElemPtr; struct _xsltAttrElem { … }; xsltUseAttrSet; xsltUseAttrSetPtr; struct _xsltUseAttrSet { … }; xsltAttrSet; xsltAttrSetPtr; struct _xsltAttrSet { … }; xsltAttrSetContext; xsltAttrSetContextPtr; struct _xsltAttrSetContext { … }; static void xsltResolveAttrSet(xsltAttrSetPtr set, xsltStylesheetPtr topStyle, xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns, int depth); /************************************************************************ * * * XSLT Attribute handling * * * ************************************************************************/ /** * xsltNewAttrElem: * @attr: the new xsl:attribute node * * Create a new XSLT AttrElem * * Returns the newly allocated xsltAttrElemPtr or NULL in case of error */ static xsltAttrElemPtr xsltNewAttrElem(xmlNodePtr attr) { … } /** * xsltFreeAttrElem: * @attr: an XSLT AttrElem * * Free up the memory allocated by @attr */ static void xsltFreeAttrElem(xsltAttrElemPtr attr) { … } /** * xsltFreeAttrElemList: * @list: an XSLT AttrElem list * * Free up the memory allocated by @list */ static void xsltFreeAttrElemList(xsltAttrElemPtr list) { … } /** * xsltAddAttrElemList: * @list: an XSLT AttrElem list * @attr: the new xsl:attribute node * * Add the new attribute to the list. * * Returns the new list pointer */ static xsltAttrElemPtr xsltAddAttrElemList(xsltAttrElemPtr list, xmlNodePtr attr) { … } /** * xsltNewUseAttrSet: * @ncname: local name * @ns: namespace URI * * Create a new XSLT UseAttrSet * * Returns the newly allocated xsltUseAttrSetPtr or NULL in case of error. */ static xsltUseAttrSetPtr xsltNewUseAttrSet(const xmlChar *ncname, const xmlChar *ns) { … } /** * xsltFreeUseAttrSet: * @use: an XSLT UseAttrSet * * Free up the memory allocated by @use */ static void xsltFreeUseAttrSet(xsltUseAttrSetPtr use) { … } /** * xsltFreeUseAttrSetList: * @list: an XSLT UseAttrSet list * * Free up the memory allocated by @list */ static void xsltFreeUseAttrSetList(xsltUseAttrSetPtr list) { … } /** * xsltAddUseAttrSetList: * @list: a xsltUseAttrSet list * @ncname: local name * @ns: namespace URI * * Add the use-attribute-set name to the list. * * Returns the new list pointer. */ static xsltUseAttrSetPtr xsltAddUseAttrSetList(xsltUseAttrSetPtr list, const xmlChar *ncname, const xmlChar *ns) { … } /** * xsltNewAttrSet: * * Create a new attribute set. * * Returns the newly allocated xsltAttrSetPtr or NULL in case of error. */ static xsltAttrSetPtr xsltNewAttrSet(void) { … } /** * xsltFreeAttrSet: * @set: an attribute set * * Free memory allocated by @set */ static void xsltFreeAttrSet(xsltAttrSetPtr set) { … } /** * xsltMergeAttrSets: * @set: an attribute set * @other: another attribute set * * Add all the attributes from @other to @set, * but drop redefinition of existing values. */ static void xsltMergeAttrSets(xsltAttrSetPtr set, xsltAttrSetPtr other) { … } /************************************************************************ * * * Module interfaces * * * ************************************************************************/ /** * xsltParseStylesheetAttributeSet: * @style: the XSLT stylesheet * @cur: the "attribute-set" element * * parse an XSLT stylesheet attribute-set element */ void xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) { … } /** * 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) { … } /** * 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) { … } /** * xsltResolveSASCallback: * @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 * * resolve the references in an attribute set. */ static void xsltResolveSASCallback(void *payload, void *data, const xmlChar *name, const xmlChar *ns, ATTRIBUTE_UNUSED const xmlChar *ignored) { … } /** * xsltResolveStylesheetAttributeSet: * @style: the XSLT stylesheet * * resolve the references between attribute sets. */ void xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style) { … } /** * xsltAttribute: * @ctxt: a XSLT process context * @contextNode: the current node in the source tree * @inst: the xsl:attribute element * @castedComp: precomputed information * * Process the xslt attribute node on the source node */ void xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr castedComp) { … } /** * 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) { … } static void xsltFreeAttributeSetsEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) { … } /** * xsltFreeAttributeSetsHashes: * @style: an XSLT stylesheet * * Free up the memory used by attribute sets */ void xsltFreeAttributeSetsHashes(xsltStylesheetPtr style) { … }