ReactOS 0.4.16-dev-2208-g6350669
transform.h File Reference
#include <libxml/parser.h>
#include <libxml/xmlIO.h>
#include "xsltexports.h"
#include <libxslt/xsltInternals.h>
Include dependency graph for transform.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

XSLTPUBFUN void XSLTCALL xsltSetXIncludeDefault (int xinclude)
 
XSLTPUBFUN int XSLTCALL xsltGetXIncludeDefault (void)
 
XSLTPUBFUN xsltTransformContextPtr XSLTCALL xsltNewTransformContext (xsltStylesheetPtr style, xmlDocPtr doc)
 
XSLTPUBFUN void XSLTCALL xsltFreeTransformContext (xsltTransformContextPtr ctxt)
 
XSLTPUBFUN xmlDocPtr XSLTCALL xsltApplyStylesheetUser (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, FILE *profile, xsltTransformContextPtr userCtxt)
 
XSLTPUBFUN void XSLTCALL xsltProcessOneNode (xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStackElemPtr params)
 
XSLTPUBFUN void XSLTCALL xsltApplyStripSpaces (xsltTransformContextPtr ctxt, xmlNodePtr node)
 
XSLTPUBFUN xmlDocPtr XSLTCALL xsltApplyStylesheet (xsltStylesheetPtr style, xmlDocPtr doc, const char **params)
 
XSLTPUBFUN xmlDocPtr XSLTCALL xsltProfileStylesheet (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, FILE *output)
 
XSLTPUBFUN int XSLTCALL xsltRunStylesheet (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf)
 
XSLTPUBFUN int XSLTCALL xsltRunStylesheetUser (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf, FILE *profile, xsltTransformContextPtr userCtxt)
 
XSLTPUBFUN void XSLTCALL xsltApplyOneTemplate (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr list, xsltTemplatePtr templ, xsltStackElemPtr params)
 
XSLTPUBFUN void XSLTCALL xsltDocumentElem (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltSort (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltCopy (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltText (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltElement (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltComment (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltAttribute (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltProcessingInstruction (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltCopyOf (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltValueOf (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltNumber (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltApplyImports (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltCallTemplate (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltApplyTemplates (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltChoose (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltIf (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltForEach (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
XSLTPUBFUN void XSLTCALL xsltRegisterAllElement (xsltTransformContextPtr ctxt)
 
XSLTPUBFUN xmlNodePtr XSLTCALL xsltCopyTextString (xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int noescape)
 
XSLTPUBFUN void XSLTCALL xsltLocalVariablePop (xsltTransformContextPtr ctxt, int limitNr, int level)
 
XSLTPUBFUN int XSLTCALL xsltLocalVariablePush (xsltTransformContextPtr ctxt, xsltStackElemPtr variable, int level)
 
XSLTPUBFUN void XSLTCALL xslHandleDebugger (xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
 

Function Documentation

◆ xslHandleDebugger()

◆ xsltApplyImports()

XSLTPUBFUN void XSLTCALL xsltApplyImports ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  inst,
xsltElemPreCompPtr comp  ATTRIBUTE_UNUSED 
)

xsltApplyImports: @ctxt: an XSLT transformation context @contextNode: the current node in the source tree. @inst: the element node of the XSLT 'apply-imports' instruction @comp: the compiled instruction

Process the XSLT apply-imports element.

Definition at line 4650 of file transform.c.

4653{
4654 xsltTemplatePtr templ;
4655
4656 if ((ctxt == NULL) || (inst == NULL))
4657 return;
4658
4659 if (comp == NULL) {
4660 xsltTransformError(ctxt, NULL, inst,
4661 "Internal error in xsltApplyImports(): "
4662 "The XSLT 'apply-imports' instruction was not compiled.\n");
4663 return;
4664 }
4665 /*
4666 * NOTE that ctxt->currentTemplateRule and ctxt->templ is not the
4667 * same; the former is the "Current Template Rule" as defined by the
4668 * XSLT spec, the latter is simply the template struct being
4669 * currently processed.
4670 */
4671 if (ctxt->currentTemplateRule == NULL) {
4672 /*
4673 * SPEC XSLT 2.0:
4674 * "[ERR XTDE0560] It is a non-recoverable dynamic error if
4675 * xsl:apply-imports or xsl:next-match is evaluated when the
4676 * current template rule is null."
4677 */
4678 xsltTransformError(ctxt, NULL, inst,
4679 "It is an error to call 'apply-imports' "
4680 "when there's no current template rule.\n");
4681 return;
4682 }
4683 /*
4684 * TODO: Check if this is correct.
4685 */
4686 templ = xsltGetTemplate(ctxt, contextNode,
4687 ctxt->currentTemplateRule->style);
4688
4689 if (templ != NULL) {
4690 xsltTemplatePtr oldCurTemplRule = ctxt->currentTemplateRule;
4691 /*
4692 * Set the current template rule.
4693 */
4694 ctxt->currentTemplateRule = templ;
4695 /*
4696 * URGENT TODO: Need xsl:with-param be handled somehow here?
4697 */
4698 xsltApplyXSLTTemplate(ctxt, contextNode, templ->content,
4699 templ, NULL);
4700
4701 ctxt->currentTemplateRule = oldCurTemplRule;
4702 }
4703 else {
4704 /* Use built-in templates. */
4705 xsltDefaultProcessOneNode(ctxt, contextNode, NULL);
4706 }
4707}
#define NULL
Definition: types.h:112
xsltTemplatePtr xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylesheetPtr style)
Definition: pattern.c:2277
static void xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ, xsltStackElemPtr withParams)
Definition: transform.c:3066
static void xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStackElemPtr params)
Definition: transform.c:1893
xmlNodePtr content
struct _xsltStylesheet * style
xsltTemplatePtr currentTemplateRule
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltApplyOneTemplate()

XSLTPUBFUN void XSLTCALL xsltApplyOneTemplate ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  list,
xsltTemplatePtr templ  ATTRIBUTE_UNUSED,
xsltStackElemPtr  params 
)

xsltApplyOneTemplate: @ctxt: a XSLT process context @contextNode: the node in the source tree. @list: the nodes of a sequence constructor @templ: not used @params: a set of parameters (xsl:param) or NULL

Processes a sequence constructor on the current node in the source tree.

@params are the already computed variable stack items; this function pushes them on the variable stack, and pops them before exiting; it's left to the caller to free or reuse @params afterwards. The initial states of the variable stack will always be restored before this function exits. NOTE that this does not initiate a new distinct variable scope; i.e. variables already on the stack are visible to the process. The caller's side needs to start a new variable scope if needed (e.g. in exsl:function).

@templ is obsolete and not used anymore (e.g. <exslt:function> does not provide a @templ); a non-NULL @templ might raise an error in the future.

BIG NOTE: This function is not intended to process the content of an xsl:template; it does not expect xsl:param instructions in @list and will report errors if found.

Called by:

Definition at line 3313 of file transform.c.

3318{
3319 if ((ctxt == NULL) || (list == NULL))
3320 return;
3322
3323 if (params) {
3324 /*
3325 * This code should be obsolete - was previously used
3326 * by libexslt/functions.c, but due to bug 381319 the
3327 * logic there was changed.
3328 */
3329 int oldVarsNr = ctxt->varsNr;
3330
3331 /*
3332 * Push the given xsl:param(s) onto the variable stack.
3333 */
3334 while (params != NULL) {
3335 xsltLocalVariablePush(ctxt, params, -1);
3336 params = params->next;
3337 }
3338 xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
3339 /*
3340 * Pop the given xsl:param(s) from the stack but don't free them.
3341 */
3342 xsltLocalVariablePop(ctxt, oldVarsNr, -2);
3343 } else
3344 xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
3345}
Definition: list.h:37
void xsltLocalVariablePop(xsltTransformContextPtr ctxt, int limitNr, int level)
Definition: transform.c:178
int xsltLocalVariablePush(xsltTransformContextPtr ctxt, xsltStackElemPtr variable, int level)
Definition: transform.c:2236
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2318
GLenum const GLfloat * params
Definition: glext.h:5645
#define CHECK_STOPPED

Referenced by xsltEvalGlobalVariable(), xsltEvalTemplateString(), and xsltEvalVariable().

◆ xsltApplyStripSpaces()

XSLTPUBFUN void XSLTCALL xsltApplyStripSpaces ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node 
)

Private Interfaces.

xsltApplyStripSpaces: @ctxt: a XSLT process context @node: the root of the XML tree

Strip the unwanted ignorable spaces from the input tree

Definition at line 5649 of file transform.c.

5649 {
5650 xmlNodePtr current;
5651#ifdef WITH_XSLT_DEBUG_PROCESS
5652 int nb = 0;
5653#endif
5654
5655
5656 current = node;
5657 while (current != NULL) {
5658 /*
5659 * Cleanup children empty nodes if asked for
5660 */
5661 if ((IS_XSLT_REAL_NODE(current)) &&
5662 (current->children != NULL) &&
5664 xmlNodePtr delete = NULL, cur = current->children;
5665
5666 while (cur != NULL) {
5667 if (IS_BLANK_NODE(cur))
5668 delete = cur;
5669
5670 cur = cur->next;
5671 if (delete != NULL) {
5672 xmlUnlinkNode(delete);
5673 xmlFreeNode(delete);
5674 delete = NULL;
5675#ifdef WITH_XSLT_DEBUG_PROCESS
5676 nb++;
5677#endif
5678 }
5679 }
5680 }
5681
5682 /*
5683 * Skip to next node in document order.
5684 */
5685 if (node->type == XML_ENTITY_REF_NODE) {
5686 /* process deep in entities */
5687 xsltApplyStripSpaces(ctxt, node->children);
5688 }
5689 if ((current->children != NULL) &&
5690 (current->type != XML_ENTITY_REF_NODE)) {
5691 current = current->children;
5692 } else if (current->next != NULL) {
5693 current = current->next;
5694 } else {
5695 do {
5696 current = current->parent;
5697 if (current == NULL)
5698 break;
5699 if (current == node)
5700 goto done;
5701 if (current->next != NULL) {
5702 current = current->next;
5703 break;
5704 }
5705 } while (current != NULL);
5706 }
5707 }
5708
5709done:
5710#ifdef WITH_XSLT_DEBUG_PROCESS
5712 "xsltApplyStripSpaces: removed %d ignorable blank node\n", nb));
5713#endif
5714 return;
5715}
#define IS_BLANK_NODE(n)
Definition: transform.c:83
void xsltApplyStripSpaces(xsltTransformContextPtr ctxt, xmlNodePtr node)
Definition: transform.c:5649
FxCollectionEntry * cur
int xsltFindElemSpaceHandling(xsltTransformContextPtr ctxt, xmlNodePtr node)
Definition: imports.c:349
struct task_struct * current
Definition: linux.c:32
Definition: dlist.c:348
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633
@ XSLT_TRACE_STRIP_SPACES
Definition: xsltutils.h:121
#define IS_XSLT_REAL_NODE(n)
Definition: xsltutils.h:68
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:132

Referenced by xsltApplyStripSpaces(), xsltApplyStylesheetInternal(), and xsltLoadDocument().

◆ xsltApplyStylesheet()

XSLTPUBFUN xmlDocPtr XSLTCALL xsltApplyStylesheet ( xsltStylesheetPtr  style,
xmlDocPtr  doc,
const char **  params 
)

xsltApplyStylesheet: @style: a parsed XSLT stylesheet @doc: a parsed XML document @params: a NULL terminated arry of parameters names/values tuples

Apply the stylesheet to the document NOTE: This may lead to a non-wellformed output XML wise !

Returns the result document or NULL in case of error

Definition at line 6230 of file transform.c.

6232{
6234}
Arabic default style
Definition: afstyles.h:94
static xmlDocPtr xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, FILE *profile, xsltTransformContextPtr userCtxt)
Definition: transform.c:5812

Referenced by node_transform_node_params().

◆ xsltApplyStylesheetUser()

XSLTPUBFUN xmlDocPtr XSLTCALL xsltApplyStylesheetUser ( xsltStylesheetPtr  style,
xmlDocPtr  doc,
const char **  params,
const char output,
FILE profile,
xsltTransformContextPtr  userCtxt 
)

xsltApplyStylesheetUser: @style: a parsed XSLT stylesheet @doc: a parsed XML document @params: a NULL terminated array of parameters names/values tuples @output: the targetted output @profile: profile FILE * output or NULL @userCtxt: user provided transform context

Apply the stylesheet to the document and allow the user to provide its own transformation context.

Returns the result document or NULL in case of error

Definition at line 6273 of file transform.c.

6276{
6277 xmlDocPtr res;
6278
6280 profile, userCtxt);
6281 return (res);
6282}
GLuint res
Definition: glext.h:9613
#define profile
Definition: kernel32.h:12

Referenced by node_transform_node_params().

◆ xsltApplyTemplates()

XSLTPUBFUN void XSLTCALL xsltApplyTemplates ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltApplyTemplates: @ctxt: a XSLT transformation context @node: the 'current node' in the source tree @inst: the element node of an XSLT 'apply-templates' instruction @castedComp: the compiled instruction

Processes the XSLT 'apply-templates' instruction on the current node.

Definition at line 4822 of file transform.c.

4824{
4825#ifdef XSLT_REFACTORED
4826 xsltStyleItemApplyTemplatesPtr comp =
4827 (xsltStyleItemApplyTemplatesPtr) castedComp;
4828#else
4829 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4830#endif
4831 int i;
4832 xmlNodePtr cur, oldContextNode;
4833 xmlNodeSetPtr list = NULL, oldList;
4834 xsltStackElemPtr withParams = NULL;
4835 int oldXPProximityPosition, oldXPContextSize;
4836 const xmlChar *oldMode, *oldModeURI;
4837 xmlDocPtr oldXPDoc;
4838 xsltDocumentPtr oldDocInfo;
4839 xmlXPathContextPtr xpctxt;
4840
4841 if (comp == NULL) {
4842 xsltTransformError(ctxt, NULL, inst,
4843 "xsl:apply-templates : compilation failed\n");
4844 return;
4845 }
4846 if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
4847 return;
4848
4849#ifdef WITH_XSLT_DEBUG_PROCESS
4850 if ((node != NULL) && (node->name != NULL))
4852 "xsltApplyTemplates: node: '%s'\n", node->name));
4853#endif
4854
4855 xpctxt = ctxt->xpathCtxt;
4856 /*
4857 * Save context states.
4858 */
4859 oldContextNode = ctxt->node;
4860 oldMode = ctxt->mode;
4861 oldModeURI = ctxt->modeURI;
4862 oldDocInfo = ctxt->document;
4863 oldList = ctxt->nodeList;
4864
4865 /*
4866 * The xpath context size and proximity position, as
4867 * well as the xpath and context documents, may be changed
4868 * so we save their initial state and will restore on exit
4869 */
4870 oldXPContextSize = xpctxt->contextSize;
4871 oldXPProximityPosition = xpctxt->proximityPosition;
4872 oldXPDoc = xpctxt->doc;
4873
4874 /*
4875 * Set up contexts.
4876 */
4877 ctxt->mode = comp->mode;
4878 ctxt->modeURI = comp->modeURI;
4879
4880 if (comp->select != NULL) {
4881 xmlXPathObjectPtr res = NULL;
4882
4883 if (comp->comp == NULL) {
4884 xsltTransformError(ctxt, NULL, inst,
4885 "xsl:apply-templates : compilation failed\n");
4886 goto error;
4887 }
4888#ifdef WITH_XSLT_DEBUG_PROCESS
4890 "xsltApplyTemplates: select %s\n", comp->select));
4891#endif
4892
4893 res = xsltPreCompEval(ctxt, node, comp);
4894
4895 if (res != NULL) {
4896 if (res->type == XPATH_NODESET) {
4897 list = res->nodesetval; /* consume the node set */
4898 res->nodesetval = NULL;
4899 } else {
4900 xsltTransformError(ctxt, NULL, inst,
4901 "The 'select' expression did not evaluate to a "
4902 "node set.\n");
4903 ctxt->state = XSLT_STATE_STOPPED;
4904 xmlXPathFreeObject(res);
4905 goto error;
4906 }
4907 xmlXPathFreeObject(res);
4908 /*
4909 * Note: An xsl:apply-templates with a 'select' attribute,
4910 * can change the current source doc.
4911 */
4912 } else {
4913 xsltTransformError(ctxt, NULL, inst,
4914 "Failed to evaluate the 'select' expression.\n");
4915 ctxt->state = XSLT_STATE_STOPPED;
4916 goto error;
4917 }
4918 if (list == NULL) {
4919#ifdef WITH_XSLT_DEBUG_PROCESS
4921 "xsltApplyTemplates: select didn't evaluate to a node list\n"));
4922#endif
4923 goto exit;
4924 }
4925 /*
4926 *
4927 * NOTE: Previously a document info (xsltDocument) was
4928 * created and attached to the Result Tree Fragment.
4929 * But such a document info is created on demand in
4930 * xsltKeyFunction() (functions.c), so we need to create
4931 * it here beforehand.
4932 * In order to take care of potential keys we need to
4933 * do some extra work for the case when a Result Tree Fragment
4934 * is converted into a nodeset (e.g. exslt:node-set()) :
4935 * We attach a "pseudo-doc" (xsltDocument) to _private.
4936 * This xsltDocument, together with the keyset, will be freed
4937 * when the Result Tree Fragment is freed.
4938 *
4939 */
4940#if 0
4941 if ((ctxt->nbKeys > 0) &&
4942 (list->nodeNr != 0) &&
4943 (list->nodeTab[0]->doc != NULL) &&
4944 XSLT_IS_RES_TREE_FRAG(list->nodeTab[0]->doc))
4945 {
4946 /*
4947 * NOTE that it's also OK if @effectiveDocInfo will be
4948 * set to NULL.
4949 */
4950 isRTF = 1;
4951 effectiveDocInfo = list->nodeTab[0]->doc->_private;
4952 }
4953#endif
4954 } else {
4955 /*
4956 * Build an XPath node set with the children
4957 */
4958 list = xmlXPathNodeSetCreate(NULL);
4959 if (list == NULL)
4960 goto error;
4961 if (node->type != XML_NAMESPACE_DECL)
4962 cur = node->children;
4963 else
4964 cur = NULL;
4965 while (cur != NULL) {
4967 xmlXPathNodeSetAddUnique(list, cur);
4968 cur = cur->next;
4969 }
4970 }
4971
4972#ifdef WITH_XSLT_DEBUG_PROCESS
4973 if (list != NULL)
4975 "xsltApplyTemplates: list of %d nodes\n", list->nodeNr));
4976#endif
4977
4978 if ((list == NULL) || (list->nodeNr == 0))
4979 goto exit;
4980
4981 /*
4982 * Set the context's node set and size; this is also needed for
4983 * for xsltDoSortFunction().
4984 */
4985 ctxt->nodeList = list;
4986 /*
4987 * Process xsl:with-param and xsl:sort instructions.
4988 * (The code became so verbose just to avoid the
4989 * xmlNodePtr sorts[XSLT_MAX_SORT] if there's no xsl:sort)
4990 * BUG TODO: We are not using namespaced potentially defined on the
4991 * xsl:sort or xsl:with-param elements; XPath expression might fail.
4992 */
4993 if (inst->children) {
4995
4996 cur = inst->children;
4997 while (cur) {
4998
4999#ifdef WITH_DEBUGGER
5000 if (ctxt->debugStatus != XSLT_DEBUG_NONE)
5001 xslHandleDebugger(cur, node, NULL, ctxt);
5002#endif
5003 if (ctxt->state == XSLT_STATE_STOPPED)
5004 break;
5005 if (cur->type == XML_TEXT_NODE) {
5006 cur = cur->next;
5007 continue;
5008 }
5009 if (! IS_XSLT_ELEM(cur))
5010 break;
5011 if (IS_XSLT_NAME(cur, "with-param")) {
5013 if (param != NULL) {
5014 param->next = withParams;
5015 withParams = param;
5016 }
5017 }
5018 if (IS_XSLT_NAME(cur, "sort")) {
5019 xsltTemplatePtr oldCurTempRule =
5020 ctxt->currentTemplateRule;
5021 int nbsorts = 0;
5022 xmlNodePtr sorts[XSLT_MAX_SORT];
5023
5024 sorts[nbsorts++] = cur;
5025 cur = cur->next;
5026
5027 while (cur) {
5028
5029#ifdef WITH_DEBUGGER
5030 if (ctxt->debugStatus != XSLT_DEBUG_NONE)
5031 xslHandleDebugger(cur, node, NULL, ctxt);
5032#endif
5033 if (ctxt->state == XSLT_STATE_STOPPED)
5034 break;
5035
5036 if (cur->type == XML_TEXT_NODE) {
5037 cur = cur->next;
5038 continue;
5039 }
5040
5041 if (! IS_XSLT_ELEM(cur))
5042 break;
5043 if (IS_XSLT_NAME(cur, "with-param")) {
5045 if (param != NULL) {
5046 param->next = withParams;
5047 withParams = param;
5048 }
5049 }
5050 if (IS_XSLT_NAME(cur, "sort")) {
5051 if (nbsorts >= XSLT_MAX_SORT) {
5053 "The number (%d) of xsl:sort instructions exceeds the "
5054 "maximum allowed by this processor's settings.\n",
5055 nbsorts);
5056 ctxt->state = XSLT_STATE_STOPPED;
5057 break;
5058 } else {
5059 sorts[nbsorts++] = cur;
5060 }
5061 }
5062 cur = cur->next;
5063 }
5064 /*
5065 * The "current template rule" is cleared for xsl:sort.
5066 */
5067 ctxt->currentTemplateRule = NULL;
5068 /*
5069 * Sort.
5070 */
5071 xsltDoSortFunction(ctxt, sorts, nbsorts);
5072 ctxt->currentTemplateRule = oldCurTempRule;
5073 break;
5074 }
5075 cur = cur->next;
5076 }
5077 }
5078 xpctxt->contextSize = list->nodeNr;
5079 /*
5080 * Apply templates for all selected source nodes.
5081 */
5082 for (i = 0; i < list->nodeNr; i++) {
5083 cur = list->nodeTab[i];
5084 /*
5085 * The node becomes the "current node".
5086 */
5087 ctxt->node = cur;
5088 /*
5089 * An xsl:apply-templates can change the current context doc.
5090 * OPTIMIZE TODO: Get rid of the need to set the context doc.
5091 */
5092 if ((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL))
5093 xpctxt->doc = cur->doc;
5094
5095 xpctxt->proximityPosition = i + 1;
5096 /*
5097 * Find and apply a template for this node.
5098 */
5099 xsltProcessOneNode(ctxt, cur, withParams);
5100 }
5101
5102exit:
5103error:
5104 /*
5105 * Free the parameter list.
5106 */
5107 if (withParams != NULL)
5108 xsltFreeStackElemList(withParams);
5109 if (list != NULL)
5110 xmlXPathFreeNodeSet(list);
5111 /*
5112 * Restore context states.
5113 */
5114 xpctxt->doc = oldXPDoc;
5115 xpctxt->contextSize = oldXPContextSize;
5116 xpctxt->proximityPosition = oldXPProximityPosition;
5117
5118 ctxt->document = oldDocInfo;
5119 ctxt->nodeList = oldList;
5120 ctxt->node = oldContextNode;
5121 ctxt->mode = oldMode;
5122 ctxt->modeURI = oldModeURI;
5123}
static xmlXPathObjectPtr xsltPreCompEval(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:349
void xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xsltStackElemPtr withParams)
Definition: transform.c:2112
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define error(str)
Definition: mkdosfs.c:1605
#define list
Definition: rosglue.h:35
#define exit(n)
Definition: config.h:202
xsltTransformState state
const xmlChar * modeURI
xsltDocumentPtr document
xmlNodeSetPtr nodeList
xmlXPathContextPtr xpathCtxt
const xmlChar * mode
XSLTPUBFUN void XSLTCALL xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
xsltStackElemPtr xsltParseStylesheetCallerParam(xsltTransformContextPtr ctxt, xmlNodePtr inst)
Definition: variables.c:1989
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:626
unsigned char xmlChar
Definition: xmlstring.h:28
@ XSLT_STATE_STOPPED
#define XSLT_MAX_SORT
#define XSLT_IS_RES_TREE_FRAG(n)
Definition: xsltInternals.h:55
xsltStylePreComp * xsltStylePreCompPtr
void xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
Definition: xsltutils.c:1447
@ XSLT_DEBUG_NONE
Definition: xsltutils.h:304
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:60
@ XSLT_TRACE_APPLY_TEMPLATES
Definition: xsltutils.h:117
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:51

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltAttribute()

