/* * attrvt.c: Implementation of the XSL Transformation 1.0 engine * attribute value template handling part. * * References: * http://www.w3.org/TR/1999/REC-xslt-19991116 * * Michael Kay "XSLT Programmer's Reference" pp 637-643 * Writing Multiple Output Files * * 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/xpath.h> #include <libxml/xpathInternals.h> #include "xslt.h" #include "xsltutils.h" #include "xsltInternals.h" #include "templates.h" #ifdef WITH_XSLT_DEBUG #define WITH_XSLT_DEBUG_AVT #endif #define MAX_AVT_SEG … xsltAttrVT; xsltAttrVTPtr; struct _xsltAttrVT { … }; /** * xsltNewAttrVT: * @style: a XSLT process context * * Build a new xsltAttrVT structure * * Returns the structure or NULL in case of error */ static xsltAttrVTPtr xsltNewAttrVT(xsltStylesheetPtr style) { … } /** * xsltFreeAttrVT: * @avt: pointer to an xsltAttrVT structure * * Free up the memory associated to the attribute value template */ static void xsltFreeAttrVT(xsltAttrVTPtr avt) { … } /** * xsltFreeAVTList: * @avt: pointer to an list of AVT structures * * Free up the memory associated to the attribute value templates */ void xsltFreeAVTList(void *avt) { … } /** * xsltSetAttrVTsegment: * @ avt: pointer to an xsltAttrVT structure * @ val: the value to be set to the next available segment * * Within xsltCompileAttr there are several places where a value * needs to be added to the 'segments' array within the xsltAttrVT * structure, and at each place the allocated size may have to be * re-allocated. This routine takes care of that situation. * * Returns the avt pointer, which may have been changed by a re-alloc */ static xsltAttrVTPtr xsltSetAttrVTsegment(xsltAttrVTPtr avt, void *val) { … } /** * xsltCompileAttr: * @style: a XSLT process context * @attr: the attribute coming from the stylesheet. * * Precompile an attribute in a stylesheet, basically it checks if it is * an attribute value template, and if yes, establish some structures needed * to process it at transformation time. */ void xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) { … } /** * xsltEvalAVT: * @ctxt: the XSLT transformation context * @avt: the prevompiled attribute value template info * @node: the node hosting the attribute * * Process the given AVT, and return the new string value. * * Returns the computed string value or NULL, must be deallocated by the * caller. */ xmlChar * xsltEvalAVT(xsltTransformContextPtr ctxt, void *avt, xmlNodePtr node) { … }