XSLTPUBFUN void XSLTCALL xsltAttribute ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

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

Definition at line 748 of file attributes.c.

752{
753#ifdef XSLT_REFACTORED
754 xsltStyleItemAttributePtr comp =
755 (xsltStyleItemAttributePtr) castedComp;
756#else
757 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
758#endif
759 xmlNodePtr targetElem;
760 xmlChar *prop = NULL;
761 const xmlChar *name = NULL, *prefix = NULL, *nsName = NULL;
762 xmlChar *value = NULL;
763 xmlNsPtr ns = NULL;
764 xmlAttrPtr attr;
765
766 if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL) ||
767 (inst->type != XML_ELEMENT_NODE) )
768 return;
769
770 /*
771 * A comp->has_name == 0 indicates that we need to skip this instruction,
772 * since it was evaluated to be invalid already during compilation.
773 */
774 if (!comp->has_name)
775 return;
776 /*
777 * BIG NOTE: This previously used xsltGetSpecialNamespace() and
778 * xsltGetNamespace(), but since both are not appropriate, we
779 * will process namespace lookup here to avoid adding yet another
780 * ns-lookup function to namespaces.c.
781 */
782 /*
783 * SPEC XSLT 1.0: Error cases:
784 * - Creating nodes other than text nodes during the instantiation of
785 * the content of the xsl:attribute element; implementations may
786 * either signal the error or ignore the offending nodes."
787 */
788
789 if (comp == NULL) {
790 xsltTransformError(ctxt, NULL, inst,
791 "Internal error in xsltAttribute(): "
792 "The XSLT 'attribute' instruction was not compiled.\n");
793 return;
794 }
795 /*
796 * TODO: Shouldn't ctxt->insert == NULL be treated as an internal error?
797 * So report an internal error?
798 */
799 if (ctxt->insert == NULL)
800 return;
801 /*
802 * SPEC XSLT 1.0:
803 * "Adding an attribute to a node that is not an element;
804 * implementations may either signal the error or ignore the attribute."
805 *
806 * TODO: I think we should signal such errors in the future, and maybe
807 * provide an option to ignore such errors.
808 */
809 targetElem = ctxt->insert;
810 if (targetElem->type != XML_ELEMENT_NODE)
811 return;
812
813 /*
814 * SPEC XSLT 1.0:
815 * "Adding an attribute to an element after children have been added
816 * to it; implementations may either signal the error or ignore the
817 * attribute."
818 *
819 * TODO: We should decide whether not to report such errors or
820 * to ignore them; note that we *ignore* if the parent is not an
821 * element, but here we report an error.
822 */
823 if (targetElem->children != NULL) {
824 /*
825 * NOTE: Ah! This seems to be intended to support streamed
826 * result generation!.
827 */
828 xsltTransformError(ctxt, NULL, inst,
829 "xsl:attribute: Cannot add attributes to an "
830 "element if children have been already added "
831 "to the element.\n");
832 return;
833 }
834
835 /*
836 * Process the name
837 * ----------------
838 */
839
840#ifdef WITH_DEBUGGER
841 if (ctxt->debugStatus != XSLT_DEBUG_NONE)
842 xslHandleDebugger(inst, contextNode, NULL, ctxt);
843#endif
844
845 if (comp->name == NULL) {
846 /* TODO: fix attr acquisition wrt to the XSLT namespace */
847 prop = xsltEvalAttrValueTemplate(ctxt, inst,
848 (const xmlChar *) "name", XSLT_NAMESPACE);
849 if (prop == NULL) {
850 xsltTransformError(ctxt, NULL, inst,
851 "xsl:attribute: The attribute 'name' is missing.\n");
852 goto error;
853 }
854 if (xmlValidateQName(prop, 0)) {
855 xsltTransformError(ctxt, NULL, inst,
856 "xsl:attribute: The effective name '%s' is not a "
857 "valid QName.\n", prop);
858 /* we fall through to catch any further errors, if possible */
859 }
860
861 /*
862 * Reject a name of "xmlns".
863 */
864 if (xmlStrEqual(prop, BAD_CAST "xmlns")) {
865 xsltTransformError(ctxt, NULL, inst,
866 "xsl:attribute: The effective name 'xmlns' is not allowed.\n");
867 xmlFree(prop);
868 goto error;
869 }
870
871 name = xsltSplitQName(ctxt->dict, prop, &prefix);
872 xmlFree(prop);
873 } else {
874 /*
875 * The "name" value was static.
876 */
877#ifdef XSLT_REFACTORED
878 prefix = comp->nsPrefix;
879 name = comp->name;
880#else
881 name = xsltSplitQName(ctxt->dict, comp->name, &prefix);
882#endif
883 }
884
885 /*
886 * Process namespace semantics
887 * ---------------------------
888 *
889 * Evaluate the namespace name.
890 */
891 if (comp->has_ns) {
892 /*
893 * The "namespace" attribute was existent.
894 */
895 if (comp->ns != NULL) {
896 /*
897 * No AVT; just plain text for the namespace name.
898 */
899 if (comp->ns[0] != 0)
900 nsName = comp->ns;
901 } else {
902 xmlChar *tmpNsName;
903 /*
904 * Eval the AVT.
905 */
906 /* TODO: check attr acquisition wrt to the XSLT namespace */
907 tmpNsName = xsltEvalAttrValueTemplate(ctxt, inst,
908 (const xmlChar *) "namespace", XSLT_NAMESPACE);
909 /*
910 * This fixes bug #302020: The AVT might also evaluate to the
911 * empty string; this means that the empty string also indicates
912 * "no namespace".
913 * SPEC XSLT 1.0:
914 * "If the string is empty, then the expanded-name of the
915 * attribute has a null namespace URI."
916 */
917 if ((tmpNsName != NULL) && (tmpNsName[0] != 0))
918 nsName = xmlDictLookup(ctxt->dict, BAD_CAST tmpNsName, -1);
919 xmlFree(tmpNsName);
920 }
921
922 if (xmlStrEqual(nsName, BAD_CAST "http://www.w3.org/2000/xmlns/")) {
923 xsltTransformError(ctxt, NULL, inst,
924 "xsl:attribute: Namespace http://www.w3.org/2000/xmlns/ "
925 "forbidden.\n");
926 goto error;
927 }
928 if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
929 prefix = BAD_CAST "xml";
930 } else if (xmlStrEqual(prefix, BAD_CAST "xml")) {
931 prefix = NULL;
932 }
933 } else if (prefix != NULL) {
934 /*
935 * SPEC XSLT 1.0:
936 * "If the namespace attribute is not present, then the QName is
937 * expanded into an expanded-name using the namespace declarations
938 * in effect for the xsl:attribute element, *not* including any
939 * default namespace declaration."
940 */
941 ns = xmlSearchNs(inst->doc, inst, prefix);
942 if (ns == NULL) {
943 /*
944 * Note that this is treated as an error now (checked with
945 * Saxon, Xalan-J and MSXML).
946 */
947 xsltTransformError(ctxt, NULL, inst,
948 "xsl:attribute: The QName '%s:%s' has no "
949 "namespace binding in scope in the stylesheet; "
950 "this is an error, since the namespace was not "
951 "specified by the instruction itself.\n", prefix, name);
952 } else
953 nsName = ns->href;
954 }
955
956 /*
957 * Find/create a matching ns-decl in the result tree.
958 */
959 ns = NULL;
960
961#if 0
962 if (0) {
963 /*
964 * OPTIMIZE TODO: How do we know if we are adding to a
965 * fragment or to the result tree?
966 *
967 * If we are adding to a result tree fragment (i.e., not to the
968 * actual result tree), we'll don't bother searching for the
969 * ns-decl, but just store it in the dummy-doc of the result
970 * tree fragment.
971 */
972 if (nsName != NULL) {
973 /*
974 * TODO: Get the doc of @targetElem.
975 */
976 ns = xsltTreeAcquireStoredNs(some doc, nsName, prefix);
977 }
978 }
979#endif
980
981 if (nsName != NULL) {
982 /*
983 * Something about ns-prefixes:
984 * SPEC XSLT 1.0:
985 * "XSLT processors may make use of the prefix of the QName specified
986 * in the name attribute when selecting the prefix used for outputting
987 * the created attribute as XML; however, they are not required to do
988 * so and, if the prefix is xmlns, they must not do so"
989 */
990 /*
991 * xsl:attribute can produce a scenario where the prefix is NULL,
992 * so generate a prefix.
993 */
994 if ((prefix == NULL) || xmlStrEqual(prefix, BAD_CAST "xmlns")) {
995 xmlChar *pref = xmlStrdup(BAD_CAST "ns_1");
996
997 ns = xsltGetSpecialNamespace(ctxt, inst, nsName, pref, targetElem);
998
999 xmlFree(pref);
1000 } else {
1001 ns = xsltGetSpecialNamespace(ctxt, inst, nsName, prefix,
1002 targetElem);
1003 }
1004 if (ns == NULL) {
1005 xsltTransformError(ctxt, NULL, inst,
1006 "Namespace fixup error: Failed to acquire an in-scope "
1007 "namespace binding for the generated attribute '{%s}%s'.\n",
1008 nsName, name);
1009 goto error;
1010 }
1011 }
1012 /*
1013 * Construction of the value
1014 * -------------------------
1015 */
1016 if (inst->children == NULL) {
1017 /*
1018 * No content.
1019 * TODO: Do we need to put the empty string in ?
1020 */
1021 attr = xmlSetNsProp(ctxt->insert, ns, name, (const xmlChar *) "");
1022 } else if ((inst->children->next == NULL) &&
1023 ((inst->children->type == XML_TEXT_NODE) ||
1024 (inst->children->type == XML_CDATA_SECTION_NODE)))
1025 {
1026 xmlNodePtr copyTxt;
1027
1028 /*
1029 * xmlSetNsProp() will take care of duplicates.
1030 */
1031 attr = xmlSetNsProp(ctxt->insert, ns, name, NULL);
1032 if (attr == NULL) /* TODO: report error ? */
1033 goto error;
1034 /*
1035 * This was taken over from xsltCopyText() (transform.c).
1036 */
1037 if (ctxt->internalized &&
1038 (ctxt->insert->doc != NULL) &&
1039 (ctxt->insert->doc->dict == ctxt->dict))
1040 {
1041 copyTxt = xmlNewText(NULL);
1042 if (copyTxt == NULL) /* TODO: report error */
1043 goto error;
1044 /*
1045 * This is a safe scenario where we don't need to lookup
1046 * the dict.
1047 */
1048 copyTxt->content = inst->children->content;
1049 /*
1050 * Copy "disable-output-escaping" information.
1051 * TODO: Does this have any effect for attribute values
1052 * anyway?
1053 */
1054 if (inst->children->name == xmlStringTextNoenc)
1055 copyTxt->name = xmlStringTextNoenc;
1056 } else {
1057 /*
1058 * Copy the value.
1059 */
1060 copyTxt = xmlNewText(inst->children->content);
1061 if (copyTxt == NULL) /* TODO: report error */
1062 goto error;
1063 }
1064 attr->children = attr->last = copyTxt;
1065 copyTxt->parent = (xmlNodePtr) attr;
1066 copyTxt->doc = attr->doc;
1067 /*
1068 * Copy "disable-output-escaping" information.
1069 * TODO: Does this have any effect for attribute values
1070 * anyway?
1071 */
1072 if (inst->children->name == xmlStringTextNoenc)
1073 copyTxt->name = xmlStringTextNoenc;
1074
1075 /*
1076 * since we create the attribute without content IDness must be
1077 * asserted as a second step
1078 */
1079 if ((copyTxt->content != NULL) &&
1080 (xmlIsID(attr->doc, attr->parent, attr)))
1081 xmlAddID(NULL, attr->doc, copyTxt->content, attr);
1082 } else {
1083 /*
1084 * The sequence constructor might be complex, so instantiate it.
1085 */
1086 value = xsltEvalTemplateString(ctxt, contextNode, inst);
1087 if (value != NULL) {
1088 attr = xmlSetNsProp(ctxt->insert, ns, name, value);
1089 xmlFree(value);
1090 } else {
1091 /*
1092 * TODO: Do we have to add the empty string to the attr?
1093 * TODO: Does a value of NULL indicate an
1094 * error in xsltEvalTemplateString() ?
1095 */
1096 attr = xmlSetNsProp(ctxt->insert, ns, name,
1097 (const xmlChar *) "");
1098 }
1099 }
1100
1101error:
1102 return;
1103}
xmlNsPtr xsltGetSpecialNamespace(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, const xmlChar *nsName, const xmlChar *nsPrefix, xmlNodePtr target)
Definition: namespaces.c:319
XMLPUBVAR const xmlChar xmlStringTextNoenc[]
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
xmlFreeFunc xmlFree
Definition: globals.c:184
Definition: cookie.c:202
WCHAR * name
Definition: cookie.c:203
char * name
Definition: compiler.c:66
Definition: name.c:39
WCHAR * name
Definition: name.c:42
Definition: mxnamespace.c:38
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:410
xmlChar * xsltEvalTemplateString(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst)
Definition: templates.c:207
Character const *const prefix
Definition: tempnam.cpp:195
Definition: pdh_main.c:96
XMLPUBFUN xmlIDPtr xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr)
Definition: valid.c:2517
XMLPUBFUN int xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
Definition: valid.c:2619
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69
#define XSLT_NAMESPACE
Definition: xslt.h:46
const xmlChar * xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
Definition: xsltutils.c:804

Referenced by xsltApplyAttributeSet(), xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltCallTemplate()

XSLTPUBFUN void XSLTCALL xsltCallTemplate ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltCallTemplate: @ctxt: a XSLT transformation context @node: the "current node" in the source tree @inst: the XSLT 'call-template' instruction @castedComp: the compiled information of the instruction

Processes the XSLT call-template instruction on the source node.

Definition at line 4719 of file transform.c.

4721{
4722#ifdef XSLT_REFACTORED
4723 xsltStyleItemCallTemplatePtr comp =
4724 (xsltStyleItemCallTemplatePtr) castedComp;
4725#else
4726 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4727#endif
4728 xsltStackElemPtr withParams = NULL;
4729
4730 if (ctxt->insert == NULL)
4731 return;
4732 if (comp == NULL) {
4733 xsltTransformError(ctxt, NULL, inst,
4734 "The XSLT 'call-template' instruction was not compiled.\n");
4735 return;
4736 }
4737
4738 /*
4739 * The template must have been precomputed
4740 */
4741 if (comp->templ == NULL) {
4742 comp->templ = xsltFindTemplate(ctxt, comp->name, comp->ns);
4743 if (comp->templ == NULL) {
4744 if (comp->ns != NULL) {
4745 xsltTransformError(ctxt, NULL, inst,
4746 "The called template '{%s}%s' was not found.\n",
4747 comp->ns, comp->name);
4748 } else {
4749 xsltTransformError(ctxt, NULL, inst,
4750 "The called template '%s' was not found.\n",
4751 comp->name);
4752 }
4753 return;
4754 }
4755 }
4756
4757#ifdef WITH_XSLT_DEBUG_PROCESS
4758 if ((comp != NULL) && (comp->name != NULL))
4760 "call-template: name %s\n", comp->name));
4761#endif
4762
4763 if (inst->children) {
4764 xmlNodePtr cur;
4766
4767 cur = inst->children;
4768 while (cur != NULL) {
4769#ifdef WITH_DEBUGGER
4770 if (ctxt->debugStatus != XSLT_DEBUG_NONE)
4771 xslHandleDebugger(cur, node, comp->templ, ctxt);
4772#endif
4773 if (ctxt->state == XSLT_STATE_STOPPED) break;
4774 /*
4775 * TODO: The "with-param"s could be part of the "call-template"
4776 * structure. Avoid to "search" for params dynamically
4777 * in the XML tree every time.
4778 */
4779 if (IS_XSLT_ELEM(cur)) {
4780 if (IS_XSLT_NAME(cur, "with-param")) {
4782 if (param != NULL) {
4783 param->next = withParams;
4784 withParams = param;
4785 }
4786 } else {
4788 "xsl:call-template: misplaced xsl:%s\n", cur->name);
4789 }
4790 } else {
4792 "xsl:call-template: misplaced %s element\n", cur->name);
4793 }
4794 cur = cur->next;
4795 }
4796 }
4797 /*
4798 * Create a new frame using the params first
4799 */
4800 xsltApplyXSLTTemplate(ctxt, node, comp->templ->content, comp->templ,
4801 withParams);
4802 if (withParams != NULL)
4803 xsltFreeStackElemList(withParams);
4804
4805#ifdef WITH_XSLT_DEBUG_PROCESS
4806 if ((comp != NULL) && (comp->name != NULL))
4808 "call-template returned: name %s\n", comp->name));
4809#endif
4810}
xsltTemplatePtr xsltFindTemplate(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: imports.c:403
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:586
void * xsltGenericErrorContext
Definition: xsltutils.c:587
@ XSLT_TRACE_CALL_TEMPLATE
Definition: xsltutils.h:116

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltChoose()

XSLTPUBFUN void XSLTCALL xsltChoose ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  inst,
xsltElemPreCompPtr comp  ATTRIBUTE_UNUSED 
)

xsltChoose: @ctxt: a XSLT process context @contextNode: the current node in the source tree @inst: the xsl:choose instruction @comp: compiled information of the instruction

Processes the xsl:choose instruction on the source node.

Definition at line 5136 of file transform.c.

5138{
5139 xmlNodePtr cur;
5140
5141 if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
5142 return;
5143
5144 /*
5145 * TODO: Content model checks should be done only at compilation
5146 * time.
5147 */
5148 cur = inst->children;
5149 if (cur == NULL) {
5150 xsltTransformError(ctxt, NULL, inst,
5151 "xsl:choose: The instruction has no content.\n");
5152 return;
5153 }
5154
5155#ifdef XSLT_REFACTORED
5156 /*
5157 * We don't check the content model during transformation.
5158 */
5159#else
5160 if ((! IS_XSLT_ELEM(cur)) || (! IS_XSLT_NAME(cur, "when"))) {
5161 xsltTransformError(ctxt, NULL, inst,
5162 "xsl:choose: xsl:when expected first\n");
5163 return;
5164 }
5165#endif
5166
5167 {
5168 int testRes = 0, res = 0;
5169
5170#ifdef XSLT_REFACTORED
5171 xsltStyleItemWhenPtr wcomp = NULL;
5172#else
5173 xsltStylePreCompPtr wcomp = NULL;
5174#endif
5175
5176 /*
5177 * Process xsl:when ---------------------------------------------------
5178 */
5179 while (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "when")) {
5180 wcomp = cur->psvi;
5181
5182 if ((wcomp == NULL) || (wcomp->test == NULL) ||
5183 (wcomp->comp == NULL))
5184 {
5186 "Internal error in xsltChoose(): "
5187 "The XSLT 'when' instruction was not compiled.\n");
5188 goto error;
5189 }
5190
5191
5192#ifdef WITH_DEBUGGER
5194 /*
5195 * TODO: Isn't comp->templ always NULL for xsl:choose?
5196 */
5197 xslHandleDebugger(cur, contextNode, NULL, ctxt);
5198 }
5199#endif
5200#ifdef WITH_XSLT_DEBUG_PROCESS
5202 "xsltChoose: test %s\n", wcomp->test));
5203#endif
5204
5205#ifdef XSLT_FAST_IF
5206 res = xsltPreCompEvalToBoolean(ctxt, contextNode, wcomp);
5207
5208 if (res == -1) {
5209 ctxt->state = XSLT_STATE_STOPPED;
5210 goto error;
5211 }
5212 testRes = (res == 1) ? 1 : 0;
5213
5214#else /* XSLT_FAST_IF */
5215
5216 res = xsltPreCompEval(ctxt, cotextNode, wcomp);
5217
5218 if (res != NULL) {
5219 if (res->type != XPATH_BOOLEAN)
5220 res = xmlXPathConvertBoolean(res);
5221 if (res->type == XPATH_BOOLEAN)
5222 testRes = res->boolval;
5223 else {
5224#ifdef WITH_XSLT_DEBUG_PROCESS
5226 "xsltChoose: test didn't evaluate to a boolean\n"));
5227#endif
5228 goto error;
5229 }
5230 xmlXPathFreeObject(res);
5231 res = NULL;
5232 } else {
5233 ctxt->state = XSLT_STATE_STOPPED;
5234 goto error;
5235 }
5236
5237#endif /* else of XSLT_FAST_IF */
5238
5239#ifdef WITH_XSLT_DEBUG_PROCESS
5241 "xsltChoose: test evaluate to %d\n", testRes));
5242#endif
5243 if (testRes)
5244 goto test_is_true;
5245
5246 cur = cur->next;
5247 }
5248
5249 /*
5250 * Process xsl:otherwise ----------------------------------------------
5251 */
5252 if (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "otherwise")) {
5253
5254#ifdef WITH_DEBUGGER
5256 xslHandleDebugger(cur, contextNode, NULL, ctxt);
5257#endif
5258
5259#ifdef WITH_XSLT_DEBUG_PROCESS
5261 "evaluating xsl:otherwise\n"));
5262#endif
5263 goto test_is_true;
5264 }
5265 goto exit;
5266
5267test_is_true:
5268
5269 goto process_sequence;
5270 }
5271
5272process_sequence:
5273
5274 /*
5275 * Instantiate the sequence constructor.
5276 */
5277 xsltApplySequenceConstructor(ctxt, ctxt->node, cur->children,
5278 NULL);
5279
5280exit:
5281error:
5282 return;
5283}
static int xsltPreCompEvalToBoolean(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:398
int xslDebugStatus
Definition: xsltutils.c:2603
@ XSLT_TRACE_CHOOSE
Definition: xsltutils.h:118

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltComment()

XSLTPUBFUN void XSLTCALL xsltComment ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr comp  ATTRIBUTE_UNUSED 
)

xsltComment: @ctxt: a XSLT process context @node: the node in the source tree. @inst: the xslt comment node @comp: precomputed information

Process the xslt comment node on the source node

Definition at line 4265 of file transform.c.

4266 {
4267 xmlChar *value = NULL;
4268 xmlNodePtr commentNode;
4269 int len;
4270
4271 value = xsltEvalTemplateString(ctxt, node, inst);
4272 /* TODO: use or generate the compiled form */
4273 len = xmlStrlen(value);
4274 if (len > 0) {
4275 if ((value[len-1] == '-') ||
4276 (xmlStrstr(value, BAD_CAST "--"))) {
4277 xsltTransformError(ctxt, NULL, inst,
4278 "xsl:comment : '--' or ending '-' not allowed in comment\n");
4279 /* fall through to try to catch further errors */
4280 }
4281 }
4282#ifdef WITH_XSLT_DEBUG_PROCESS
4283 if (value == NULL) {
4285 "xsltComment: empty\n"));
4286 } else {
4288 "xsltComment: content %s\n", value));
4289 }
4290#endif
4291
4292 commentNode = xmlNewComment(value);
4293 commentNode = xsltAddChild(ctxt->insert, commentNode);
4294
4295 if (value != NULL)
4296 xmlFree(value);
4297}
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:783
GLenum GLsizei len
Definition: glext.h:6722
XMLPUBFUN int xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:428
XMLPUBFUN const xmlChar * xmlStrstr(const xmlChar *str, const xmlChar *val)
Definition: xmlstring.c:347
@ XSLT_TRACE_COMMENT
Definition: xsltutils.h:112

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltCopy()

XSLTPUBFUN void XSLTCALL xsltCopy ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltCopy: @ctxt: an XSLT process context @node: the node in the source tree @inst: the element node of the XSLT-copy instruction @castedComp: computed information of the XSLT-copy instruction

Execute the XSLT-copy instruction on the source node.

Definition at line 3901 of file transform.c.

3903{
3904#ifdef XSLT_REFACTORED
3905 xsltStyleItemCopyPtr comp = (xsltStyleItemCopyPtr) castedComp;
3906#else
3907 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
3908#endif
3909 xmlNodePtr copy, oldInsert;
3910
3911 oldInsert = ctxt->insert;
3912 if (ctxt->insert != NULL) {
3913 switch (node->type) {
3914 case XML_TEXT_NODE:
3915 case XML_CDATA_SECTION_NODE:
3916 /*
3917 * This text comes from the stylesheet
3918 * For stylesheets, the set of whitespace-preserving
3919 * element names consists of just xsl:text.
3920 */
3921#ifdef WITH_XSLT_DEBUG_PROCESS
3922 if (node->type == XML_CDATA_SECTION_NODE) {
3924 "xsltCopy: CDATA text %s\n", node->content));
3925 } else {
3927 "xsltCopy: text %s\n", node->content));
3928 }
3929#endif
3930 xsltCopyText(ctxt, ctxt->insert, node, 0);
3931 break;
3932 case XML_DOCUMENT_NODE:
3933 case XML_HTML_DOCUMENT_NODE:
3934 break;
3935 case XML_ELEMENT_NODE:
3936 /*
3937 * REVISIT NOTE: The "fake" is a doc-node, not an element node.
3938 * REMOVED:
3939 * if (xmlStrEqual(node->name, BAD_CAST " fake node libxslt"))
3940 * return;
3941 */
3942
3943#ifdef WITH_XSLT_DEBUG_PROCESS
3945 "xsltCopy: node %s\n", node->name));
3946#endif
3947 copy = xsltShallowCopyElem(ctxt, node, ctxt->insert, 0);
3948 ctxt->insert = copy;
3949 if (comp->use != NULL) {
3950 xsltApplyAttributeSet(ctxt, node, inst, comp->use);
3951 }
3952 break;
3953 case XML_ATTRIBUTE_NODE: {
3954#ifdef WITH_XSLT_DEBUG_PROCESS
3956 "xsltCopy: attribute %s\n", node->name));
3957#endif
3958 /*
3959 * REVISIT: We could also raise an error if the parent is not
3960 * an element node.
3961 * OPTIMIZE TODO: Can we set the value/children of the
3962 * attribute without an intermediate copy of the string value?
3963 */
3964 xsltShallowCopyAttr(ctxt, inst, ctxt->insert, (xmlAttrPtr) node);
3965 break;
3966 }
3967 case XML_PI_NODE:
3968#ifdef WITH_XSLT_DEBUG_PROCESS
3970 "xsltCopy: PI %s\n", node->name));
3971#endif
3972 copy = xmlNewDocPI(ctxt->insert->doc, node->name,
3973 node->content);
3974 copy = xsltAddChild(ctxt->insert, copy);
3975 break;
3976 case XML_COMMENT_NODE:
3977#ifdef WITH_XSLT_DEBUG_PROCESS
3979 "xsltCopy: comment\n"));
3980#endif
3981 copy = xmlNewComment(node->content);
3982 copy = xsltAddChild(ctxt->insert, copy);
3983 break;
3984 case XML_NAMESPACE_DECL:
3985#ifdef WITH_XSLT_DEBUG_PROCESS
3987 "xsltCopy: namespace declaration\n"));
3988#endif
3989 xsltShallowCopyNsNode(ctxt, inst, ctxt->insert, (xmlNsPtr)node);
3990 break;
3991 default:
3992 break;
3993
3994 }
3995 }
3996
3997 switch (node->type) {
3998 case XML_DOCUMENT_NODE:
3999 case XML_HTML_DOCUMENT_NODE:
4000 case XML_ELEMENT_NODE:
4001 xsltApplySequenceConstructor(ctxt, ctxt->node, inst->children,
4002 NULL);
4003 break;
4004 default:
4005 break;
4006 }
4007 ctxt->insert = oldInsert;
4008}
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
void xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, const xmlChar *attrSets)
Definition: attributes.c:1118
static xmlAttrPtr xsltShallowCopyAttr(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr target, xmlAttrPtr attr)
Definition: transform.c:1155
static xmlNsPtr xsltShallowCopyNsNode(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr insert, xmlNsPtr ns)
Definition: transform.c:1515
static xmlNodePtr xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target, xmlNodePtr cur, int interned)
Definition: transform.c:977
static xmlNodePtr xsltShallowCopyElem(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr insert, int isLRE)
Definition: transform.c:1330
@ XSLT_TRACE_COPY
Definition: xsltutils.h:111

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltCopyOf()

XSLTPUBFUN void XSLTCALL xsltCopyOf ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltCopyOf: @ctxt: an XSLT transformation context @node: the current node in the source tree @inst: the element node of the XSLT copy-of instruction @castedComp: precomputed information of the XSLT copy-of instruction

Process the XSLT copy-of instruction.

Definition at line 4375 of file transform.c.

4376 {
4377#ifdef XSLT_REFACTORED
4378 xsltStyleItemCopyOfPtr comp = (xsltStyleItemCopyOfPtr) castedComp;
4379#else
4380 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4381#endif
4382 xmlXPathObjectPtr res = NULL;
4383 xmlNodeSetPtr list = NULL;
4384 int i;
4385
4386 if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
4387 return;
4388 if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
4389 xsltTransformError(ctxt, NULL, inst,
4390 "xsl:copy-of : compilation failed\n");
4391 return;
4392 }
4393
4394 /*
4395 * SPEC XSLT 1.0:
4396 * "The xsl:copy-of element can be used to insert a result tree
4397 * fragment into the result tree, without first converting it to
4398 * a string as xsl:value-of does (see [7.6.1 Generating Text with
4399 * xsl:value-of]). The required select attribute contains an
4400 * expression. When the result of evaluating the expression is a
4401 * result tree fragment, the complete fragment is copied into the
4402 * result tree. When the result is a node-set, all the nodes in the
4403 * set are copied in document order into the result tree; copying
4404 * an element node copies the attribute nodes, namespace nodes and
4405 * children of the element node as well as the element node itself;
4406 * a root node is copied by copying its children. When the result
4407 * is neither a node-set nor a result tree fragment, the result is
4408 * converted to a string and then inserted into the result tree,
4409 * as with xsl:value-of.
4410 */
4411
4412#ifdef WITH_XSLT_DEBUG_PROCESS
4414 "xsltCopyOf: select %s\n", comp->select));
4415#endif
4416
4417 /*
4418 * Evaluate the "select" expression.
4419 */
4420 res = xsltPreCompEval(ctxt, node, comp);
4421
4422 if (res != NULL) {
4423 if (res->type == XPATH_NODESET) {
4424 /*
4425 * Node-set
4426 * --------
4427 */
4428#ifdef WITH_XSLT_DEBUG_PROCESS
4430 "xsltCopyOf: result is a node set\n"));
4431#endif
4432 list = res->nodesetval;
4433 if (list != NULL) {
4434 xmlNodePtr cur;
4435 /*
4436 * The list is already sorted in document order by XPath.
4437 * Append everything in this order under ctxt->insert.
4438 */
4439 for (i = 0;i < list->nodeNr;i++) {
4440 cur = list->nodeTab[i];
4441 if (cur == NULL)
4442 continue;
4443 if ((cur->type == XML_DOCUMENT_NODE) ||
4444 (cur->type == XML_HTML_DOCUMENT_NODE))
4445 {
4446 xsltCopyTreeList(ctxt, inst,
4447 cur->children, ctxt->insert, 0, 0);
4448 } else if (cur->type == XML_ATTRIBUTE_NODE) {
4449 xsltShallowCopyAttr(ctxt, inst,
4450 ctxt->insert, (xmlAttrPtr) cur);
4451 } else {
4452 xsltCopyTree(ctxt, inst, cur, ctxt->insert, 0, 0);
4453 }
4454 }
4455 }
4456 } else if (res->type == XPATH_XSLT_TREE) {
4457 /*
4458 * Result tree fragment
4459 * --------------------
4460 * E.g. via <xsl:variable ...><foo/></xsl:variable>
4461 * Note that the root node of such trees is an xmlDocPtr in Libxslt.
4462 */
4463#ifdef WITH_XSLT_DEBUG_PROCESS
4465 "xsltCopyOf: result is a result tree fragment\n"));
4466#endif
4467 list = res->nodesetval;
4468 if ((list != NULL) && (list->nodeTab != NULL) &&
4469 (list->nodeTab[0] != NULL) &&
4470 (IS_XSLT_REAL_NODE(list->nodeTab[0])))
4471 {
4472 xsltCopyTreeList(ctxt, inst,
4473 list->nodeTab[0]->children, ctxt->insert, 0, 0);
4474 }
4475 } else {
4476 xmlChar *value = NULL;
4477 /*
4478 * Convert to a string.
4479 */
4480 value = xmlXPathCastToString(res);
4481 if (value == NULL) {
4482 xsltTransformError(ctxt, NULL, inst,
4483 "Internal error in xsltCopyOf(): "
4484 "failed to cast an XPath object to string.\n");
4485 ctxt->state = XSLT_STATE_STOPPED;
4486 } else {
4487 if (value[0] != 0) {
4488 /*
4489 * Append content as text node.
4490 */
4491 xsltCopyTextString(ctxt, ctxt->insert, value, 0);
4492 }
4493 xmlFree(value);
4494
4495#ifdef WITH_XSLT_DEBUG_PROCESS
4497 "xsltCopyOf: result %s\n", res->stringval));
4498#endif
4499 }
4500 }
4501 } else {
4502 ctxt->state = XSLT_STATE_STOPPED;
4503 }
4504
4505 if (res != NULL)
4506 xmlXPathFreeObject(res);
4507}
xmlNodePtr xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int noescape)
Definition: transform.c:881
static xmlNodePtr xsltCopyTreeList(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr list, xmlNodePtr insert, int isLRE, int topElemVisited)
Definition: transform.c:1422
static xmlNodePtr xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr node, xmlNodePtr insert, int isLRE, int topElemVisited)
Definition: transform.c:1626
@ XSLT_TRACE_COPY_OF
Definition: xsltutils.h:114

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltCopyTextString()

XSLTPUBFUN xmlNodePtr XSLTCALL xsltCopyTextString ( xsltTransformContextPtr  ctxt,
xmlNodePtr  target,
const xmlChar string,
int  noescape 
)

xsltCopyTextString: @ctxt: a XSLT process context @target: the element where the text will be attached @string: the text string @noescape: should disable-escaping be activated for this text node.

Adds @string to a newly created or an existent text node child of @target.

Returns: the text node, where the text content of @cur is copied to. NULL in case of API or internal errors.

Definition at line 881 of file transform.c.

883{
884 xmlNodePtr copy;
885 int len;
886
887 if (string == NULL)
888 return(NULL);
889
890#ifdef WITH_XSLT_DEBUG_PROCESS
892 "xsltCopyTextString: copy text %s\n",
893 string));
894#endif
895
896 /*
897 * Play safe and reset the merging mechanism for every new
898 * target node.
899 */
900 if ((target == NULL) || (target->children == NULL)) {
901 ctxt->lasttext = NULL;
902 }
903
904 /* handle coalescing of text nodes here */
905 len = xmlStrlen(string);
906 if ((ctxt->type == XSLT_OUTPUT_XML) &&
907 (ctxt->style->cdataSection != NULL) &&
908 (target != NULL) &&
909 (target->type == XML_ELEMENT_NODE) &&
910 (((target->ns == NULL) &&
912 target->name, NULL) != NULL)) ||
913 ((target->ns != NULL) &&
915 target->name, target->ns->href) != NULL))))
916 {
917 /*
918 * Process "cdata-section-elements".
919 */
920 if ((target->last != NULL) &&
921 (target->last->type == XML_CDATA_SECTION_NODE))
922 {
923 return(xsltAddTextString(ctxt, target->last, string, len));
924 }
925 copy = xmlNewCDataBlock(ctxt->output, string, len);
926 } else if (noescape) {
927 /*
928 * Process "disable-output-escaping".
929 */
930 if ((target != NULL) && (target->last != NULL) &&
931 (target->last->type == XML_TEXT_NODE) &&
932 (target->last->name == xmlStringTextNoenc))
933 {
934 return(xsltAddTextString(ctxt, target->last, string, len));
935 }
936 copy = xmlNewTextLen(string, len);
937 if (copy != NULL)
938 copy->name = xmlStringTextNoenc;
939 } else {
940 /*
941 * Default processing.
942 */
943 if ((target != NULL) && (target->last != NULL) &&
944 (target->last->type == XML_TEXT_NODE) &&
945 (target->last->name == xmlStringText)) {
946 return(xsltAddTextString(ctxt, target->last, string, len));
947 }
948 copy = xmlNewTextLen(string, len);
949 }
950 if (copy != NULL && target != NULL)
952 if (copy != NULL) {
953 ctxt->lasttext = copy->content;
954 ctxt->lasttsize = len;
955 ctxt->lasttuse = len;
956 } else {
958 "xsltCopyTextString: text copy failed\n");
959 ctxt->lasttext = NULL;
960 }
961 return(copy);
962}
static xmlNodePtr xsltAddTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int len)
Definition: transform.c:809
XMLPUBVAR const xmlChar xmlStringText[]
void * xmlHashLookup2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2)
Definition: hash.c:754
xmlHashTablePtr cdataSection
xsltStylesheetPtr style
const xmlChar * lasttext
Definition: tools.h:99
@ XSLT_OUTPUT_XML
@ XSLT_TRACE_COPY_TEXT
Definition: xsltutils.h:108

Referenced by xsltCopyOf(), xsltCopyTree(), xsltNumberFormat(), and xsltValueOf().

◆ xsltDocumentElem()

XSLTPUBFUN void XSLTCALL xsltDocumentElem ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltDocumentElem: @ctxt: an XSLT processing context @node: The current node @inst: the instruction in the stylesheet @castedComp: precomputed information

Process an EXSLT/XSLT-1.1 document element

Definition at line 3363 of file transform.c.

3365{
3366#ifdef XSLT_REFACTORED
3367 xsltStyleItemDocumentPtr comp = (xsltStyleItemDocumentPtr) castedComp;
3368#else
3369 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
3370#endif
3372 int ret;
3373 xmlChar *filename = NULL, *prop, *elements;
3374 xmlChar *element, *end;
3375 xmlDocPtr res = NULL;
3376 xmlDocPtr oldOutput;
3377 xmlNodePtr oldInsert, root;
3378 const char *oldOutputFile;
3379 xsltOutputType oldType;
3380 xmlChar *URL = NULL;
3381 const xmlChar *method;
3382 const xmlChar *doctypePublic;
3383 const xmlChar *doctypeSystem;
3384 const xmlChar *version;
3385 const xmlChar *encoding;
3386 int redirect_write_append = 0;
3387
3388 if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
3389 return;
3390
3391 if (comp->filename == NULL) {
3392
3393 if (xmlStrEqual(inst->name, (const xmlChar *) "output")) {
3394 /*
3395 * The element "output" is in the namespace XSLT_SAXON_NAMESPACE
3396 * (http://icl.com/saxon)
3397 * The @file is in no namespace.
3398 */
3399#ifdef WITH_XSLT_DEBUG_EXTRA
3401 "Found saxon:output extension\n");
3402#endif
3403 URL = xsltEvalAttrValueTemplate(ctxt, inst,
3404 (const xmlChar *) "file",
3406
3407 if (URL == NULL)
3408 URL = xsltEvalAttrValueTemplate(ctxt, inst,
3409 (const xmlChar *) "href",
3411 } else if (xmlStrEqual(inst->name, (const xmlChar *) "write")) {
3412#ifdef WITH_XSLT_DEBUG_EXTRA
3414 "Found xalan:write extension\n");
3415#endif
3416 URL = xsltEvalAttrValueTemplate(ctxt, inst,
3417 (const xmlChar *)
3418 "select",
3420 if (URL != NULL) {
3421 xmlXPathCompExprPtr cmp;
3422 xmlChar *val;
3423
3424 /*
3425 * Trying to handle bug #59212
3426 * The value of the "select" attribute is an
3427 * XPath expression.
3428 * (see http://xml.apache.org/xalan-j/extensionslib.html#redirect)
3429 */
3430 cmp = xmlXPathCtxtCompile(ctxt->xpathCtxt, URL);
3431 val = xsltEvalXPathString(ctxt, cmp);
3432 xmlXPathFreeCompExpr(cmp);
3433 xmlFree(URL);
3434 URL = val;
3435 }
3436 if (URL == NULL)
3437 URL = xsltEvalAttrValueTemplate(ctxt, inst,
3438 (const xmlChar *)
3439 "file",
3441 if (URL == NULL)
3442 URL = xsltEvalAttrValueTemplate(ctxt, inst,
3443 (const xmlChar *)
3444 "href",
3446 } else if (xmlStrEqual(inst->name, (const xmlChar *) "document")) {
3447 URL = xsltEvalAttrValueTemplate(ctxt, inst,
3448 (const xmlChar *) "href",
3449 NULL);
3450 }
3451
3452 } else {
3453 URL = xmlStrdup(comp->filename);
3454 }
3455
3456 if (URL == NULL) {
3457 xsltTransformError(ctxt, NULL, inst,
3458 "xsltDocumentElem: href/URI-Reference not found\n");
3459 return;
3460 }
3461
3462 /*
3463 * If the computation failed, it's likely that the URL wasn't escaped
3464 */
3465 filename = xmlBuildURI(URL, (const xmlChar *) ctxt->outputFile);
3466 if (filename == NULL) {
3467 xmlChar *escURL;
3468
3469 escURL=xmlURIEscapeStr(URL, BAD_CAST ":/.?,");
3470 if (escURL != NULL) {
3471 filename = xmlBuildURI(escURL, (const xmlChar *) ctxt->outputFile);
3472 xmlFree(escURL);
3473 }
3474 }
3475
3476 if (filename == NULL) {
3477 xsltTransformError(ctxt, NULL, inst,
3478 "xsltDocumentElem: URL computation failed for %s\n",
3479 URL);
3480 xmlFree(URL);
3481 return;
3482 }
3483
3484 /*
3485 * Security checking: can we write to this resource
3486 */
3487 if (ctxt->sec != NULL) {
3488 ret = xsltCheckWrite(ctxt->sec, ctxt, filename);
3489 if (ret <= 0) {
3490 if (ret == 0)
3491 xsltTransformError(ctxt, NULL, inst,
3492 "xsltDocumentElem: write rights for %s denied\n",
3493 filename);
3494 xmlFree(URL);
3496 return;
3497 }
3498 }
3499
3500 oldOutputFile = ctxt->outputFile;
3501 oldOutput = ctxt->output;
3502 oldInsert = ctxt->insert;
3503 oldType = ctxt->type;
3504 ctxt->outputFile = (const char *) filename;
3505
3507 if (style == NULL) {
3508 xsltTransformError(ctxt, NULL, inst,
3509 "xsltDocumentElem: out of memory\n");
3510 goto error;
3511 }
3512
3513 /*
3514 * Version described in 1.1 draft allows full parameterization
3515 * of the output.
3516 */
3517 prop = xsltEvalAttrValueTemplate(ctxt, inst,
3518 (const xmlChar *) "version",
3519 NULL);
3520 if (prop != NULL) {
3521 if (style->version != NULL)
3522 xmlFree(style->version);
3523 style->version = prop;
3524 }
3525 prop = xsltEvalAttrValueTemplate(ctxt, inst,
3526 (const xmlChar *) "encoding",
3527 NULL);
3528 if (prop != NULL) {
3529 if (style->encoding != NULL)
3530 xmlFree(style->encoding);
3531 style->encoding = prop;
3532 }
3533 prop = xsltEvalAttrValueTemplate(ctxt, inst,
3534 (const xmlChar *) "method",
3535 NULL);
3536 if (prop != NULL) {
3537 const xmlChar *URI;
3538
3539 if (style->method != NULL)
3540 xmlFree(style->method);
3541 style->method = NULL;
3542 if (style->methodURI != NULL)
3543 xmlFree(style->methodURI);
3544 style->methodURI = NULL;
3545
3546 URI = xsltGetQNameURI(inst, &prop);
3547 if (prop == NULL) {
3548 if (style != NULL) style->errors++;
3549 } else if (URI == NULL) {
3550 if ((xmlStrEqual(prop, (const xmlChar *) "xml")) ||
3551 (xmlStrEqual(prop, (const xmlChar *) "html")) ||
3552 (xmlStrEqual(prop, (const xmlChar *) "text"))) {
3553 style->method = prop;
3554 } else {
3555 xsltTransformError(ctxt, NULL, inst,
3556 "invalid value for method: %s\n", prop);
3557 if (style != NULL) style->warnings++;
3558 }
3559 } else {
3560 style->method = prop;
3561 style->methodURI = xmlStrdup(URI);
3562 }
3563 }
3564 prop = xsltEvalAttrValueTemplate(ctxt, inst,
3565 (const xmlChar *)
3566 "doctype-system", NULL);
3567 if (prop != NULL) {
3568 if (style->doctypeSystem != NULL)
3569 xmlFree(style->doctypeSystem);
3570 style->doctypeSystem = prop;
3571 }
3572 prop = xsltEvalAttrValueTemplate(ctxt, inst,
3573 (const xmlChar *)
3574 "doctype-public", NULL);
3575 if (prop != NULL) {
3576 if (style->doctypePublic != NULL)
3577 xmlFree(style->doctypePublic);
3578 style->doctypePublic = prop;
3579 }
3580 prop = xsltEvalAttrValueTemplate(ctxt, inst,
3581 (const xmlChar *) "standalone",
3582 NULL);
3583 if (prop != NULL) {
3584 if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
3585 style->standalone = 1;
3586 } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
3587 style->standalone = 0;
3588 } else {
3589 xsltTransformError(ctxt, NULL, inst,
3590 "invalid value for standalone: %s\n",
3591 prop);
3592 if (style != NULL) style->warnings++;
3593 }
3594 xmlFree(prop);
3595 }
3596
3597 prop = xsltEvalAttrValueTemplate(ctxt, inst,
3598 (const xmlChar *) "indent",
3599 NULL);
3600 if (prop != NULL) {
3601 if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
3602 style->indent = 1;
3603 } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
3604 style->indent = 0;
3605 } else {
3606 xsltTransformError(ctxt, NULL, inst,
3607 "invalid value for indent: %s\n", prop);
3608 if (style != NULL) style->warnings++;
3609 }
3610 xmlFree(prop);
3611 }
3612
3613 prop = xsltEvalAttrValueTemplate(ctxt, inst,
3614 (const xmlChar *)
3615 "omit-xml-declaration",
3616 NULL);
3617 if (prop != NULL) {
3618 if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
3619 style->omitXmlDeclaration = 1;
3620 } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
3621 style->omitXmlDeclaration = 0;
3622 } else {
3623 xsltTransformError(ctxt, NULL, inst,
3624 "invalid value for omit-xml-declaration: %s\n",
3625 prop);
3626 if (style != NULL) style->warnings++;
3627 }
3628 xmlFree(prop);
3629 }
3630
3631 elements = xsltEvalAttrValueTemplate(ctxt, inst,
3632 (const xmlChar *)
3633 "cdata-section-elements",
3634 NULL);
3635 if (elements != NULL) {
3636 if (style->stripSpaces == NULL)
3637 style->stripSpaces = xmlHashCreate(10);
3638 if (style->stripSpaces == NULL) {
3639 xmlFree(elements);
3640 return;
3641 }
3642
3643 element = elements;
3644 while (*element != 0) {
3645 while (xmlIsBlank_ch(*element))
3646 element++;
3647 if (*element == 0)
3648 break;
3649 end = element;
3650 while ((*end != 0) && (!xmlIsBlank_ch(*end)))
3651 end++;
3653 if (element) {
3654 const xmlChar *URI;
3655
3656#ifdef WITH_XSLT_DEBUG_PARSING
3658 "add cdata section output element %s\n",
3659 element);
3660#endif
3661 URI = xsltGetQNameURI(inst, &element);
3662
3663 xmlHashAddEntry2(style->stripSpaces, element, URI,
3664 (xmlChar *) "cdata");
3666 }
3667 element = end;
3668 }
3669 xmlFree(elements);
3670 }
3671
3672 /*
3673 * Create a new document tree and process the element template
3674 */
3676 XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
3677 XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
3679 XSLT_GET_IMPORT_PTR(encoding, style, encoding)
3680
3681 if ((method != NULL) &&
3682 (!xmlStrEqual(method, (const xmlChar *) "xml"))) {
3683 if (xmlStrEqual(method, (const xmlChar *) "html")) {
3684 ctxt->type = XSLT_OUTPUT_HTML;
3685 if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
3686 res = htmlNewDoc(doctypeSystem, doctypePublic);
3687 else {
3688 if (version != NULL) {
3689#ifdef XSLT_GENERATE_HTML_DOCTYPE
3690 xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem);
3691#endif
3692 }
3693 res = htmlNewDocNoDtD(doctypeSystem, doctypePublic);
3694 }
3695 if (res == NULL)
3696 goto error;
3697 res->dict = ctxt->dict;
3698 xmlDictReference(res->dict);
3699 } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
3700 xsltTransformError(ctxt, NULL, inst,
3701 "xsltDocumentElem: unsupported method xhtml\n");
3702 ctxt->type = XSLT_OUTPUT_HTML;
3703 res = htmlNewDocNoDtD(doctypeSystem, doctypePublic);
3704 if (res == NULL)
3705 goto error;
3706 res->dict = ctxt->dict;
3707 xmlDictReference(res->dict);
3708 } else if (xmlStrEqual(method, (const xmlChar *) "text")) {
3709 ctxt->type = XSLT_OUTPUT_TEXT;
3710 res = xmlNewDoc(style->version);
3711 if (res == NULL)
3712 goto error;
3713 res->dict = ctxt->dict;
3714 xmlDictReference(res->dict);
3715#ifdef WITH_XSLT_DEBUG
3717 "reusing transformation dict for output\n");
3718#endif
3719 } else {
3720 xsltTransformError(ctxt, NULL, inst,
3721 "xsltDocumentElem: unsupported method (%s)\n",
3722 method);
3723 goto error;
3724 }
3725 } else {
3726 ctxt->type = XSLT_OUTPUT_XML;
3727 res = xmlNewDoc(style->version);
3728 if (res == NULL)
3729 goto error;
3730 res->dict = ctxt->dict;
3731 xmlDictReference(res->dict);
3732#ifdef WITH_XSLT_DEBUG
3734 "reusing transformation dict for output\n");
3735#endif
3736 }
3737 res->charset = XML_CHAR_ENCODING_UTF8;
3738 if (encoding != NULL)
3739 res->encoding = xmlStrdup(encoding);
3740 ctxt->output = res;
3741 ctxt->insert = (xmlNodePtr) res;
3742 xsltApplySequenceConstructor(ctxt, node, inst->children, NULL);
3743
3744 /*
3745 * Do some post processing work depending on the generated output
3746 */
3747 root = xmlDocGetRootElement(res);
3748 if (root != NULL) {
3749 const xmlChar *doctype = NULL;
3750
3751 if ((root->ns != NULL) && (root->ns->prefix != NULL))
3752 doctype = xmlDictQLookup(ctxt->dict, root->ns->prefix, root->name);
3753 if (doctype == NULL)
3754 doctype = root->name;
3755
3756 /*
3757 * Apply the default selection of the method
3758 */
3759 if ((method == NULL) &&
3760 (root->ns == NULL) &&
3761 (!xmlStrcasecmp(root->name, (const xmlChar *) "html"))) {
3762 xmlNodePtr tmp;
3763
3764 tmp = res->children;
3765 while ((tmp != NULL) && (tmp != root)) {
3766 if (tmp->type == XML_ELEMENT_NODE)
3767 break;
3768 if ((tmp->type == XML_TEXT_NODE) && (!xmlIsBlankNode(tmp)))
3769 break;
3770 tmp = tmp->next;
3771 }
3772 if (tmp == root) {
3773 ctxt->type = XSLT_OUTPUT_HTML;
3774 res->type = XML_HTML_DOCUMENT_NODE;
3775 if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
3776 res->intSubset = xmlCreateIntSubset(res, doctype,
3777 doctypePublic,
3778 doctypeSystem);
3779#ifdef XSLT_GENERATE_HTML_DOCTYPE
3780 } else if (version != NULL) {
3781 xsltGetHTMLIDs(version, &doctypePublic,
3782 &doctypeSystem);
3783 if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
3784 res->intSubset =
3785 xmlCreateIntSubset(res, doctype,
3786 doctypePublic,
3787 doctypeSystem);
3788#endif
3789 }
3790 }
3791
3792 }
3793 if (ctxt->type == XSLT_OUTPUT_XML) {
3794 XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
3795 XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
3796 if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
3797 res->intSubset = xmlCreateIntSubset(res, doctype,
3798 doctypePublic,
3799 doctypeSystem);
3800 }
3801 }
3802
3803 /*
3804 * Calls to redirect:write also take an optional attribute append.
3805 * Attribute append="true|yes" which will attempt to simply append
3806 * to an existing file instead of always opening a new file. The
3807 * default behavior of always overwriting the file still happens
3808 * if we do not specify append.
3809 * Note that append use will forbid use of remote URI target.
3810 */
3811 prop = xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *)"append",
3812 NULL);
3813 if (prop != NULL) {
3814 if (xmlStrEqual(prop, (const xmlChar *) "true") ||
3815 xmlStrEqual(prop, (const xmlChar *) "yes")) {
3816 style->omitXmlDeclaration = 1;
3817 redirect_write_append = 1;
3818 } else
3819 style->omitXmlDeclaration = 0;
3820 xmlFree(prop);
3821 }
3822
3823 if (redirect_write_append) {
3824 FILE *f;
3825
3826 f = fopen((const char *) filename, "ab");
3827 if (f == NULL) {
3828 ret = -1;
3829 } else {
3831 fclose(f);
3832 }
3833 } else {
3834 ret = xsltSaveResultToFilename((const char *) filename, res, style, 0);
3835 }
3836 if (ret < 0) {
3837 xsltTransformError(ctxt, NULL, inst,
3838 "xsltDocumentElem: unable to save to %s\n",
3839 filename);
3840#ifdef WITH_XSLT_DEBUG_EXTRA
3841 } else {
3843 "Wrote %d bytes to %s\n", ret, filename);
3844#endif
3845 }
3846
3847 error:
3848 ctxt->output = oldOutput;
3849 ctxt->insert = oldInsert;
3850 ctxt->type = oldType;
3851 ctxt->outputFile = oldOutputFile;
3852 if (URL != NULL)
3853 xmlFree(URL);
3854 if (filename != NULL)
3856 if (style != NULL)
3858 if (res != NULL)
3859 xmlFreeDoc(res);
3860}
struct _root root
#define xmlIsBlank_ch(c)
Definition: chvalid.h:88
int xsltCheckWrite(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:352
static int xsltGetHTMLIDs(const xmlChar *version, const xmlChar **publicID, const xmlChar **systemID)
Definition: transform.c:5621
static const WCHAR version[]
Definition: asmname.c:66
int CDECL fclose(FILE *file)
Definition: file.c:3757
FILE *CDECL fopen(const char *path, const char *mode)
Definition: file.c:4310
method
Definition: dragdrop.c:54
return ret
Definition: mutex.c:146
@ XML_CHAR_ENCODING_UTF8
Definition: encoding.h:68
#define XSLT_XALAN_NAMESPACE
Definition: extra.h:48
#define XSLT_SAXON_NAMESPACE
Definition: extra.h:34
GLuint GLuint end
Definition: gl.h:1545
GLfloat f
Definition: glext.h:7540
GLuint GLfloat * val
Definition: glext.h:7180
const char * filename
Definition: ioapi.h:137
#define f
Definition: ke_i.h:83
#define cmp(status, error)
Definition: error.c:114
#define XSLT_GET_IMPORT_PTR(res, style, name)
Definition: node.c:1070
int xmlDictReference(xmlDictPtr dict)
Definition: dict.c:317
const xmlChar * xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name)
Definition: dict.c:894
xmlHashTablePtr xmlHashCreate(int size)
Definition: hash.c:160
int xmlHashAddEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, void *payload)
Definition: hash.c:639
xmlChar * xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp)
Definition: templates.c:189
XMLPUBFUN xmlChar * xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1902
XMLPUBFUN xmlChar * xmlURIEscapeStr(const xmlChar *str, const xmlChar *list)
Definition: uri.c:1689
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:45
XMLPUBFUN int xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:277
xsltOutputType
@ XSLT_OUTPUT_HTML
@ XSLT_OUTPUT_TEXT
xsltStylesheetPtr xsltNewStylesheet(void)
Definition: xslt.c:810
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:965
const xmlChar * xsltGetQNameURI(xmlNodePtr node, xmlChar **name)
Definition: xsltutils.c:837
int xsltSaveResultToFilename(const char *URL, xmlDocPtr result, xsltStylesheetPtr style, int compression)
Definition: xsltutils.c:1740
int xsltSaveResultToFile(FILE *file, xmlDocPtr result, xsltStylesheetPtr style)
Definition: xsltutils.c:1783

Referenced by xsltNewStylePreComp(), xsltRegisterAllExtras(), and xsltStylePreCompute().

◆ xsltElement()

XSLTPUBFUN void XSLTCALL xsltElement ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltElement: @ctxt: a XSLT process context @node: the node in the source tree. @inst: the xslt element node @castedComp: precomputed information

Process the xslt element node on the source node

Definition at line 4057 of file transform.c.

4058 {
4059#ifdef XSLT_REFACTORED
4060 xsltStyleItemElementPtr comp = (xsltStyleItemElementPtr) castedComp;
4061#else
4062 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4063#endif
4064 xmlChar *prop = NULL;
4065 const xmlChar *name, *prefix = NULL, *nsName = NULL;
4066 xmlNodePtr copy;
4067 xmlNodePtr oldInsert;
4068
4069 if (ctxt->insert == NULL)
4070 return;
4071
4072 /*
4073 * A comp->has_name == 0 indicates that we need to skip this instruction,
4074 * since it was evaluated to be invalid already during compilation.
4075 */
4076 if (!comp->has_name)
4077 return;
4078
4079 /*
4080 * stack and saves
4081 */
4082 oldInsert = ctxt->insert;
4083
4084 if (comp->name == NULL) {
4085 /* TODO: fix attr acquisition wrt to the XSLT namespace */
4086 prop = xsltEvalAttrValueTemplate(ctxt, inst,
4087 (const xmlChar *) "name", XSLT_NAMESPACE);
4088 if (prop == NULL) {
4089 xsltTransformError(ctxt, NULL, inst,
4090 "xsl:element: The attribute 'name' is missing.\n");
4091 goto error;
4092 }
4093 if (xmlValidateQName(prop, 0)) {
4094 xsltTransformError(ctxt, NULL, inst,
4095 "xsl:element: The effective name '%s' is not a "
4096 "valid QName.\n", prop);
4097 /* we fall through to catch any further errors, if possible */
4098 }
4099 name = xsltSplitQName(ctxt->dict, prop, &prefix);
4100 xmlFree(prop);
4101 } else {
4102 /*
4103 * The "name" value was static.
4104 */
4105#ifdef XSLT_REFACTORED
4106 prefix = comp->nsPrefix;
4107 name = comp->name;
4108#else
4109 name = xsltSplitQName(ctxt->dict, comp->name, &prefix);
4110#endif
4111 }
4112
4113 /*
4114 * Create the new element
4115 */
4116 if (ctxt->output->dict == ctxt->dict) {
4117 copy = xmlNewDocNodeEatName(ctxt->output, NULL, (xmlChar *)name, NULL);
4118 } else {
4119 copy = xmlNewDocNode(ctxt->output, NULL, (xmlChar *)name, NULL);
4120 }
4121 if (copy == NULL) {
4122 xsltTransformError(ctxt, NULL, inst,
4123 "xsl:element : creation of %s failed\n", name);
4124 return;
4125 }
4126 copy = xsltAddChild(ctxt->insert, copy);
4127 if (copy == NULL) {
4128 xsltTransformError(ctxt, NULL, inst,
4129 "xsl:element : xsltAddChild failed\n");
4130 return;
4131 }
4132
4133 /*
4134 * Namespace
4135 * ---------
4136 */
4137 if (comp->has_ns) {
4138 if (comp->ns != NULL) {
4139 /*
4140 * No AVT; just plain text for the namespace name.
4141 */
4142 if (comp->ns[0] != 0)
4143 nsName = comp->ns;
4144 } else {
4145 xmlChar *tmpNsName;
4146 /*
4147 * Eval the AVT.
4148 */
4149 /* TODO: check attr acquisition wrt to the XSLT namespace */
4150 tmpNsName = xsltEvalAttrValueTemplate(ctxt, inst,
4151 (const xmlChar *) "namespace", XSLT_NAMESPACE);
4152 /*
4153 * SPEC XSLT 1.0:
4154 * "If the string is empty, then the expanded-name of the
4155 * attribute has a null namespace URI."
4156 */
4157 if ((tmpNsName != NULL) && (tmpNsName[0] != 0))
4158 nsName = xmlDictLookup(ctxt->dict, BAD_CAST tmpNsName, -1);
4159 xmlFree(tmpNsName);
4160 }
4161
4162 if (xmlStrEqual(nsName, BAD_CAST "http://www.w3.org/2000/xmlns/")) {
4163 xsltTransformError(ctxt, NULL, inst,
4164 "xsl:attribute: Namespace http://www.w3.org/2000/xmlns/ "
4165 "forbidden.\n");
4166 goto error;
4167 }
4168 if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
4169 prefix = BAD_CAST "xml";
4170 } else if (xmlStrEqual(prefix, BAD_CAST "xml")) {
4171 prefix = NULL;
4172 }
4173 } else {
4174 xmlNsPtr ns;
4175 /*
4176 * SPEC XSLT 1.0:
4177 * "If the namespace attribute is not present, then the QName is
4178 * expanded into an expanded-name using the namespace declarations
4179 * in effect for the xsl:element element, including any default
4180 * namespace declaration.
4181 */
4182 ns = xmlSearchNs(inst->doc, inst, prefix);
4183 if (ns == NULL) {
4184 /*
4185 * TODO: Check this in the compilation layer in case it's a
4186 * static value.
4187 */
4188 if (prefix != NULL) {
4189 xsltTransformError(ctxt, NULL, inst,
4190 "xsl:element: The QName '%s:%s' has no "
4191 "namespace binding in scope in the stylesheet; "
4192 "this is an error, since the namespace was not "
4193 "specified by the instruction itself.\n", prefix, name);
4194 }
4195 } else
4196 nsName = ns->href;
4197 }
4198 /*
4199 * Find/create a matching ns-decl in the result tree.
4200 */
4201 if (nsName != NULL) {
4202 if (xmlStrEqual(prefix, BAD_CAST "xmlns")) {
4203 /* Don't use a prefix of "xmlns" */
4204 xmlChar *pref = xmlStrdup(BAD_CAST "ns_1");
4205
4206 copy->ns = xsltGetSpecialNamespace(ctxt, inst, nsName, pref, copy);
4207
4208 xmlFree(pref);
4209 } else {
4210 copy->ns = xsltGetSpecialNamespace(ctxt, inst, nsName, prefix,
4211 copy);
4212 }
4213 } else if ((copy->parent != NULL) &&
4214 (copy->parent->type == XML_ELEMENT_NODE) &&
4215 (copy->parent->ns != NULL))
4216 {
4217 /*
4218 * "Undeclare" the default namespace.
4219 */
4220 xsltGetSpecialNamespace(ctxt, inst, NULL, NULL, copy);
4221 }
4222
4223 ctxt->insert = copy;
4224
4225 if (comp->has_use) {
4226 if (comp->use != NULL) {
4227 xsltApplyAttributeSet(ctxt, node, inst, comp->use);
4228 } else {
4229 xmlChar *attrSets = NULL;
4230 /*
4231 * BUG TODO: use-attribute-sets is not a value template.
4232 * use-attribute-sets = qnames
4233 */
4234 attrSets = xsltEvalAttrValueTemplate(ctxt, inst,
4235 (const xmlChar *)"use-attribute-sets", NULL);
4236 if (attrSets != NULL) {
4237 xsltApplyAttributeSet(ctxt, node, inst, attrSets);
4238 xmlFree(attrSets);
4239 }
4240 }
4241 }
4242 /*
4243 * Instantiate the sequence constructor.
4244 */
4245 if (inst->children != NULL)
4246 xsltApplySequenceConstructor(ctxt, ctxt->node, inst->children,
4247 NULL);
4248
4249error:
4250 ctxt->insert = oldInsert;
4251 return;
4252}

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltForEach()

XSLTPUBFUN void XSLTCALL xsltForEach ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltForEach: @ctxt: an XSLT transformation context @contextNode: the "current node" in the source tree @inst: the element node of the xsl:for-each instruction @castedComp: the compiled information of the instruction

Process the xslt for-each node on the source node

Definition at line 5401 of file transform.c.

5403{
5404#ifdef XSLT_REFACTORED
5405 xsltStyleItemForEachPtr comp = (xsltStyleItemForEachPtr) castedComp;
5406#else
5407 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
5408#endif
5409 int i;
5410 xmlXPathObjectPtr res = NULL;
5411 xmlNodePtr cur, curInst;
5412 xmlNodeSetPtr list = NULL;
5413 xmlNodeSetPtr oldList;
5414 int oldXPProximityPosition, oldXPContextSize;
5415 xmlNodePtr oldContextNode;
5416 xsltTemplatePtr oldCurTemplRule;
5417 xmlDocPtr oldXPDoc;
5418 xsltDocumentPtr oldDocInfo;
5419 xmlXPathContextPtr xpctxt;
5420
5421 if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL)) {
5423 "xsltForEach(): Bad arguments.\n");
5424 return;
5425 }
5426
5427 if (comp == NULL) {
5428 xsltTransformError(ctxt, NULL, inst,
5429 "Internal error in xsltForEach(): "
5430 "The XSLT 'for-each' instruction was not compiled.\n");
5431 return;
5432 }
5433 if ((comp->select == NULL) || (comp->comp == NULL)) {
5434 xsltTransformError(ctxt, NULL, inst,
5435 "Internal error in xsltForEach(): "
5436 "The selecting expression of the XSLT 'for-each' "
5437 "instruction was not compiled correctly.\n");
5438 return;
5439 }
5440 xpctxt = ctxt->xpathCtxt;
5441
5442#ifdef WITH_XSLT_DEBUG_PROCESS
5444 "xsltForEach: select %s\n", comp->select));
5445#endif
5446
5447 /*
5448 * Save context states.
5449 */
5450 oldDocInfo = ctxt->document;
5451 oldList = ctxt->nodeList;
5452 oldContextNode = ctxt->node;
5453 /*
5454 * The "current template rule" is cleared for the instantiation of
5455 * xsl:for-each.
5456 */
5457 oldCurTemplRule = ctxt->currentTemplateRule;
5458 ctxt->currentTemplateRule = NULL;
5459
5460 oldXPDoc = xpctxt->doc;
5461 oldXPProximityPosition = xpctxt->proximityPosition;
5462 oldXPContextSize = xpctxt->contextSize;
5463
5464 /*
5465 * Evaluate the 'select' expression.
5466 */
5467 res = xsltPreCompEval(ctxt, contextNode, comp);
5468
5469 if (res != NULL) {
5470 if (res->type == XPATH_NODESET)
5471 list = res->nodesetval;
5472 else {
5473 xsltTransformError(ctxt, NULL, inst,
5474 "The 'select' expression does not evaluate to a node set.\n");
5475
5476#ifdef WITH_XSLT_DEBUG_PROCESS
5478 "xsltForEach: select didn't evaluate to a node list\n"));
5479#endif
5480 goto error;
5481 }
5482 } else {
5483 xsltTransformError(ctxt, NULL, inst,
5484 "Failed to evaluate the 'select' expression.\n");
5485 ctxt->state = XSLT_STATE_STOPPED;
5486 goto error;
5487 }
5488
5489 if ((list == NULL) || (list->nodeNr <= 0))
5490 goto exit;
5491
5492#ifdef WITH_XSLT_DEBUG_PROCESS
5494 "xsltForEach: select evaluates to %d nodes\n", list->nodeNr));
5495#endif
5496
5497 /*
5498 * Set the list; this has to be done already here for xsltDoSortFunction().
5499 */
5500 ctxt->nodeList = list;
5501 /*
5502 * Handle xsl:sort instructions and skip them for further processing.
5503 * BUG TODO: We are not using namespaced potentially defined on the
5504 * xsl:sort element; XPath expression might fail.
5505 */
5506 curInst = inst->children;
5507 if (IS_XSLT_ELEM(curInst) && IS_XSLT_NAME(curInst, "sort")) {
5508 int nbsorts = 0;
5509 xmlNodePtr sorts[XSLT_MAX_SORT];
5510
5511 sorts[nbsorts++] = curInst;
5512
5513#ifdef WITH_DEBUGGER
5515 xslHandleDebugger(curInst, contextNode, NULL, ctxt);
5516#endif
5517
5518 curInst = curInst->next;
5519 while (IS_XSLT_ELEM(curInst) && IS_XSLT_NAME(curInst, "sort")) {
5520 if (nbsorts >= XSLT_MAX_SORT) {
5521 xsltTransformError(ctxt, NULL, curInst,
5522 "The number of xsl:sort instructions exceeds the "
5523 "maximum (%d) allowed by this processor.\n",
5525 goto error;
5526 } else {
5527 sorts[nbsorts++] = curInst;
5528 }
5529
5530#ifdef WITH_DEBUGGER
5532 xslHandleDebugger(curInst, contextNode, NULL, ctxt);
5533#endif
5534 curInst = curInst->next;
5535 }
5536 xsltDoSortFunction(ctxt, sorts, nbsorts);
5537 }
5538 xpctxt->contextSize = list->nodeNr;
5539 /*
5540 * Instantiate the sequence constructor for each selected node.
5541 */
5542 for (i = 0; i < list->nodeNr; i++) {
5543 cur = list->nodeTab[i];
5544 /*
5545 * The selected node becomes the "current node".
5546 */
5547 ctxt->node = cur;
5548 /*
5549 * An xsl:for-each can change the current context doc.
5550 * OPTIMIZE TODO: Get rid of the need to set the context doc.
5551 */
5552 if ((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL))
5553 xpctxt->doc = cur->doc;
5554
5555 xpctxt->proximityPosition = i + 1;
5556
5557 xsltApplySequenceConstructor(ctxt, cur, curInst, NULL);
5558 }
5559
5560exit:
5561error:
5562 if (res != NULL)
5563 xmlXPathFreeObject(res);
5564 /*
5565 * Restore old states.
5566 */
5567 ctxt->document = oldDocInfo;
5568 ctxt->nodeList = oldList;
5569 ctxt->node = oldContextNode;
5570 ctxt->currentTemplateRule = oldCurTemplRule;
5571
5572 xpctxt->doc = oldXPDoc;
5573 xpctxt->contextSize = oldXPContextSize;
5574 xpctxt->proximityPosition = oldXPProximityPosition;
5575}
@ XSLT_TRACE_FOR_EACH
Definition: xsltutils.h:120

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltFreeTransformContext()

XSLTPUBFUN void XSLTCALL xsltFreeTransformContext ( xsltTransformContextPtr  ctxt)

xsltFreeTransformContext: @ctxt: an XSLT transform context

Free up the memory allocated by @ctxt

Definition at line 721 of file transform.c.

721 {
722 if (ctxt == NULL)
723 return;
724
725 /*
726 * Shutdown the extension modules associated to the stylesheet
727 * used if needed.
728 */
730
731 if (ctxt->xpathCtxt != NULL) {
732 ctxt->xpathCtxt->nsHash = NULL;
733 xmlXPathFreeContext(ctxt->xpathCtxt);
734 }
735 if (ctxt->templTab != NULL)
736 xmlFree(ctxt->templTab);
737 if (ctxt->varsTab != NULL)
738 xmlFree(ctxt->varsTab);
739 if (ctxt->profTab != NULL)
740 xmlFree(ctxt->profTab);
741 if ((ctxt->extrasNr > 0) && (ctxt->extras != NULL)) {
742 int i;
743
744 for (i = 0;i < ctxt->extrasNr;i++) {
745 if ((ctxt->extras[i].deallocate != NULL) &&
746 (ctxt->extras[i].info != NULL))
747 ctxt->extras[i].deallocate(ctxt->extras[i].info);
748 }
749 xmlFree(ctxt->extras);
750 }
752 xsltFreeDocuments(ctxt);
753 xsltFreeCtxtExts(ctxt);
754 xsltFreeRVTs(ctxt);
756 xmlDictFree(ctxt->dict);
757#ifdef WITH_XSLT_DEBUG
759 "freeing transformation dictionary\n");
760#endif
761 memset(ctxt, -1, sizeof(xsltTransformContext));
762 xmlFree(ctxt);
763}
void xsltFreeCtxtExts(xsltTransformContextPtr ctxt)
Definition: extensions.c:664
void xsltShutdownCtxtExts(xsltTransformContextPtr ctxt)
Definition: extensions.c:1106
static void xsltTransformCacheFree(xsltTransformCachePtr cache)
Definition: transform.c:514
void xsltFreeDocuments(xsltTransformContextPtr ctxt)
Definition: documents.c:249
void xmlDictFree(xmlDictPtr dict)
Definition: dict.c:333
#define memset(x, y, z)
Definition: compat.h:39
xmlFreeFunc deallocate
xsltTemplatePtr * templTab
xsltTransformCachePtr cache
xsltRuntimeExtraPtr extras
xsltStackElemPtr * varsTab
void xsltFreeRVTs(xsltTransformContextPtr ctxt)
Definition: variables.c:439
void xsltFreeGlobalVariables(xsltTransformContextPtr ctxt)
Definition: variables.c:2254

Referenced by node_transform_node_params(), xsltApplyStylesheetInternal(), and xsltNewTransformContext().

◆ xsltGetXIncludeDefault()

XSLTPUBFUN int XSLTCALL xsltGetXIncludeDefault ( void  )

xsltGetXIncludeDefault:

Provides the default state for XInclude processing

Returns 0 if there is no processing 1 otherwise

Definition at line 465 of file transform.c.

465 {
466 return(xsltDoXIncludeDefault);
467}
static int xsltDoXIncludeDefault
Definition: transform.c:444

Referenced by xsltNewTransformContext().

◆ xsltIf()

XSLTPUBFUN void XSLTCALL xsltIf ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltIf: @ctxt: a XSLT process context @contextNode: the current node in the source tree @inst: the xsl:if instruction @castedComp: compiled information of the instruction

Processes the xsl:if instruction on the source node.

Definition at line 5295 of file transform.c.

5297{
5298 int res = 0;
5299
5300#ifdef XSLT_REFACTORED
5301 xsltStyleItemIfPtr comp = (xsltStyleItemIfPtr) castedComp;
5302#else
5303 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
5304#endif
5305
5306 if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
5307 return;
5308 if ((comp == NULL) || (comp->test == NULL) || (comp->comp == NULL)) {
5309 xsltTransformError(ctxt, NULL, inst,
5310 "Internal error in xsltIf(): "
5311 "The XSLT 'if' instruction was not compiled.\n");
5312 return;
5313 }
5314
5315#ifdef WITH_XSLT_DEBUG_PROCESS
5317 "xsltIf: test %s\n", comp->test));
5318#endif
5319
5320#ifdef XSLT_FAST_IF
5321 {
5322 xmlDocPtr oldLocalFragmentTop = ctxt->localRVT;
5323
5324 res = xsltPreCompEvalToBoolean(ctxt, contextNode, comp);
5325
5326 /*
5327 * Cleanup fragments created during evaluation of the
5328 * "select" expression.
5329 */
5330 if (oldLocalFragmentTop != ctxt->localRVT)
5331 xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
5332 }
5333
5334#ifdef WITH_XSLT_DEBUG_PROCESS
5336 "xsltIf: test evaluate to %d\n", res));
5337#endif
5338
5339 if (res == -1) {
5340 ctxt->state = XSLT_STATE_STOPPED;
5341 goto error;
5342 }
5343 if (res == 1) {
5344 /*
5345 * Instantiate the sequence constructor of xsl:if.
5346 */
5348 contextNode, inst->children, NULL);
5349 }
5350
5351#else /* XSLT_FAST_IF */
5352 {
5353 /*
5354 * OLD CODE:
5355 */
5356 xmlXPathObjectPtr xpobj = xsltPreCompEval(ctxt, contextNode, comp);
5357 if (xpobj != NULL) {
5358 if (xpobj->type != XPATH_BOOLEAN)
5359 xpobj = xmlXPathConvertBoolean(xpobj);
5360 if (xpobj->type == XPATH_BOOLEAN) {
5361 res = xpobj->boolval;
5362
5363#ifdef WITH_XSLT_DEBUG_PROCESS
5365 "xsltIf: test evaluate to %d\n", res));
5366#endif
5367 if (res) {
5369 contextNode, inst->children, NULL);
5370 }
5371 } else {
5372
5373#ifdef WITH_XSLT_DEBUG_PROCESS
5376 "xsltIf: test didn't evaluate to a boolean\n"));
5377#endif
5378 ctxt->state = XSLT_STATE_STOPPED;
5379 }
5380 xmlXPathFreeObject(xpobj);
5381 } else {
5382 ctxt->state = XSLT_STATE_STOPPED;
5383 }
5384 }
5385#endif /* else of XSLT_FAST_IF */
5386
5387error:
5388 return;
5389}
static void xsltReleaseLocalRVTs(xsltTransformContextPtr ctxt, xmlDocPtr base)
Definition: transform.c:2266
@ XSLT_TRACE_IF
Definition: xsltutils.h:119

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltLocalVariablePop()

XSLTPUBFUN void XSLTCALL xsltLocalVariablePop ( xsltTransformContextPtr  ctxt,
int  limitNr,
int  level 
)

xsltLocalVariablePop: @ctxt: the transformation context @limitNr: number of variables which should remain @level: the depth in the xsl:template's tree

Pops all variable values at the given @depth from the stack.

Returns the stored variable value NOTE: This is an internal routine and should not be called by users!

Definition at line 178 of file transform.c.

179{
181
182 if (ctxt->varsNr <= 0)
183 return;
184
185 do {
186 if (ctxt->varsNr <= limitNr)
187 break;
188 variable = ctxt->varsTab[ctxt->varsNr - 1];
189 if (variable->level <= level)
190 break;
191 if (variable->level >= 0)
193 ctxt->varsNr--;
194 } while (ctxt->varsNr != 0);
195 if (ctxt->varsNr > 0)
196 ctxt->vars = ctxt->varsTab[ctxt->varsNr - 1];
197 else
198 ctxt->vars = NULL;
199}
GLint level
Definition: gl.h:1546
GLenum GLenum variable
Definition: glext.h:9031
xsltStackElemPtr vars

Referenced by xsltApplyOneTemplate(), xsltApplySequenceConstructor(), and xsltApplyStylesheetInternal().

◆ xsltLocalVariablePush()

XSLTPUBFUN int XSLTCALL xsltLocalVariablePush ( xsltTransformContextPtr  ctxt,
xsltStackElemPtr  variable,
int  level 
)

xsltLocalVariablePush: @ctxt: the transformation context @variable: variable to be pushed to the variable stack @level: new value for variable's level

Places the variable onto the local variable stack

Returns: 0 for success, -1 for any error NOTE: This is an internal routine and should not be called by users!

Definition at line 2236 of file transform.c.

2239{
2240 if (ctxt->varsNr >= ctxt->varsMax) {
2241 xsltStackElemPtr *tmp;
2242 int newMax = ctxt->varsMax == 0 ? 10 : 2 * ctxt->varsMax;
2243
2244 tmp = (xsltStackElemPtr *) xmlRealloc(ctxt->varsTab,
2245 newMax * sizeof(*tmp));
2246 if (tmp == NULL) {
2247 xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
2248 return (-1);
2249 }
2250 ctxt->varsTab = tmp;
2251 ctxt->varsMax = newMax;
2252 }
2253 ctxt->varsTab[ctxt->varsNr++] = variable;
2254 ctxt->vars = variable;
2255 variable->level = level;
2256 return(0);
2257}
void * xmlGenericErrorContext
Definition: globals.c:410
xmlReallocFunc xmlRealloc
Definition: globals.c:214
xmlGenericErrorFunc xmlGenericError
Definition: globals.c:396

Referenced by xsltApplyOneTemplate(), and xsltApplyXSLTTemplate().

◆ xsltNewTransformContext()

XSLTPUBFUN xsltTransformContextPtr XSLTCALL xsltNewTransformContext ( xsltStylesheetPtr  style,
xmlDocPtr  doc 
)

Export context to users.

xsltNewTransformContext: @style: a parsed XSLT stylesheet @doc: the input document

Create a new XSLT TransformContext

Returns the newly allocated xsltTransformContextPtr or NULL in case of error

Definition at line 564 of file transform.c.

564 {
566 xsltDocumentPtr docu;
567 int i;
568
570
572 if (cur == NULL) {
573 xsltTransformError(NULL, NULL, (xmlNodePtr)doc,
574 "xsltNewTransformContext : malloc failed\n");
575 return(NULL);
576 }
577 memset(cur, 0, sizeof(xsltTransformContext));
578
579 cur->cache = xsltTransformCacheCreate();
580 if (cur->cache == NULL)
581 goto internal_err;
582 /*
583 * setup of the dictionary must be done early as some of the
584 * processing later like key handling may need it.
585 */
586 cur->dict = xmlDictCreateSub(style->dict);
587 cur->internalized = ((style->internalized) && (cur->dict != NULL));
588#ifdef WITH_XSLT_DEBUG
590 "Creating sub-dictionary from stylesheet for transformation\n");
591#endif
592
593 /*
594 * initialize the template stack
595 */
596 cur->templTab = (xsltTemplatePtr *)
597 xmlMalloc(10 * sizeof(xsltTemplatePtr));
598 if (cur->templTab == NULL) {
599 xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
600 "xsltNewTransformContext: out of memory\n");
601 goto internal_err;
602 }
603 cur->templNr = 0;
604 cur->templMax = 5;
605 cur->templ = NULL;
606 cur->maxTemplateDepth = xsltMaxDepth;
607
608 /*
609 * initialize the variables stack
610 */
611 cur->varsTab = (xsltStackElemPtr *)
612 xmlMalloc(10 * sizeof(xsltStackElemPtr));
613 if (cur->varsTab == NULL) {
615 "xsltNewTransformContext: out of memory\n");
616 goto internal_err;
617 }
618 cur->varsNr = 0;
619 cur->varsMax = 10;
620 cur->vars = NULL;
621 cur->varsBase = 0;
622 cur->maxTemplateVars = xsltMaxVars;
623
624 /*
625 * the profiling stack is not initialized by default
626 */
627 cur->profTab = NULL;
628 cur->profNr = 0;
629 cur->profMax = 0;
630 cur->prof = 0;
631
632 cur->style = style;
633 cur->xpathCtxt = xmlXPathNewContext(doc);
634 if (cur->xpathCtxt == NULL) {
635 xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
636 "xsltNewTransformContext : xmlXPathNewContext failed\n");
637 goto internal_err;
638 }
639 /*
640 * Create an XPath cache.
641 */
642 if (xmlXPathContextSetCache(cur->xpathCtxt, 1, -1, 0) == -1)
643 goto internal_err;
644 /*
645 * Initialize the extras array
646 */
647 if (style->extrasNr != 0) {
648 cur->extrasMax = style->extrasNr + 20;
649 cur->extras = (xsltRuntimeExtraPtr)
650 xmlMalloc(cur->extrasMax * sizeof(xsltRuntimeExtra));
651 if (cur->extras == NULL) {
653 "xsltNewTransformContext: out of memory\n");
654 goto internal_err;
655 }
656 cur->extrasNr = style->extrasNr;
657 for (i = 0;i < cur->extrasMax;i++) {
658 cur->extras[i].info = NULL;
659 cur->extras[i].deallocate = NULL;
660 cur->extras[i].val.ptr = NULL;
661 }
662 } else {
663 cur->extras = NULL;
664 cur->extrasNr = 0;
665 cur->extrasMax = 0;
666 }
667
670 cur->xpathCtxt->nsHash = style->nsHash;
671 /*
672 * Initialize the registered external modules
673 */
675 /*
676 * Setup document element ordering for later efficiencies
677 * (bug 133289)
678 */
680 xmlXPathOrderDocElems(doc);
681 /*
682 * Must set parserOptions before calling xsltNewDocument
683 * (bug 164530)
684 */
685 cur->parserOptions = XSLT_PARSE_OPTIONS;
686 docu = xsltNewDocument(cur, doc);
687 if (docu == NULL) {
688 xsltTransformError(cur, NULL, (xmlNodePtr)doc,
689 "xsltNewTransformContext : xsltNewDocument failed\n");
690 goto internal_err;
691 }
692 docu->main = 1;
693 cur->document = docu;
694 cur->inst = NULL;
695 cur->outputFile = NULL;
697 cur->debugStatus = xslDebugStatus;
698 cur->traceCode = (unsigned long*) &xsltDefaultTrace;
699 cur->xinclude = xsltGetXIncludeDefault();
700 cur->keyInitLevel = 0;
701
702 cur->newLocale = xsltNewLocale;
703 cur->freeLocale = xsltFreeLocale;
704 cur->genSortKey = xsltStrxfrm;
705
706 return(cur);
707
708internal_err:
709 if (cur != NULL)
711 return(NULL);
712}
int xsltInitCtxtExts(xsltTransformContextPtr ctxt)
Definition: extensions.c:1041
void xsltInitGlobals(void)
Definition: extensions.c:2282
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:180
static unsigned long xsltDefaultTrace
Definition: transform.c:469
void xsltFreeTransformContext(xsltTransformContextPtr ctxt)
Definition: transform.c:721
int xsltMaxDepth
Definition: transform.c:71
static xsltTransformCachePtr xsltTransformCacheCreate(void)
Definition: transform.c:499
int xsltGetXIncludeDefault(void)
Definition: transform.c:465
int xsltMaxVars
Definition: transform.c:72
xsltDocumentPtr xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc)
Definition: documents.c:142
#define XSLT_REGISTER_FUNCTION_LOOKUP(ctxt)
Definition: functions.h:27
xmlDictPtr xmlDictCreateSub(xmlDictPtr sub)
Definition: dict.c:297
xmlMallocFunc xmlMalloc
Definition: globals.c:193
#define XSLT_REGISTER_VARIABLE_LOOKUP(ctxt)
Definition: variables.h:30
xsltTransformContext * xsltTransformContextPtr
xsltRuntimeExtra * xsltRuntimeExtraPtr
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54
xmlChar * xsltStrxfrm(void *vlocale, const xmlChar *string)
Definition: xsltlocale.c:392
void * xsltNewLocale(const xmlChar *languageTag, int lowerFirst ATTRIBUTE_UNUSED)
Definition: xsltlocale.c:112
void xsltFreeLocale(void *locale)
Definition: xsltlocale.c:372

Referenced by node_transform_node_params(), and xsltApplyStylesheetInternal().

◆ xsltNumber()

XSLTPUBFUN void XSLTCALL xsltNumber ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltNumber: @ctxt: a XSLT process context @node: the node in the source tree. @inst: the xslt number node @castedComp: precomputed information

Process the xslt number node on the source node

Definition at line 4593 of file transform.c.

4595{
4596#ifdef XSLT_REFACTORED
4597 xsltStyleItemNumberPtr comp = (xsltStyleItemNumberPtr) castedComp;
4598#else
4599 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4600#endif
4601 xmlXPathContextPtr xpctxt;
4602 xmlNsPtr *oldXPNamespaces;
4603 int oldXPNsNr;
4604
4605 if (comp == NULL) {
4606 xsltTransformError(ctxt, NULL, inst,
4607 "xsl:number : compilation failed\n");
4608 return;
4609 }
4610
4611 if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
4612 return;
4613
4614 comp->numdata.doc = inst->doc;
4615 comp->numdata.node = inst;
4616
4617 xpctxt = ctxt->xpathCtxt;
4618 oldXPNsNr = xpctxt->nsNr;
4619 oldXPNamespaces = xpctxt->namespaces;
4620
4621#ifdef XSLT_REFACTORED
4622 if (comp->inScopeNs != NULL) {
4623 xpctxt->namespaces = comp->inScopeNs->list;
4624 xpctxt->nsNr = comp->inScopeNs->xpathNumber;
4625 } else {
4626 xpctxt->namespaces = NULL;
4627 xpctxt->nsNr = 0;
4628 }
4629#else
4630 xpctxt->namespaces = comp->nsList;
4631 xpctxt->nsNr = comp->nsNr;
4632#endif
4633
4634 xsltNumberFormat(ctxt, &comp->numdata, node);
4635
4636 xpctxt->nsNr = oldXPNsNr;
4637 xpctxt->namespaces = oldXPNamespaces;
4638}
void xsltNumberFormat(xsltTransformContextPtr ctxt, xsltNumberDataPtr data, xmlNodePtr node)
Definition: numbers.c:744

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltProcessingInstruction()

XSLTPUBFUN void XSLTCALL xsltProcessingInstruction ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltProcessingInstruction: @ctxt: a XSLT process context @node: the node in the source tree. @inst: the xslt processing-instruction node @castedComp: precomputed information

Process the xslt processing-instruction node on the source node

Definition at line 4309 of file transform.c.

4310 {
4311#ifdef XSLT_REFACTORED
4312 xsltStyleItemPIPtr comp = (xsltStyleItemPIPtr) castedComp;
4313#else
4314 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4315#endif
4316 const xmlChar *name;
4317 xmlChar *value = NULL;
4318 xmlNodePtr pi;
4319
4320
4321 if (ctxt->insert == NULL)
4322 return;
4323 if (comp->has_name == 0)
4324 return;
4325 if (comp->name == NULL) {
4326 name = xsltEvalAttrValueTemplate(ctxt, inst,
4327 (const xmlChar *)"name", NULL);
4328 if (name == NULL) {
4329 xsltTransformError(ctxt, NULL, inst,
4330 "xsl:processing-instruction : name is missing\n");
4331 goto error;
4332 }
4333 } else {
4334 name = comp->name;
4335 }
4336 /* TODO: check that it's both an an NCName and a PITarget. */
4337
4338
4339 value = xsltEvalTemplateString(ctxt, node, inst);
4340 if (xmlStrstr(value, BAD_CAST "?>") != NULL) {
4341 xsltTransformError(ctxt, NULL, inst,
4342 "xsl:processing-instruction: '?>' not allowed within PI content\n");
4343 goto error;
4344 }
4345#ifdef WITH_XSLT_DEBUG_PROCESS
4346 if (value == NULL) {
4348 "xsltProcessingInstruction: %s empty\n", name));
4349 } else {
4351 "xsltProcessingInstruction: %s content %s\n", name, value));
4352 }
4353#endif
4354
4355 pi = xmlNewDocPI(ctxt->insert->doc, name, value);
4356 pi = xsltAddChild(ctxt->insert, pi);
4357
4358error:
4359 if ((name != NULL) && (name != comp->name))
4360 xmlFree((xmlChar *) name);
4361 if (value != NULL)
4362 xmlFree(value);
4363}
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
@ XSLT_TRACE_PI
Definition: xsltutils.h:113

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltProcessOneNode()

XSLTPUBFUN void XSLTCALL xsltProcessOneNode ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xsltStackElemPtr  withParams 
)

xsltProcessOneNode: @ctxt: a XSLT process context @contextNode: the "current node" in the source tree @withParams: extra parameters (e.g. xsl:with-param) passed to the template if any

Process the source node.

Definition at line 2112 of file transform.c.

2114{
2115 xsltTemplatePtr templ;
2116 xmlNodePtr oldNode;
2117
2118 templ = xsltGetTemplate(ctxt, contextNode, NULL);
2119 /*
2120 * If no template is found, apply the default rule.
2121 */
2122 if (templ == NULL) {
2123#ifdef WITH_XSLT_DEBUG_PROCESS
2124 if (contextNode->type == XML_DOCUMENT_NODE) {
2126 "xsltProcessOneNode: no template found for /\n"));
2127 } else if (contextNode->type == XML_CDATA_SECTION_NODE) {
2129 "xsltProcessOneNode: no template found for CDATA\n"));
2130 } else if (contextNode->type == XML_ATTRIBUTE_NODE) {
2132 "xsltProcessOneNode: no template found for attribute %s\n",
2133 ((xmlAttrPtr) contextNode)->name));
2134 } else {
2136 "xsltProcessOneNode: no template found for %s\n", contextNode->name));
2137 }
2138#endif
2139 oldNode = ctxt->node;
2140 ctxt->node = contextNode;
2141 xsltDefaultProcessOneNode(ctxt, contextNode, withParams);
2142 ctxt->node = oldNode;
2143 return;
2144 }
2145
2146 if (contextNode->type == XML_ATTRIBUTE_NODE) {
2147 xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
2148 /*
2149 * Set the "current template rule".
2150 */
2151 ctxt->currentTemplateRule = templ;
2152
2153#ifdef WITH_XSLT_DEBUG_PROCESS
2155 "xsltProcessOneNode: applying template '%s' for attribute %s\n",
2156 templ->match, contextNode->name));
2157#endif
2158 xsltApplyXSLTTemplate(ctxt, contextNode, templ->content, templ, withParams);
2159
2160 ctxt->currentTemplateRule = oldCurTempRule;
2161 } else {
2162 xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
2163 /*
2164 * Set the "current template rule".
2165 */
2166 ctxt->currentTemplateRule = templ;
2167
2168#ifdef WITH_XSLT_DEBUG_PROCESS
2169 if (contextNode->type == XML_DOCUMENT_NODE) {
2171 "xsltProcessOneNode: applying template '%s' for /\n",
2172 templ->match));
2173 } else {
2175 "xsltProcessOneNode: applying template '%s' for %s\n",
2176 templ->match, contextNode->name));
2177 }
2178#endif
2179 xsltApplyXSLTTemplate(ctxt, contextNode, templ->content, templ, withParams);
2180
2181 ctxt->currentTemplateRule = oldCurTempRule;
2182 }
2183}
xmlChar * match
@ XSLT_TRACE_PROCESS_NODE
Definition: xsltutils.h:109

Referenced by xsltApplyStylesheetInternal(), xsltApplyTemplates(), and xsltDefaultProcessOneNode().

◆ xsltProfileStylesheet()

XSLTPUBFUN xmlDocPtr XSLTCALL xsltProfileStylesheet ( xsltStylesheetPtr  style,
xmlDocPtr  doc,
const char **  params,
FILE output 
)

xsltProfileStylesheet: @style: a parsed XSLT stylesheet @doc: a parsed XML document @params: a NULL terminated arry of parameters names/values tuples @output: a FILE * for the profiling output

Apply the stylesheet to the document and dump the profiling to the given output.

Returns the result document or NULL in case of error

Definition at line 6249 of file transform.c.

6251{
6252 xmlDocPtr res;
6253
6255 return (res);
6256}

◆ xsltRegisterAllElement()

XSLTPUBFUN void XSLTCALL xsltRegisterAllElement ( xsltTransformContextPtr  ctxt)

xsltRegisterAllElement: @ctxt: the XPath context

Registers all default XSLT elements in this context

Definition at line 6393 of file transform.c.

6394{
6395 xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-templates",
6398 xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-imports",
6401 xsltRegisterExtElement(ctxt, (const xmlChar *) "call-template",
6404 xsltRegisterExtElement(ctxt, (const xmlChar *) "element",
6406 xsltElement);
6407 xsltRegisterExtElement(ctxt, (const xmlChar *) "attribute",
6410 xsltRegisterExtElement(ctxt, (const xmlChar *) "text",
6412 xsltText);
6413 xsltRegisterExtElement(ctxt, (const xmlChar *) "processing-instruction",
6416 xsltRegisterExtElement(ctxt, (const xmlChar *) "comment",
6418 xsltComment);
6419 xsltRegisterExtElement(ctxt, (const xmlChar *) "copy",
6421 xsltCopy);
6422 xsltRegisterExtElement(ctxt, (const xmlChar *) "value-of",
6424 xsltValueOf);
6425 xsltRegisterExtElement(ctxt, (const xmlChar *) "number",
6427 xsltNumber);
6428 xsltRegisterExtElement(ctxt, (const xmlChar *) "for-each",
6430 xsltForEach);
6431 xsltRegisterExtElement(ctxt, (const xmlChar *) "if",
6433 xsltIf);
6434 xsltRegisterExtElement(ctxt, (const xmlChar *) "choose",
6436 xsltChoose);
6437 xsltRegisterExtElement(ctxt, (const xmlChar *) "sort",
6439 xsltSort);
6440 xsltRegisterExtElement(ctxt, (const xmlChar *) "copy-of",
6442 xsltCopyOf);
6443 xsltRegisterExtElement(ctxt, (const xmlChar *) "message",
6446
6447 /*
6448 * Those don't have callable entry points but are registered anyway
6449 */
6450 xsltRegisterExtElement(ctxt, (const xmlChar *) "variable",
6452 xsltDebug);
6453 xsltRegisterExtElement(ctxt, (const xmlChar *) "param",
6455 xsltDebug);
6456 xsltRegisterExtElement(ctxt, (const xmlChar *) "with-param",
6458 xsltDebug);
6459 xsltRegisterExtElement(ctxt, (const xmlChar *) "decimal-format",
6461 xsltDebug);
6462 xsltRegisterExtElement(ctxt, (const xmlChar *) "when",
6464 xsltDebug);
6465 xsltRegisterExtElement(ctxt, (const xmlChar *) "otherwise",
6467 xsltDebug);
6468 xsltRegisterExtElement(ctxt, (const xmlChar *) "fallback",
6470 xsltDebug);
6471
6472}
int xsltRegisterExtElement(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *URI, xsltTransformFunction function)
Definition: extensions.c:643
void xsltDebug(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst ATTRIBUTE_UNUSED, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: extra.c:53
void xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: attributes.c:748
void xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:5401
void xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:4719
void xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:4519
void xsltSort(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst, xsltElemPreCompPtr comp)
Definition: transform.c:3879
void xsltApplyImports(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: transform.c:4650
void xsltProcessingInstruction(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:4309
static void xsltMessageWrapper(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: transform.c:6381
void xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:4375
void xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:4057
void xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:5295
void xsltComment(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: transform.c:4265
void xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: transform.c:5136
void xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: transform.c:4020
void xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:3901
void xsltNumber(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:4593
void xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:4822

◆ xsltRunStylesheet()

XSLTPUBFUN int XSLTCALL xsltRunStylesheet ( xsltStylesheetPtr  style,
xmlDocPtr  doc,
const char **  params,
const char output,
xmlSAXHandlerPtr  SAX,
xmlOutputBufferPtr  IObuf 
)

xsltRunStylesheet: @style: a parsed XSLT stylesheet @doc: a parsed XML document @params: a NULL terminated array of parameters names/values tuples @output: the URL/filename ot the generated resource if available @SAX: a SAX handler for progressive callback output (not implemented yet) @IObuf: an output buffer for progressive output (not implemented yet)

Apply the stylesheet to the document and generate the output according to @output @SAX and @IObuf. It's an error to specify both @SAX and @IObuf.

NOTE: This may lead to a non-wellformed output XML wise ! NOTE: This may also result in multiple files being generated NOTE: using IObuf, the result encoding used will be the one used for creating the output buffer, use the following macro to read it from the stylesheet XSLT_GET_IMPORT_PTR(encoding, style, encoding) NOTE: using SAX, any encoding specified in the stylesheet will be lost since the interface uses only UTF8

Returns the number of bytes written to the main resource or -1 in case of error.

Definition at line 6372 of file transform.c.

6375{
6376 return(xsltRunStylesheetUser(style, doc, params, output, SAX, IObuf,
6377 NULL, NULL));
6378}
int xsltRunStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf, FILE *profile, xsltTransformContextPtr userCtxt)
Definition: transform.c:6311

◆ xsltRunStylesheetUser()

XSLTPUBFUN int XSLTCALL xsltRunStylesheetUser ( xsltStylesheetPtr  style,
xmlDocPtr  doc,
const char **  params,
const char output,
xmlSAXHandlerPtr  SAX,
xmlOutputBufferPtr  IObuf,
FILE profile,
xsltTransformContextPtr  userCtxt 
)

xsltRunStylesheetUser: @style: a parsed XSLT stylesheet @doc: a parsed XML document @params: a NULL terminated array of parameters names/values tuples @output: the URL/filename ot the generated resource if available @SAX: a SAX handler for progressive callback output (not implemented yet) @IObuf: an output buffer for progressive output (not implemented yet) @profile: profile FILE * output or NULL @userCtxt: user provided transform context

Apply the stylesheet to the document and generate the output according to @output @SAX and @IObuf. It's an error to specify both @SAX and @IObuf.

NOTE: This may lead to a non-wellformed output XML wise ! NOTE: This may also result in multiple files being generated NOTE: using IObuf, the result encoding used will be the one used for creating the output buffer, use the following macro to read it from the stylesheet XSLT_GET_IMPORT_PTR(encoding, style, encoding) NOTE: using SAX, any encoding specified in the stylesheet will be lost since the interface uses only UTF8

Returns the number of by written to the main resource or -1 in case of error.

Definition at line 6311 of file transform.c.

6315{
6316 xmlDocPtr tmp;
6317 int ret;
6318
6319 if ((output == NULL) && (SAX == NULL) && (IObuf == NULL))
6320 return (-1);
6321 if ((SAX != NULL) && (IObuf != NULL))
6322 return (-1);
6323
6324 /* unsupported yet */
6325 if (SAX != NULL) {
6326 XSLT_TODO /* xsltRunStylesheet xmlSAXHandlerPtr SAX */
6327 return (-1);
6328 }
6329
6330 tmp = xsltApplyStylesheetInternal(style, doc, params, output, profile,
6331 userCtxt);
6332 if (tmp == NULL) {
6333 xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
6334 "xsltRunStylesheet : run failed\n");
6335 return (-1);
6336 }
6337 if (IObuf != NULL) {
6338 /* TODO: incomplete, IObuf output not progressive */
6339 ret = xsltSaveResultTo(IObuf, tmp, style);
6340 } else {
6341 ret = xsltSaveResultToFilename(output, tmp, style, 0);
6342 }
6343 xmlFreeDoc(tmp);
6344 return (ret);
6345}
int xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result, xsltStylesheetPtr style)
Definition: xsltutils.c:1564
#define XSLT_TODO
Definition: xsltutils.h:31

Referenced by xsltRunStylesheet().

◆ xsltSetXIncludeDefault()

XSLTPUBFUN void XSLTCALL xsltSetXIncludeDefault ( int  xinclude)

XInclude default processing.

xsltSetXIncludeDefault: @xinclude: whether to do XInclude processing

Set whether XInclude should be processed on document being loaded by default

Definition at line 453 of file transform.c.

453 {
454 xsltDoXIncludeDefault = (xinclude != 0);
455}

◆ xsltSort()

XSLTPUBFUN void XSLTCALL xsltSort ( xsltTransformContextPtr  ctxt,
xmlNodePtr node  ATTRIBUTE_UNUSED,
xmlNodePtr  inst,
xsltElemPreCompPtr  comp 
)

xsltSort: @ctxt: a XSLT process context @node: the node in the source tree. @inst: the xslt sort node @comp: precomputed information

function attached to xsl:sort nodes, but this should not be called directly

Definition at line 3879 of file transform.c.

3881 {
3882 if (comp == NULL) {
3883 xsltTransformError(ctxt, NULL, inst,
3884 "xsl:sort : compilation failed\n");
3885 return;
3886 }
3887 xsltTransformError(ctxt, NULL, inst,
3888 "xsl:sort : improper use this should not be reached\n");
3889}

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltText()

XSLTPUBFUN void XSLTCALL xsltText ( xsltTransformContextPtr  ctxt,
xmlNodePtr node  ATTRIBUTE_UNUSED,
xmlNodePtr  inst,
xsltElemPreCompPtr comp  ATTRIBUTE_UNUSED 
)

xsltText: @ctxt: a XSLT process context @node: the node in the source tree. @inst: the xslt text node @comp: precomputed information

Process the xslt text node on the source node

Definition at line 4020 of file transform.c.

4021 {
4022 if ((inst->children != NULL) && (comp != NULL)) {
4023 xmlNodePtr text = inst->children;
4024 xmlNodePtr copy;
4025
4026 while (text != NULL) {
4027 if ((text->type != XML_TEXT_NODE) &&
4028 (text->type != XML_CDATA_SECTION_NODE)) {
4029 xsltTransformError(ctxt, NULL, inst,
4030 "xsl:text content problem\n");
4031 break;
4032 }
4033 copy = xmlNewDocText(ctxt->output, text->content);
4034 if (text->type != XML_CDATA_SECTION_NODE) {
4035#ifdef WITH_XSLT_DEBUG_PARSING
4037 "Disable escaping: %s\n", text->content);
4038#endif
4039 copy->name = xmlStringTextNoenc;
4040 }
4041 copy = xsltAddChild(ctxt->insert, copy);
4042 text = text->next;
4043 }
4044 }
4045}
const WCHAR * text
Definition: package.c:1794

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltValueOf()

XSLTPUBFUN void XSLTCALL xsltValueOf ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr  castedComp 
)

xsltValueOf: @ctxt: a XSLT process context @node: the node in the source tree. @inst: the xslt value-of node @castedComp: precomputed information

Process the xslt value-of node on the source node

Definition at line 4519 of file transform.c.

4521{
4522#ifdef XSLT_REFACTORED
4523 xsltStyleItemValueOfPtr comp = (xsltStyleItemValueOfPtr) castedComp;
4524#else
4525 xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4526#endif
4527 xmlXPathObjectPtr res = NULL;
4528 xmlChar *value = NULL;
4529
4530 if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
4531 return;
4532
4533 if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
4534 xsltTransformError(ctxt, NULL, inst,
4535 "Internal error in xsltValueOf(): "
4536 "The XSLT 'value-of' instruction was not compiled.\n");
4537 return;
4538 }
4539
4540#ifdef WITH_XSLT_DEBUG_PROCESS
4542 "xsltValueOf: select %s\n", comp->select));
4543#endif
4544
4545 res = xsltPreCompEval(ctxt, node, comp);
4546
4547 /*
4548 * Cast the XPath object to string.
4549 */
4550 if (res != NULL) {
4551 value = xmlXPathCastToString(res);
4552 if (value == NULL) {
4553 xsltTransformError(ctxt, NULL, inst,
4554 "Internal error in xsltValueOf(): "
4555 "failed to cast an XPath object to string.\n");
4556 ctxt->state = XSLT_STATE_STOPPED;
4557 goto error;
4558 }
4559 if (value[0] != 0) {
4560 xsltCopyTextString(ctxt, ctxt->insert, value, comp->noescape);
4561 }
4562 } else {
4563 xsltTransformError(ctxt, NULL, inst,
4564 "XPath evaluation returned no result.\n");
4565 ctxt->state = XSLT_STATE_STOPPED;
4566 goto error;
4567 }
4568
4569#ifdef WITH_XSLT_DEBUG_PROCESS
4570 if (value) {
4572 "xsltValueOf: result '%s'\n", value));
4573 }
4574#endif
4575
4576error:
4577 if (value != NULL)
4578 xmlFree(value);
4579 if (res != NULL)
4580 xmlXPathFreeObject(res);
4581}
@ XSLT_TRACE_VALUE_OF
Definition: xsltutils.h:115

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().