ReactOS  0.4.13-dev-982-g9853eab
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()

XSLTPUBFUN void XSLTCALL xslHandleDebugger ( xmlNodePtr  cur,
xmlNodePtr  node,
xsltTemplatePtr  templ,
xsltTransformContextPtr  ctxt 
)

xslHandleDebugger: @cur : source node being executed @node : data node being processed @templ : temlate that applies to node @ctxt : the xslt transform context

If either cur or node are a breakpoint, or xslDebugStatus in state where debugging must occcur at this time then transfer control to the xslDebugBreak function

Definition at line 2422 of file xsltutils.c.

2424 {
2426  xsltDebuggerCurrentCallbacks.handler(cur, node, templ, ctxt);
2427 }
smooth NULL
Definition: ftsmooth.c:416
static xsltDebuggerCallbacks xsltDebuggerCurrentCallbacks
Definition: xsltutils.c:2351
xsltHandleDebuggerCallback handler
Definition: xsltutils.c:2346
Definition: dlist.c:348

Referenced by xsltApplyAttributeSet(), xsltApplySequenceConstructor(), xsltApplyTemplates(), xsltAttribute(), xsltCallTemplate(), xsltChoose(), xsltDebuggerStartSequenceConstructor(), xsltEvalGlobalVariable(), and xsltForEach().

◆ 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 4619 of file transform.c.

4622 {
4623  xsltTemplatePtr templ;
4624 
4625  if ((ctxt == NULL) || (inst == NULL))
4626  return;
4627 
4628  if (comp == NULL) {
4629  xsltTransformError(ctxt, NULL, inst,
4630  "Internal error in xsltApplyImports(): "
4631  "The XSLT 'apply-imports' instruction was not compiled.\n");
4632  return;
4633  }
4634  /*
4635  * NOTE that ctxt->currentTemplateRule and ctxt->templ is not the
4636  * same; the former is the "Current Template Rule" as defined by the
4637  * XSLT spec, the latter is simply the template struct being
4638  * currently processed.
4639  */
4640  if (ctxt->currentTemplateRule == NULL) {
4641  /*
4642  * SPEC XSLT 2.0:
4643  * "[ERR XTDE0560] It is a non-recoverable dynamic error if
4644  * xsl:apply-imports or xsl:next-match is evaluated when the
4645  * current template rule is null."
4646  */
4647  xsltTransformError(ctxt, NULL, inst,
4648  "It is an error to call 'apply-imports' "
4649  "when there's no current template rule.\n");
4650  return;
4651  }
4652  /*
4653  * TODO: Check if this is correct.
4654  */
4655  templ = xsltGetTemplate(ctxt, contextNode,
4656  ctxt->currentTemplateRule->style);
4657 
4658  if (templ != NULL) {
4659  xsltTemplatePtr oldCurTemplRule = ctxt->currentTemplateRule;
4660  /*
4661  * Set the current template rule.
4662  */
4663  ctxt->currentTemplateRule = templ;
4664  /*
4665  * URGENT TODO: Need xsl:with-param be handled somehow here?
4666  */
4667  xsltApplyXSLTTemplate(ctxt, contextNode, templ->content,
4668  templ, NULL);
4669 
4670  ctxt->currentTemplateRule = oldCurTemplRule;
4671  }
4672  else {
4673  /* Use built-in templates. */
4674  xsltDefaultProcessOneNode(ctxt, contextNode, NULL);
4675  }
4676 }
xmlNodePtr content
static void xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ, xsltStackElemPtr withParams)
Definition: transform.c:3047
xsltTemplatePtr xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylesheetPtr style)
Definition: pattern.c:2318
smooth NULL
Definition: ftsmooth.c:416
static void xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStackElemPtr params)
Definition: transform.c:1854
xsltTemplatePtr currentTemplateRule
struct _xsltStylesheet * style
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

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 3285 of file transform.c.

3290 {
3291  if ((ctxt == NULL) || (list == NULL))
3292  return;
3293  CHECK_STOPPED;
3294 
3295  if (params) {
3296  /*
3297  * This code should be obsolete - was previously used
3298  * by libexslt/functions.c, but due to bug 381319 the
3299  * logic there was changed.
3300  */
3301  int oldVarsNr = ctxt->varsNr;
3302 
3303  /*
3304  * Push the given xsl:param(s) onto the variable stack.
3305  */
3306  while (params != NULL) {
3307  xsltLocalVariablePush(ctxt, params, -1);
3308  params = params->next;
3309  }
3310  xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
3311  /*
3312  * Pop the given xsl:param(s) from the stack but don't free them.
3313  */
3314  xsltLocalVariablePop(ctxt, oldVarsNr, -2);
3315  } else
3316  xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
3317 }
#define CHECK_STOPPED
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
int xsltLocalVariablePush(xsltTransformContextPtr ctxt, xsltStackElemPtr variable, int level)
Definition: transform.c:2222
Definition: _list.h:228
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
void xsltLocalVariablePop(xsltTransformContextPtr ctxt, int limitNr, int level)
Definition: transform.c:150

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 5681 of file transform.c.

5681  {
5683 #ifdef WITH_XSLT_DEBUG_PROCESS
5684  int nb = 0;
5685 #endif
5686 
5687 
5688  current = node;
5689  while (current != NULL) {
5690  /*
5691  * Cleanup children empty nodes if asked for
5692  */
5693  if ((IS_XSLT_REAL_NODE(current)) &&
5694  (current->children != NULL) &&
5696  xmlNodePtr delete = NULL, cur = current->children;
5697 
5698  while (cur != NULL) {
5699  if (IS_BLANK_NODE(cur))
5700  delete = cur;
5701 
5702  cur = cur->next;
5703  if (delete != NULL) {
5704  xmlUnlinkNode(delete);
5705  xmlFreeNode(delete);
5706  delete = NULL;
5707 #ifdef WITH_XSLT_DEBUG_PROCESS
5708  nb++;
5709 #endif
5710  }
5711  }
5712  }
5713 
5714  /*
5715  * Skip to next node in document order.
5716  */
5717  if (node->type == XML_ENTITY_REF_NODE) {
5718  /* process deep in entities */
5719  xsltApplyStripSpaces(ctxt, node->children);
5720  }
5721  if ((current->children != NULL) &&
5722  (current->type != XML_ENTITY_REF_NODE)) {
5723  current = current->children;
5724  } else if (current->next != NULL) {
5725  current = current->next;
5726  } else {
5727  do {
5728  current = current->parent;
5729  if (current == NULL)
5730  break;
5731  if (current == node)
5732  goto done;
5733  if (current->next != NULL) {
5734  current = current->next;
5735  break;
5736  }
5737  } while (current != NULL);
5738  }
5739  }
5740 
5741 done:
5742 #ifdef WITH_XSLT_DEBUG_PROCESS
5744  "xsltApplyStripSpaces: removed %d ignorable blank node\n", nb));
5745 #endif
5746  return;
5747 }
struct node node
#define IS_BLANK_NODE(n)
Definition: transform.c:47
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
#define IS_XSLT_REAL_NODE(n)
Definition: xsltutils.h:71
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
int xsltFindElemSpaceHandling(xsltTransformContextPtr ctxt, xmlNodePtr node)
Definition: imports.c:302
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
void xsltApplyStripSpaces(xsltTransformContextPtr ctxt, xmlNodePtr node)
Definition: transform.c:5681
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
struct task_struct * current
Definition: linux.c:32
Definition: dlist.c:348

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 6204 of file transform.c.

6206 {
6208 }
static xmlDocPtr xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, FILE *profile, xsltTransformContextPtr userCtxt)
Definition: transform.c:5801
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
Arabic default style
Definition: afstyles.h:93

◆ 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 6247 of file transform.c.

6250 {
6251  xmlDocPtr res;
6252 
6254  profile, userCtxt);
6255  return (res);
6256 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
static xmlDocPtr xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, FILE *profile, xsltTransformContextPtr userCtxt)
Definition: transform.c:5801
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: tree.h:551
GLuint res
Definition: glext.h:9613
#define profile
Definition: kernel32.h:12
Arabic default style
Definition: afstyles.h:93

◆ 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 4791 of file transform.c.

4793 {
4794 #ifdef XSLT_REFACTORED
4795  xsltStyleItemApplyTemplatesPtr comp =
4796  (xsltStyleItemApplyTemplatesPtr) castedComp;
4797 #else
4798  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4799 #endif
4800  int i;
4801  xmlNodePtr cur, delNode = NULL, oldContextNode;
4802  xmlNodeSetPtr list = NULL, oldList;
4803  xsltStackElemPtr withParams = NULL;
4804  int oldXPProximityPosition, oldXPContextSize;
4805  const xmlChar *oldMode, *oldModeURI;
4806  xmlDocPtr oldXPDoc;
4807  xsltDocumentPtr oldDocInfo;
4808  xmlXPathContextPtr xpctxt;
4809 
4810  if (comp == NULL) {
4811  xsltTransformError(ctxt, NULL, inst,
4812  "xsl:apply-templates : compilation failed\n");
4813  return;
4814  }
4815  if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
4816  return;
4817 
4818 #ifdef WITH_XSLT_DEBUG_PROCESS
4819  if ((node != NULL) && (node->name != NULL))
4821  "xsltApplyTemplates: node: '%s'\n", node->name));
4822 #endif
4823 
4824  xpctxt = ctxt->xpathCtxt;
4825  /*
4826  * Save context states.
4827  */
4828  oldContextNode = ctxt->node;
4829  oldMode = ctxt->mode;
4830  oldModeURI = ctxt->modeURI;
4831  oldDocInfo = ctxt->document;
4832  oldList = ctxt->nodeList;
4833 
4834  /*
4835  * The xpath context size and proximity position, as
4836  * well as the xpath and context documents, may be changed
4837  * so we save their initial state and will restore on exit
4838  */
4839  oldXPContextSize = xpctxt->contextSize;
4840  oldXPProximityPosition = xpctxt->proximityPosition;
4841  oldXPDoc = xpctxt->doc;
4842 
4843  /*
4844  * Set up contexts.
4845  */
4846  ctxt->mode = comp->mode;
4847  ctxt->modeURI = comp->modeURI;
4848 
4849  if (comp->select != NULL) {
4850  xmlXPathObjectPtr res = NULL;
4851 
4852  if (comp->comp == NULL) {
4853  xsltTransformError(ctxt, NULL, inst,
4854  "xsl:apply-templates : compilation failed\n");
4855  goto error;
4856  }
4857 #ifdef WITH_XSLT_DEBUG_PROCESS
4859  "xsltApplyTemplates: select %s\n", comp->select));
4860 #endif
4861 
4862  res = xsltPreCompEval(ctxt, node, comp);
4863 
4864  if (res != NULL) {
4865  if (res->type == XPATH_NODESET) {
4866  list = res->nodesetval; /* consume the node set */
4867  res->nodesetval = NULL;
4868  } else {
4869  xsltTransformError(ctxt, NULL, inst,
4870  "The 'select' expression did not evaluate to a "
4871  "node set.\n");
4872  ctxt->state = XSLT_STATE_STOPPED;
4873  xmlXPathFreeObject(res);
4874  goto error;
4875  }
4876  xmlXPathFreeObject(res);
4877  /*
4878  * Note: An xsl:apply-templates with a 'select' attribute,
4879  * can change the current source doc.
4880  */
4881  } else {
4882  xsltTransformError(ctxt, NULL, inst,
4883  "Failed to evaluate the 'select' expression.\n");
4884  ctxt->state = XSLT_STATE_STOPPED;
4885  goto error;
4886  }
4887  if (list == NULL) {
4888 #ifdef WITH_XSLT_DEBUG_PROCESS
4890  "xsltApplyTemplates: select didn't evaluate to a node list\n"));
4891 #endif
4892  goto exit;
4893  }
4894  /*
4895  *
4896  * NOTE: Previously a document info (xsltDocument) was
4897  * created and attached to the Result Tree Fragment.
4898  * But such a document info is created on demand in
4899  * xsltKeyFunction() (functions.c), so we need to create
4900  * it here beforehand.
4901  * In order to take care of potential keys we need to
4902  * do some extra work for the case when a Result Tree Fragment
4903  * is converted into a nodeset (e.g. exslt:node-set()) :
4904  * We attach a "pseudo-doc" (xsltDocument) to _private.
4905  * This xsltDocument, together with the keyset, will be freed
4906  * when the Result Tree Fragment is freed.
4907  *
4908  */
4909 #if 0
4910  if ((ctxt->nbKeys > 0) &&
4911  (list->nodeNr != 0) &&
4912  (list->nodeTab[0]->doc != NULL) &&
4913  XSLT_IS_RES_TREE_FRAG(list->nodeTab[0]->doc))
4914  {
4915  /*
4916  * NOTE that it's also OK if @effectiveDocInfo will be
4917  * set to NULL.
4918  */
4919  isRTF = 1;
4920  effectiveDocInfo = list->nodeTab[0]->doc->_private;
4921  }
4922 #endif
4923  } else {
4924  /*
4925  * Build an XPath node set with the children
4926  */
4927  list = xmlXPathNodeSetCreate(NULL);
4928  if (list == NULL)
4929  goto error;
4930  if (node->type != XML_NAMESPACE_DECL)
4931  cur = node->children;
4932  else
4933  cur = NULL;
4934  while (cur != NULL) {
4935  switch (cur->type) {
4936  case XML_TEXT_NODE:
4937  if ((IS_BLANK_NODE(cur)) &&
4938  (cur->parent != NULL) &&
4939  (cur->parent->type == XML_ELEMENT_NODE) &&
4940  (ctxt->style->stripSpaces != NULL)) {
4941  const xmlChar *val;
4942 
4943  if (cur->parent->ns != NULL) {
4944  val = (const xmlChar *)
4946  cur->parent->name,
4947  cur->parent->ns->href);
4948  if (val == NULL) {
4949  val = (const xmlChar *)
4951  BAD_CAST "*",
4952  cur->parent->ns->href);
4953  }
4954  } else {
4955  val = (const xmlChar *)
4957  cur->parent->name, NULL);
4958  }
4959  if ((val != NULL) &&
4960  (xmlStrEqual(val, (xmlChar *) "strip"))) {
4961  delNode = cur;
4962  break;
4963  }
4964  }
4965  /* no break on purpose */
4966  case XML_ELEMENT_NODE:
4967  case XML_DOCUMENT_NODE:
4970  case XML_PI_NODE:
4971  case XML_COMMENT_NODE:
4972  xmlXPathNodeSetAddUnique(list, cur);
4973  break;
4974  case XML_DTD_NODE:
4975  /* Unlink the DTD, it's still reachable
4976  * using doc->intSubset */
4977  if (cur->next != NULL)
4978  cur->next->prev = cur->prev;
4979  if (cur->prev != NULL)
4980  cur->prev->next = cur->next;
4981  break;
4982  case XML_NAMESPACE_DECL:
4983  break;
4984  default:
4985 #ifdef WITH_XSLT_DEBUG_PROCESS
4987  "xsltApplyTemplates: skipping cur type %d\n",
4988  cur->type));
4989 #endif
4990  delNode = cur;
4991  }
4992  cur = cur->next;
4993  if (delNode != NULL) {
4994 #ifdef WITH_XSLT_DEBUG_PROCESS
4996  "xsltApplyTemplates: removing ignorable blank cur\n"));
4997 #endif
4998  xmlUnlinkNode(delNode);
4999  xmlFreeNode(delNode);
5000  delNode = NULL;
5001  }
5002  }
5003  }
5004 
5005 #ifdef WITH_XSLT_DEBUG_PROCESS
5006  if (list != NULL)
5008  "xsltApplyTemplates: list of %d nodes\n", list->nodeNr));
5009 #endif
5010 
5011  if ((list == NULL) || (list->nodeNr == 0))
5012  goto exit;
5013 
5014  /*
5015  * Set the context's node set and size; this is also needed for
5016  * for xsltDoSortFunction().
5017  */
5018  ctxt->nodeList = list;
5019  /*
5020  * Process xsl:with-param and xsl:sort instructions.
5021  * (The code became so verbose just to avoid the
5022  * xmlNodePtr sorts[XSLT_MAX_SORT] if there's no xsl:sort)
5023  * BUG TODO: We are not using namespaced potentially defined on the
5024  * xsl:sort or xsl:with-param elements; XPath expression might fail.
5025  */
5026  if (inst->children) {
5028 
5029  cur = inst->children;
5030  while (cur) {
5031 
5032 #ifdef WITH_DEBUGGER
5033  if (ctxt->debugStatus != XSLT_DEBUG_NONE)
5034  xslHandleDebugger(cur, node, NULL, ctxt);
5035 #endif
5036  if (ctxt->state == XSLT_STATE_STOPPED)
5037  break;
5038  if (cur->type == XML_TEXT_NODE) {
5039  cur = cur->next;
5040  continue;
5041  }
5042  if (! IS_XSLT_ELEM(cur))
5043  break;
5044  if (IS_XSLT_NAME(cur, "with-param")) {
5046  if (param != NULL) {
5047  param->next = withParams;
5048  withParams = param;
5049  }
5050  }
5051  if (IS_XSLT_NAME(cur, "sort")) {
5052  xsltTemplatePtr oldCurTempRule =
5053  ctxt->currentTemplateRule;
5054  int nbsorts = 0;
5055  xmlNodePtr sorts[XSLT_MAX_SORT];
5056 
5057  sorts[nbsorts++] = cur;
5058 
5059  while (cur) {
5060 
5061 #ifdef WITH_DEBUGGER
5062  if (ctxt->debugStatus != XSLT_DEBUG_NONE)
5063  xslHandleDebugger(cur, node, NULL, ctxt);
5064 #endif
5065  if (ctxt->state == XSLT_STATE_STOPPED)
5066  break;
5067 
5068  if (cur->type == XML_TEXT_NODE) {
5069  cur = cur->next;
5070  continue;
5071  }
5072 
5073  if (! IS_XSLT_ELEM(cur))
5074  break;
5075  if (IS_XSLT_NAME(cur, "with-param")) {
5077  if (param != NULL) {
5078  param->next = withParams;
5079  withParams = param;
5080  }
5081  }
5082  if (IS_XSLT_NAME(cur, "sort")) {
5083  if (nbsorts >= XSLT_MAX_SORT) {
5084  xsltTransformError(ctxt, NULL, cur,
5085  "The number (%d) of xsl:sort instructions exceeds the "
5086  "maximum allowed by this processor's settings.\n",
5087  nbsorts);
5088  ctxt->state = XSLT_STATE_STOPPED;
5089  break;
5090  } else {
5091  sorts[nbsorts++] = cur;
5092  }
5093  }
5094  cur = cur->next;
5095  }
5096  /*
5097  * The "current template rule" is cleared for xsl:sort.
5098  */
5099  ctxt->currentTemplateRule = NULL;
5100  /*
5101  * Sort.
5102  */
5103  xsltDoSortFunction(ctxt, sorts, nbsorts);
5104  ctxt->currentTemplateRule = oldCurTempRule;
5105  break;
5106  }
5107  cur = cur->next;
5108  }
5109  }
5110  xpctxt->contextSize = list->nodeNr;
5111  /*
5112  * Apply templates for all selected source nodes.
5113  */
5114  for (i = 0; i < list->nodeNr; i++) {
5115  cur = list->nodeTab[i];
5116  /*
5117  * The node becomes the "current node".
5118  */
5119  ctxt->node = cur;
5120  /*
5121  * An xsl:apply-templates can change the current context doc.
5122  * OPTIMIZE TODO: Get rid of the need to set the context doc.
5123  */
5124  if ((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL))
5125  xpctxt->doc = cur->doc;
5126 
5127  xpctxt->proximityPosition = i + 1;
5128  /*
5129  * Find and apply a template for this node.
5130  */
5131  xsltProcessOneNode(ctxt, cur, withParams);
5132  }
5133 
5134 exit:
5135 error:
5136  /*
5137  * Free the parameter list.
5138  */
5139  if (withParams != NULL)
5140  xsltFreeStackElemList(withParams);
5141  if (list != NULL)
5142  xmlXPathFreeNodeSet(list);
5143  /*
5144  * Restore context states.
5145  */
5146  xpctxt->doc = oldXPDoc;
5147  xpctxt->contextSize = oldXPContextSize;
5148  xpctxt->proximityPosition = oldXPProximityPosition;
5149 
5150  ctxt->document = oldDocInfo;
5151  ctxt->nodeList = oldList;
5152  ctxt->node = oldContextNode;
5153  ctxt->mode = oldMode;
5154  ctxt->modeURI = oldModeURI;
5155 }
xmlNodeSetPtr nodeList
void xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xsltStackElemPtr withParams)
Definition: transform.c:2100
struct _xmlNode * prev
Definition: tree.h:497
#define error(str)
Definition: mkdosfs.c:1605
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:474
xsltStackElemPtr xsltParseStylesheetCallerParam(xsltTransformContextPtr ctxt, xmlNodePtr inst)
Definition: variables.c:1957
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
struct _xmlDoc * doc
Definition: tree.h:498
struct _xmlDoc * doc
Definition: tree.h:560
void xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
Definition: xsltutils.c:1332
const xmlChar * modeURI
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 XSLT_MAX_SORT
xsltTransformState state
#define IS_BLANK_NODE(n)
Definition: transform.c:47
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
xsltDocumentPtr document
xmlXPathContextPtr xpathCtxt
static xmlXPathObjectPtr xsltPreCompEval(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:317
GLuint GLfloat * val
Definition: glext.h:7180
struct _xmlNode * parent
Definition: tree.h:495
const xmlChar * modeURI
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
GLfloat param
Definition: glext.h:5796
xsltTemplatePtr currentTemplateRule
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
unsigned char xmlChar
Definition: xmlstring.h:28
Definition: _list.h:228
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlElementType type
Definition: tree.h:491
void xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
Definition: xsltutils.c:2422
xsltStylePreComp * xsltStylePreCompPtr
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:606
xsltStylesheetPtr style
#define XSLT_IS_RES_TREE_FRAG(n)
Definition: xsltInternals.h:56
const xmlChar * mode
struct _xmlNode * next
Definition: tree.h:496
xmlXPathCompExprPtr comp
#define list
Definition: rosglue.h:35
Definition: tree.h:551
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
const xmlChar * select
struct _xmlNode * children
Definition: tree.h:493
GLuint res
Definition: glext.h:9613
xmlHashTablePtr stripSpaces
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void exit(int exitcode)
Definition: _exit.c:33
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:63
const xmlChar * mode
Definition: dlist.c:348

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 716 of file attributes.c.

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

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 4688 of file transform.c.

4690 {
4691 #ifdef XSLT_REFACTORED
4692  xsltStyleItemCallTemplatePtr comp =
4693  (xsltStyleItemCallTemplatePtr) castedComp;
4694 #else
4695  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4696 #endif
4697  xsltStackElemPtr withParams = NULL;
4698 
4699  if (ctxt->insert == NULL)
4700  return;
4701  if (comp == NULL) {
4702  xsltTransformError(ctxt, NULL, inst,
4703  "The XSLT 'call-template' instruction was not compiled.\n");
4704  return;
4705  }
4706 
4707  /*
4708  * The template must have been precomputed
4709  */
4710  if (comp->templ == NULL) {
4711  comp->templ = xsltFindTemplate(ctxt, comp->name, comp->ns);
4712  if (comp->templ == NULL) {
4713  if (comp->ns != NULL) {
4714  xsltTransformError(ctxt, NULL, inst,
4715  "The called template '{%s}%s' was not found.\n",
4716  comp->ns, comp->name);
4717  } else {
4718  xsltTransformError(ctxt, NULL, inst,
4719  "The called template '%s' was not found.\n",
4720  comp->name);
4721  }
4722  return;
4723  }
4724  }
4725 
4726 #ifdef WITH_XSLT_DEBUG_PROCESS
4727  if ((comp != NULL) && (comp->name != NULL))
4729  "call-template: name %s\n", comp->name));
4730 #endif
4731 
4732  if (inst->children) {
4733  xmlNodePtr cur;
4735 
4736  cur = inst->children;
4737  while (cur != NULL) {
4738 #ifdef WITH_DEBUGGER
4739  if (ctxt->debugStatus != XSLT_DEBUG_NONE)
4740  xslHandleDebugger(cur, node, comp->templ, ctxt);
4741 #endif
4742  if (ctxt->state == XSLT_STATE_STOPPED) break;
4743  /*
4744  * TODO: The "with-param"s could be part of the "call-template"
4745  * structure. Avoid to "search" for params dynamically
4746  * in the XML tree every time.
4747  */
4748  if (IS_XSLT_ELEM(cur)) {
4749  if (IS_XSLT_NAME(cur, "with-param")) {
4751  if (param != NULL) {
4752  param->next = withParams;
4753  withParams = param;
4754  }
4755  } else {
4757  "xsl:call-template: misplaced xsl:%s\n", cur->name);
4758  }
4759  } else {
4761  "xsl:call-template: misplaced %s element\n", cur->name);
4762  }
4763  cur = cur->next;
4764  }
4765  }
4766  /*
4767  * Create a new frame using the params first
4768  */
4769  xsltApplyXSLTTemplate(ctxt, node, comp->templ->content, comp->templ,
4770  withParams);
4771  if (withParams != NULL)
4772  xsltFreeStackElemList(withParams);
4773 
4774 #ifdef WITH_XSLT_DEBUG_PROCESS
4775  if ((comp != NULL) && (comp->name != NULL))
4777  "call-template returned: name %s\n", comp->name));
4778 #endif
4779 }
const xmlChar * name
Definition: tree.h:492
xsltTemplatePtr xsltFindTemplate(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: imports.c:356
const xmlChar * ns
xmlNodePtr content
static void xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ, xsltStackElemPtr withParams)
Definition: transform.c:3047
xsltStackElemPtr xsltParseStylesheetCallerParam(xsltTransformContextPtr ctxt, xmlNodePtr inst)
Definition: variables.c:1957
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:502
xsltTransformState state
smooth NULL
Definition: ftsmooth.c:416
xsltTemplatePtr templ
void * xsltGenericDebugContext
Definition: xsltutils.c:549
GLfloat param
Definition: glext.h:5796
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
void * xsltGenericErrorContext
Definition: xsltutils.c:503
Definition: tree.h:489
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
void xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
Definition: xsltutils.c:2422
xsltStylePreComp * xsltStylePreCompPtr
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:606
struct _xmlNode * next
Definition: tree.h:496
const xmlChar * name
struct _xmlNode * children
Definition: tree.h:493
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:63
Definition: dlist.c:348

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 5168 of file transform.c.

5170 {
5171  xmlNodePtr cur;
5172 
5173  if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
5174  return;
5175 
5176  /*
5177  * TODO: Content model checks should be done only at compilation
5178  * time.
5179  */
5180  cur = inst->children;
5181  if (cur == NULL) {
5182  xsltTransformError(ctxt, NULL, inst,
5183  "xsl:choose: The instruction has no content.\n");
5184  return;
5185  }
5186 
5187 #ifdef XSLT_REFACTORED
5188  /*
5189  * We don't check the content model during transformation.
5190  */
5191 #else
5192  if ((! IS_XSLT_ELEM(cur)) || (! IS_XSLT_NAME(cur, "when"))) {
5193  xsltTransformError(ctxt, NULL, inst,
5194  "xsl:choose: xsl:when expected first\n");
5195  return;
5196  }
5197 #endif
5198 
5199  {
5200  int testRes = 0, res = 0;
5201 
5202 #ifdef XSLT_REFACTORED
5203  xsltStyleItemWhenPtr wcomp = NULL;
5204 #else
5205  xsltStylePreCompPtr wcomp = NULL;
5206 #endif
5207 
5208  /*
5209  * Process xsl:when ---------------------------------------------------
5210  */
5211  while (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "when")) {
5212  wcomp = cur->psvi;
5213 
5214  if ((wcomp == NULL) || (wcomp->test == NULL) ||
5215  (wcomp->comp == NULL))
5216  {
5217  xsltTransformError(ctxt, NULL, cur,
5218  "Internal error in xsltChoose(): "
5219  "The XSLT 'when' instruction was not compiled.\n");
5220  goto error;
5221  }
5222 
5223 
5224 #ifdef WITH_DEBUGGER
5226  /*
5227  * TODO: Isn't comp->templ always NULL for xsl:choose?
5228  */
5229  xslHandleDebugger(cur, contextNode, NULL, ctxt);
5230  }
5231 #endif
5232 #ifdef WITH_XSLT_DEBUG_PROCESS
5234  "xsltChoose: test %s\n", wcomp->test));
5235 #endif
5236 
5237 #ifdef XSLT_FAST_IF
5238  res = xsltPreCompEvalToBoolean(ctxt, contextNode, wcomp);
5239 
5240  if (res == -1) {
5241  ctxt->state = XSLT_STATE_STOPPED;
5242  goto error;
5243  }
5244  testRes = (res == 1) ? 1 : 0;
5245 
5246 #else /* XSLT_FAST_IF */
5247 
5248  res = xsltPreCompEval(ctxt, cotextNode, wcomp);
5249 
5250  if (res != NULL) {
5251  if (res->type != XPATH_BOOLEAN)
5252  res = xmlXPathConvertBoolean(res);
5253  if (res->type == XPATH_BOOLEAN)
5254  testRes = res->boolval;
5255  else {
5256 #ifdef WITH_XSLT_DEBUG_PROCESS
5258  "xsltChoose: test didn't evaluate to a boolean\n"));
5259 #endif
5260  goto error;
5261  }
5262  xmlXPathFreeObject(res);
5263  res = NULL;
5264  } else {
5265  ctxt->state = XSLT_STATE_STOPPED;
5266  goto error;
5267  }
5268 
5269 #endif /* else of XSLT_FAST_IF */
5270 
5271 #ifdef WITH_XSLT_DEBUG_PROCESS
5273  "xsltChoose: test evaluate to %d\n", testRes));
5274 #endif
5275  if (testRes)
5276  goto test_is_true;
5277 
5278  cur = cur->next;
5279  }
5280 
5281  /*
5282  * Process xsl:otherwise ----------------------------------------------
5283  */
5284  if (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "otherwise")) {
5285 
5286 #ifdef WITH_DEBUGGER
5288  xslHandleDebugger(cur, contextNode, NULL, ctxt);
5289 #endif
5290 
5291 #ifdef WITH_XSLT_DEBUG_PROCESS
5293  "evaluating xsl:otherwise\n"));
5294 #endif
5295  goto test_is_true;
5296  }
5297  goto exit;
5298 
5299 test_is_true:
5300 
5301  goto process_sequence;
5302  }
5303 
5304 process_sequence:
5305 
5306  /*
5307  * Instantiate the sequence constructor.
5308  */
5309  xsltApplySequenceConstructor(ctxt, ctxt->node, cur->children,
5310  NULL);
5311 
5312 exit:
5313 error:
5314  return;
5315 }
void * psvi
Definition: tree.h:505
#define error(str)
Definition: mkdosfs.c:1605
const xmlChar * test
int xslDebugStatus
Definition: xsltutils.c:2357
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
xsltTransformState state
smooth NULL
Definition: ftsmooth.c:416
static xmlXPathObjectPtr xsltPreCompEval(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:317
static int xsltPreCompEvalToBoolean(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:366
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
void xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
Definition: xsltutils.c:2422
struct _xmlNode * next
Definition: tree.h:496
xmlXPathCompExprPtr comp
struct _xmlNode * children
Definition: tree.h:493
GLuint res
Definition: glext.h:9613
void exit(int exitcode)
Definition: _exit.c:33
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:63

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 4234 of file transform.c.

4235  {
4236  xmlChar *value = NULL;
4237  xmlNodePtr commentNode;
4238  int len;
4239 
4240  value = xsltEvalTemplateString(ctxt, node, inst);
4241  /* TODO: use or generate the compiled form */
4242  len = xmlStrlen(value);
4243  if (len > 0) {
4244  if ((value[len-1] == '-') ||
4245  (xmlStrstr(value, BAD_CAST "--"))) {
4246  xsltTransformError(ctxt, NULL, inst,
4247  "xsl:comment : '--' or ending '-' not allowed in comment\n");
4248  /* fall through to try to catch further errors */
4249  }
4250  }
4251 #ifdef WITH_XSLT_DEBUG_PROCESS
4252  if (value == NULL) {
4254  "xsltComment: empty\n"));
4255  } else {
4257  "xsltComment: content %s\n", value));
4258  }
4259 #endif
4260 
4261  commentNode = xmlNewComment(value);
4262  commentNode = xsltAddChild(ctxt->insert, commentNode);
4263 
4264  if (value != NULL)
4265  xmlFree(value);
4266 }
XMLPUBFUN const xmlChar *XMLCALL xmlStrstr(const xmlChar *str, const xmlChar *val)
Definition: xmlstring.c:341
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:748
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
XMLPUBFUN xmlNodePtr XMLCALL xmlNewComment(const xmlChar *content)
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlChar * xsltEvalTemplateString(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst)
Definition: templates.c:189
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Definition: dlist.c:348

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 3870 of file transform.c.

3872 {
3873 #ifdef XSLT_REFACTORED
3874  xsltStyleItemCopyPtr comp = (xsltStyleItemCopyPtr) castedComp;
3875 #else
3876  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
3877 #endif
3878  xmlNodePtr copy, oldInsert;
3879 
3880  oldInsert = ctxt->insert;
3881  if (ctxt->insert != NULL) {
3882  switch (node->type) {
3883  case XML_TEXT_NODE:
3885  /*
3886  * This text comes from the stylesheet
3887  * For stylesheets, the set of whitespace-preserving
3888  * element names consists of just xsl:text.
3889  */
3890 #ifdef WITH_XSLT_DEBUG_PROCESS
3891  if (node->type == XML_CDATA_SECTION_NODE) {
3893  "xsltCopy: CDATA text %s\n", node->content));
3894  } else {
3896  "xsltCopy: text %s\n", node->content));
3897  }
3898 #endif
3899  xsltCopyText(ctxt, ctxt->insert, node, 0);
3900  break;
3901  case XML_DOCUMENT_NODE:
3903  break;
3904  case XML_ELEMENT_NODE:
3905  /*
3906  * REVISIT NOTE: The "fake" is a doc-node, not an element node.
3907  * REMOVED:
3908  * if (xmlStrEqual(node->name, BAD_CAST " fake node libxslt"))
3909  * return;
3910  */
3911 
3912 #ifdef WITH_XSLT_DEBUG_PROCESS
3914  "xsltCopy: node %s\n", node->name));
3915 #endif
3916  copy = xsltShallowCopyElem(ctxt, node, ctxt->insert, 0);
3917  ctxt->insert = copy;
3918  if (comp->use != NULL) {
3919  xsltApplyAttributeSet(ctxt, node, inst, comp->use);
3920  }
3921  break;
3922  case XML_ATTRIBUTE_NODE: {
3923 #ifdef WITH_XSLT_DEBUG_PROCESS
3925  "xsltCopy: attribute %s\n", node->name));
3926 #endif
3927  /*
3928  * REVISIT: We could also raise an error if the parent is not
3929  * an element node.
3930  * OPTIMIZE TODO: Can we set the value/children of the
3931  * attribute without an intermediate copy of the string value?
3932  */
3933  xsltShallowCopyAttr(ctxt, inst, ctxt->insert, (xmlAttrPtr) node);
3934  break;
3935  }
3936  case XML_PI_NODE:
3937 #ifdef WITH_XSLT_DEBUG_PROCESS
3939  "xsltCopy: PI %s\n", node->name));
3940 #endif
3941  copy = xmlNewDocPI(ctxt->insert->doc, node->name,
3942  node->content);
3943  copy = xsltAddChild(ctxt->insert, copy);
3944  break;
3945  case XML_COMMENT_NODE:
3946 #ifdef WITH_XSLT_DEBUG_PROCESS
3948  "xsltCopy: comment\n"));
3949 #endif
3950  copy = xmlNewComment(node->content);
3951  copy = xsltAddChild(ctxt->insert, copy);
3952  break;
3953  case XML_NAMESPACE_DECL:
3954 #ifdef WITH_XSLT_DEBUG_PROCESS
3956  "xsltCopy: namespace declaration\n"));
3957 #endif
3958  xsltShallowCopyNsNode(ctxt, inst, ctxt->insert, (xmlNsPtr)node);
3959  break;
3960  default:
3961  break;
3962 
3963  }
3964  }
3965 
3966  switch (node->type) {
3967  case XML_DOCUMENT_NODE:
3969  case XML_ELEMENT_NODE:
3970  xsltApplySequenceConstructor(ctxt, ctxt->node, inst->children,
3971  NULL);
3972  break;
3973  default:
3974  break;
3975  }
3976  ctxt->insert = oldInsert;
3977 }
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:748
const xmlChar * use
Definition: tree.h:389
static xmlNodePtr xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target, xmlNodePtr cur, int interned)
Definition: transform.c:942
struct _xmlDoc * doc
Definition: tree.h:498
static xmlAttrPtr xsltShallowCopyAttr(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr target, xmlAttrPtr attr)
Definition: transform.c:1116
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content)
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
void xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, const xmlChar *attrSets)
Definition: attributes.c:1086
XMLPUBFUN xmlNodePtr XMLCALL xmlNewComment(const xmlChar *content)
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
xsltStylePreComp * xsltStylePreCompPtr
static xmlNodePtr xsltShallowCopyElem(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr insert, int isLRE)
Definition: transform.c:1291
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
struct _xmlNode * children
Definition: tree.h:493
Definition: tree.h:434
static xmlNsPtr xsltShallowCopyNsNode(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr insert, xmlNsPtr ns)
Definition: transform.c:1476
Definition: dlist.c:348

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 4344 of file transform.c.

4345  {
4346 #ifdef XSLT_REFACTORED
4347  xsltStyleItemCopyOfPtr comp = (xsltStyleItemCopyOfPtr) castedComp;
4348 #else
4349  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4350 #endif
4351  xmlXPathObjectPtr res = NULL;
4352  xmlNodeSetPtr list = NULL;
4353  int i;
4354 
4355  if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
4356  return;
4357  if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
4358  xsltTransformError(ctxt, NULL, inst,
4359  "xsl:copy-of : compilation failed\n");
4360  return;
4361  }
4362 
4363  /*
4364  * SPEC XSLT 1.0:
4365  * "The xsl:copy-of element can be used to insert a result tree
4366  * fragment into the result tree, without first converting it to
4367  * a string as xsl:value-of does (see [7.6.1 Generating Text with
4368  * xsl:value-of]). The required select attribute contains an
4369  * expression. When the result of evaluating the expression is a
4370  * result tree fragment, the complete fragment is copied into the
4371  * result tree. When the result is a node-set, all the nodes in the
4372  * set are copied in document order into the result tree; copying
4373  * an element node copies the attribute nodes, namespace nodes and
4374  * children of the element node as well as the element node itself;
4375  * a root node is copied by copying its children. When the result
4376  * is neither a node-set nor a result tree fragment, the result is
4377  * converted to a string and then inserted into the result tree,
4378  * as with xsl:value-of.
4379  */
4380 
4381 #ifdef WITH_XSLT_DEBUG_PROCESS
4383  "xsltCopyOf: select %s\n", comp->select));
4384 #endif
4385 
4386  /*
4387  * Evaluate the "select" expression.
4388  */
4389  res = xsltPreCompEval(ctxt, node, comp);
4390 
4391  if (res != NULL) {
4392  if (res->type == XPATH_NODESET) {
4393  /*
4394  * Node-set
4395  * --------
4396  */
4397 #ifdef WITH_XSLT_DEBUG_PROCESS
4399  "xsltCopyOf: result is a node set\n"));
4400 #endif
4401  list = res->nodesetval;
4402  if (list != NULL) {
4403  xmlNodePtr cur;
4404  /*
4405  * The list is already sorted in document order by XPath.
4406  * Append everything in this order under ctxt->insert.
4407  */
4408  for (i = 0;i < list->nodeNr;i++) {
4409  cur = list->nodeTab[i];
4410  if (cur == NULL)
4411  continue;
4412  if ((cur->type == XML_DOCUMENT_NODE) ||
4413  (cur->type == XML_HTML_DOCUMENT_NODE))
4414  {
4415  xsltCopyTreeList(ctxt, inst,
4416  cur->children, ctxt->insert, 0, 0);
4417  } else if (cur->type == XML_ATTRIBUTE_NODE) {
4418  xsltShallowCopyAttr(ctxt, inst,
4419  ctxt->insert, (xmlAttrPtr) cur);
4420  } else {
4421  xsltCopyTree(ctxt, inst, cur, ctxt->insert, 0, 0);
4422  }
4423  }
4424  }
4425  } else if (res->type == XPATH_XSLT_TREE) {
4426  /*
4427  * Result tree fragment
4428  * --------------------
4429  * E.g. via <xsl:variable ...><foo/></xsl:variable>
4430  * Note that the root node of such trees is an xmlDocPtr in Libxslt.
4431  */
4432 #ifdef WITH_XSLT_DEBUG_PROCESS
4434  "xsltCopyOf: result is a result tree fragment\n"));
4435 #endif
4436  list = res->nodesetval;
4437  if ((list != NULL) && (list->nodeTab != NULL) &&
4438  (list->nodeTab[0] != NULL) &&
4439  (IS_XSLT_REAL_NODE(list->nodeTab[0])))
4440  {
4441  xsltCopyTreeList(ctxt, inst,
4442  list->nodeTab[0]->children, ctxt->insert, 0, 0);
4443  }
4444  } else {
4445  xmlChar *value = NULL;
4446  /*
4447  * Convert to a string.
4448  */
4449  value = xmlXPathCastToString(res);
4450  if (value == NULL) {
4451  xsltTransformError(ctxt, NULL, inst,
4452  "Internal error in xsltCopyOf(): "
4453  "failed to cast an XPath object to string.\n");
4454  ctxt->state = XSLT_STATE_STOPPED;
4455  } else {
4456  if (value[0] != 0) {
4457  /*
4458  * Append content as text node.
4459  */
4460  xsltCopyTextString(ctxt, ctxt->insert, value, 0);
4461  }
4462  xmlFree(value);
4463 
4464 #ifdef WITH_XSLT_DEBUG_PROCESS
4466  "xsltCopyOf: result %s\n", res->stringval));
4467 #endif
4468  }
4469  }
4470  } else {
4471  ctxt->state = XSLT_STATE_STOPPED;
4472  }
4473 
4474  if (res != NULL)
4475  xmlXPathFreeObject(res);
4476 }
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
static xmlNodePtr xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr node, xmlNodePtr insert, int isLRE, int topElemVisited)
Definition: transform.c:1587
xsltTransformState state
static xmlAttrPtr xsltShallowCopyAttr(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr target, xmlAttrPtr attr)
Definition: transform.c:1116
smooth NULL
Definition: ftsmooth.c:416
xmlNodePtr xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int noescape)
Definition: transform.c:846
static xmlXPathObjectPtr xsltPreCompEval(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:317
void * xsltGenericDebugContext
Definition: xsltutils.c:549
#define IS_XSLT_REAL_NODE(n)
Definition: xsltutils.h:71
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
unsigned char xmlChar
Definition: xmlstring.h:28
Definition: _list.h:228
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlElementType type
Definition: tree.h:491
xsltStylePreComp * xsltStylePreCompPtr
xmlXPathCompExprPtr comp
const xmlChar * select
struct _xmlNode * children
Definition: tree.h:493
Definition: tree.h:434
GLuint res
Definition: glext.h:9613
static xmlNodePtr xsltCopyTreeList(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr list, xmlNodePtr insert, int isLRE, int topElemVisited)
Definition: transform.c:1383
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Definition: dlist.c:348

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 846 of file transform.c.

848 {
850  int len;
851 
852  if (string == NULL)
853  return(NULL);
854 
855 #ifdef WITH_XSLT_DEBUG_PROCESS
857  "xsltCopyTextString: copy text %s\n",
858  string));
859 #endif
860 
861  /*
862  * Play safe and reset the merging mechanism for every new
863  * target node.
864  */
865  if ((target == NULL) || (target->children == NULL)) {
866  ctxt->lasttext = NULL;
867  }
868 
869  /* handle coalescing of text nodes here */
870  len = xmlStrlen(string);
871  if ((ctxt->type == XSLT_OUTPUT_XML) &&
872  (ctxt->style->cdataSection != NULL) &&
873  (target != NULL) &&
874  (target->type == XML_ELEMENT_NODE) &&
875  (((target->ns == NULL) &&
877  target->name, NULL) != NULL)) ||
878  ((target->ns != NULL) &&
880  target->name, target->ns->href) != NULL))))
881  {
882  /*
883  * Process "cdata-section-elements".
884  */
885  if ((target->last != NULL) &&
886  (target->last->type == XML_CDATA_SECTION_NODE))
887  {
888  return(xsltAddTextString(ctxt, target->last, string, len));
889  }
890  copy = xmlNewCDataBlock(ctxt->output, string, len);
891  } else if (noescape) {
892  /*
893  * Process "disable-output-escaping".
894  */
895  if ((target != NULL) && (target->last != NULL) &&
896  (target->last->type == XML_TEXT_NODE) &&
897  (target->last->name == xmlStringTextNoenc))
898  {
899  return(xsltAddTextString(ctxt, target->last, string, len));
900  }
901  copy = xmlNewTextLen(string, len);
902  if (copy != NULL)
903  copy->name = xmlStringTextNoenc;
904  } else {
905  /*
906  * Default processing.
907  */
908  if ((target != NULL) && (target->last != NULL) &&
909  (target->last->type == XML_TEXT_NODE) &&
910  (target->last->name == xmlStringText)) {
911  return(xsltAddTextString(ctxt, target->last, string, len));
912  }
913  copy = xmlNewTextLen(string, len);
914  }
915  if (copy != NULL && target != NULL)
917  if (copy != NULL) {
918  ctxt->lasttext = copy->content;
919  ctxt->lasttsize = len;
920  ctxt->lasttuse = len;
921  } else {
923  "xsltCopyTextString: text copy failed\n");
924  ctxt->lasttext = NULL;
925  }
926  return(copy);
927 }
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:748
XMLPUBFUN xmlNodePtr XMLCALL xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len)
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:474
XMLPUBVAR const xmlChar xmlStringText[]
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
xmlHashTablePtr cdataSection
const xmlChar * lasttext
GLenum GLsizei len
Definition: glext.h:6722
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xsltStylesheetPtr style
static xmlNodePtr xsltAddTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int len)
Definition: transform.c:774
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
XMLPUBVAR const xmlChar xmlStringTextNoenc[]
GLenum target
Definition: glext.h:7315
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
XMLPUBFUN xmlNodePtr XMLCALL xmlNewTextLen(const xmlChar *content, int len)

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 3335 of file transform.c.

3337 {
3338 #ifdef XSLT_REFACTORED
3339  xsltStyleItemDocumentPtr comp = (xsltStyleItemDocumentPtr) castedComp;
3340 #else
3341  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
3342 #endif
3344  int ret;
3345  xmlChar *filename = NULL, *prop, *elements;
3346  xmlChar *element, *end;
3347  xmlDocPtr res = NULL;
3348  xmlDocPtr oldOutput;
3349  xmlNodePtr oldInsert, root;
3350  const char *oldOutputFile;
3351  xsltOutputType oldType;
3352  xmlChar *URL = NULL;
3353  const xmlChar *method;
3354  const xmlChar *doctypePublic;
3355  const xmlChar *doctypeSystem;
3356  const xmlChar *version;
3357  const xmlChar *encoding;
3358  int redirect_write_append = 0;
3359 
3360  if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
3361  return;
3362 
3363  if (comp->filename == NULL) {
3364 
3365  if (xmlStrEqual(inst->name, (const xmlChar *) "output")) {
3366  /*
3367  * The element "output" is in the namespace XSLT_SAXON_NAMESPACE
3368  * (http://icl.com/saxon)
3369  * The @file is in no namespace.
3370  */
3371 #ifdef WITH_XSLT_DEBUG_EXTRA
3373  "Found saxon:output extension\n");
3374 #endif
3375  URL = xsltEvalAttrValueTemplate(ctxt, inst,
3376  (const xmlChar *) "file",
3378 
3379  if (URL == NULL)
3380  URL = xsltEvalAttrValueTemplate(ctxt, inst,
3381  (const xmlChar *) "href",
3383  } else if (xmlStrEqual(inst->name, (const xmlChar *) "write")) {
3384 #ifdef WITH_XSLT_DEBUG_EXTRA
3386  "Found xalan:write extension\n");
3387 #endif
3388  URL = xsltEvalAttrValueTemplate(ctxt, inst,
3389  (const xmlChar *)
3390  "select",
3392  if (URL != NULL) {
3393  xmlXPathCompExprPtr cmp;
3394  xmlChar *val;
3395 
3396  /*
3397  * Trying to handle bug #59212
3398  * The value of the "select" attribute is an
3399  * XPath expression.
3400  * (see http://xml.apache.org/xalan-j/extensionslib.html#redirect)
3401  */
3402  cmp = xmlXPathCompile(URL);
3403  val = xsltEvalXPathString(ctxt, cmp);
3404  xmlXPathFreeCompExpr(cmp);
3405  xmlFree(URL);
3406  URL = val;
3407  }
3408  if (URL == NULL)
3409  URL = xsltEvalAttrValueTemplate(ctxt, inst,
3410  (const xmlChar *)
3411  "file",
3413  if (URL == NULL)
3414  URL = xsltEvalAttrValueTemplate(ctxt, inst,
3415  (const xmlChar *)
3416  "href",
3418  } else if (xmlStrEqual(inst->name, (const xmlChar *) "document")) {
3419  URL = xsltEvalAttrValueTemplate(ctxt, inst,
3420  (const xmlChar *) "href",
3421  NULL);
3422  }
3423 
3424  } else {
3425  URL = xmlStrdup(comp->filename);
3426  }
3427 
3428  if (URL == NULL) {
3429  xsltTransformError(ctxt, NULL, inst,
3430  "xsltDocumentElem: href/URI-Reference not found\n");
3431  return;
3432  }
3433 
3434  /*
3435  * If the computation failed, it's likely that the URL wasn't escaped
3436  */
3437  filename = xmlBuildURI(URL, (const xmlChar *) ctxt->outputFile);
3438  if (filename == NULL) {
3439  xmlChar *escURL;
3440 
3441  escURL=xmlURIEscapeStr(URL, BAD_CAST ":/.?,");
3442  if (escURL != NULL) {
3443  filename = xmlBuildURI(escURL, (const xmlChar *) ctxt->outputFile);
3444  xmlFree(escURL);
3445  }
3446  }
3447 
3448  if (filename == NULL) {
3449  xsltTransformError(ctxt, NULL, inst,
3450  "xsltDocumentElem: URL computation failed for %s\n",
3451  URL);
3452  xmlFree(URL);
3453  return;
3454  }
3455 
3456  /*
3457  * Security checking: can we write to this resource
3458  */
3459  if (ctxt->sec != NULL) {
3460  ret = xsltCheckWrite(ctxt->sec, ctxt, filename);
3461  if (ret == 0) {
3462  xsltTransformError(ctxt, NULL, inst,
3463  "xsltDocumentElem: write rights for %s denied\n",
3464  filename);
3465  xmlFree(URL);
3466  xmlFree(filename);
3467  return;
3468  }
3469  }
3470 
3471  oldOutputFile = ctxt->outputFile;
3472  oldOutput = ctxt->output;
3473  oldInsert = ctxt->insert;
3474  oldType = ctxt->type;
3475  ctxt->outputFile = (const char *) filename;
3476 
3478  if (style == NULL) {
3479  xsltTransformError(ctxt, NULL, inst,
3480  "xsltDocumentElem: out of memory\n");
3481  goto error;
3482  }
3483 
3484  /*
3485  * Version described in 1.1 draft allows full parameterization
3486  * of the output.
3487  */
3488  prop = xsltEvalAttrValueTemplate(ctxt, inst,
3489  (const xmlChar *) "version",
3490  NULL);
3491  if (prop != NULL) {
3492  if (style->version != NULL)
3493  xmlFree(style->version);
3494  style->version = prop;
3495  }
3496  prop = xsltEvalAttrValueTemplate(ctxt, inst,
3497  (const xmlChar *) "encoding",
3498  NULL);
3499  if (prop != NULL) {
3500  if (style->encoding != NULL)
3501  xmlFree(style->encoding);
3502  style->encoding = prop;
3503  }
3504  prop = xsltEvalAttrValueTemplate(ctxt, inst,
3505  (const xmlChar *) "method",
3506  NULL);
3507  if (prop != NULL) {
3508  const xmlChar *URI;
3509 
3510  if (style->method != NULL)
3511  xmlFree(style->method);
3512  style->method = NULL;
3513  if (style->methodURI != NULL)
3514  xmlFree(style->methodURI);
3515  style->methodURI = NULL;
3516 
3517  URI = xsltGetQNameURI(inst, &prop);
3518  if (prop == NULL) {
3519  if (style != NULL) style->errors++;
3520  } else if (URI == NULL) {
3521  if ((xmlStrEqual(prop, (const xmlChar *) "xml")) ||
3522  (xmlStrEqual(prop, (const xmlChar *) "html")) ||
3523  (xmlStrEqual(prop, (const xmlChar *) "text"))) {
3524  style->method = prop;
3525  } else {
3526  xsltTransformError(ctxt, NULL, inst,
3527  "invalid value for method: %s\n", prop);
3528  if (style != NULL) style->warnings++;
3529  }
3530  } else {
3531  style->method = prop;
3532  style->methodURI = xmlStrdup(URI);
3533  }
3534  }
3535  prop = xsltEvalAttrValueTemplate(ctxt, inst,
3536  (const xmlChar *)
3537  "doctype-system", NULL);
3538  if (prop != NULL) {
3539  if (style->doctypeSystem != NULL)
3540  xmlFree(style->doctypeSystem);
3541  style->doctypeSystem = prop;
3542  }
3543  prop = xsltEvalAttrValueTemplate(ctxt, inst,
3544  (const xmlChar *)
3545  "doctype-public", NULL);
3546  if (prop != NULL) {
3547  if (style->doctypePublic != NULL)
3548  xmlFree(style->doctypePublic);
3549  style->doctypePublic = prop;
3550  }
3551  prop = xsltEvalAttrValueTemplate(ctxt, inst,
3552  (const xmlChar *) "standalone",
3553  NULL);
3554  if (prop != NULL) {
3555  if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
3556  style->standalone = 1;
3557  } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
3558  style->standalone = 0;
3559  } else {
3560  xsltTransformError(ctxt, NULL, inst,
3561  "invalid value for standalone: %s\n",
3562  prop);
3563  if (style != NULL) style->warnings++;
3564  }
3565  xmlFree(prop);
3566  }
3567 
3568  prop = xsltEvalAttrValueTemplate(ctxt, inst,
3569  (const xmlChar *) "indent",
3570  NULL);
3571  if (prop != NULL) {
3572  if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
3573  style->indent = 1;
3574  } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
3575  style->indent = 0;
3576  } else {
3577  xsltTransformError(ctxt, NULL, inst,
3578  "invalid value for indent: %s\n", prop);
3579  if (style != NULL) style->warnings++;
3580  }
3581  xmlFree(prop);
3582  }
3583 
3584  prop = xsltEvalAttrValueTemplate(ctxt, inst,
3585  (const xmlChar *)
3586  "omit-xml-declaration",
3587  NULL);
3588  if (prop != NULL) {
3589  if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
3590  style->omitXmlDeclaration = 1;
3591  } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
3592  style->omitXmlDeclaration = 0;
3593  } else {
3594  xsltTransformError(ctxt, NULL, inst,
3595  "invalid value for omit-xml-declaration: %s\n",
3596  prop);
3597  if (style != NULL) style->warnings++;
3598  }
3599  xmlFree(prop);
3600  }
3601 
3602  elements = xsltEvalAttrValueTemplate(ctxt, inst,
3603  (const xmlChar *)
3604  "cdata-section-elements",
3605  NULL);
3606  if (elements != NULL) {
3607  if (style->stripSpaces == NULL)
3608  style->stripSpaces = xmlHashCreate(10);
3609  if (style->stripSpaces == NULL)
3610  return;
3611 
3612  element = elements;
3613  while (*element != 0) {
3614  while (IS_BLANK_CH(*element))
3615  element++;
3616  if (*element == 0)
3617  break;
3618  end = element;
3619  while ((*end != 0) && (!IS_BLANK_CH(*end)))
3620  end++;
3622  if (element) {
3623  const xmlChar *URI;
3624 
3625 #ifdef WITH_XSLT_DEBUG_PARSING
3627  "add cdata section output element %s\n",
3628  element);
3629 #endif
3630  URI = xsltGetQNameURI(inst, &element);
3631 
3632  xmlHashAddEntry2(style->stripSpaces, element, URI,
3633  (xmlChar *) "cdata");
3634  xmlFree(element);
3635  }
3636  element = end;
3637  }
3638  xmlFree(elements);
3639  }
3640 
3641  /*
3642  * Create a new document tree and process the element template
3643  */
3645  XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
3646  XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
3649 
3650  if ((method != NULL) &&
3651  (!xmlStrEqual(method, (const xmlChar *) "xml"))) {
3652  if (xmlStrEqual(method, (const xmlChar *) "html")) {
3653  ctxt->type = XSLT_OUTPUT_HTML;
3654  if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
3655  res = htmlNewDoc(doctypeSystem, doctypePublic);
3656  else {
3657  if (version != NULL) {
3658 #ifdef XSLT_GENERATE_HTML_DOCTYPE
3659  xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem);
3660 #endif
3661  }
3662  res = htmlNewDocNoDtD(doctypeSystem, doctypePublic);
3663  }
3664  if (res == NULL)
3665  goto error;
3666  res->dict = ctxt->dict;
3667  xmlDictReference(res->dict);
3668  } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
3669  xsltTransformError(ctxt, NULL, inst,
3670  "xsltDocumentElem: unsupported method xhtml\n");
3671  ctxt->type = XSLT_OUTPUT_HTML;
3672  res = htmlNewDocNoDtD(doctypeSystem, doctypePublic);
3673  if (res == NULL)
3674  goto error;
3675  res->dict = ctxt->dict;
3676  xmlDictReference(res->dict);
3677  } else if (xmlStrEqual(method, (const xmlChar *) "text")) {
3678  ctxt->type = XSLT_OUTPUT_TEXT;
3679  res = xmlNewDoc(style->version);
3680  if (res == NULL)
3681  goto error;
3682  res->dict = ctxt->dict;
3683  xmlDictReference(res->dict);
3684 #ifdef WITH_XSLT_DEBUG
3686  "reusing transformation dict for output\n");
3687 #endif
3688  } else {
3689  xsltTransformError(ctxt, NULL, inst,
3690  "xsltDocumentElem: unsupported method (%s)\n",
3691  method);
3692  goto error;
3693  }
3694  } else {
3695  ctxt->type = XSLT_OUTPUT_XML;
3696  res = xmlNewDoc(style->version);
3697  if (res == NULL)
3698  goto error;
3699  res->dict = ctxt->dict;
3700  xmlDictReference(res->dict);
3701 #ifdef WITH_XSLT_DEBUG
3703  "reusing transformation dict for output\n");
3704 #endif
3705  }
3706  res->charset = XML_CHAR_ENCODING_UTF8;
3707  if (encoding != NULL)
3708  res->encoding = xmlStrdup(encoding);
3709  ctxt->output = res;
3710  ctxt->insert = (xmlNodePtr) res;
3712 
3713  /*
3714  * Do some post processing work depending on the generated output
3715  */
3717  if (root != NULL) {
3718  const xmlChar *doctype = NULL;
3719 
3720  if ((root->ns != NULL) && (root->ns->prefix != NULL))
3721  doctype = xmlDictQLookup(ctxt->dict, root->ns->prefix, root->name);
3722  if (doctype == NULL)
3723  doctype = root->name;
3724 
3725  /*
3726  * Apply the default selection of the method
3727  */
3728  if ((method == NULL) &&
3729  (root->ns == NULL) &&
3730  (!xmlStrcasecmp(root->name, (const xmlChar *) "html"))) {
3731  xmlNodePtr tmp;
3732 
3733  tmp = res->children;
3734  while ((tmp != NULL) && (tmp != root)) {
3735  if (tmp->type == XML_ELEMENT_NODE)
3736  break;
3737  if ((tmp->type == XML_TEXT_NODE) && (!xmlIsBlankNode(tmp)))
3738  break;
3739  tmp = tmp->next;
3740  }
3741  if (tmp == root) {
3742  ctxt->type = XSLT_OUTPUT_HTML;
3743  res->type = XML_HTML_DOCUMENT_NODE;
3744  if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
3745  res->intSubset = xmlCreateIntSubset(res, doctype,
3746  doctypePublic,
3747  doctypeSystem);
3748 #ifdef XSLT_GENERATE_HTML_DOCTYPE
3749  } else if (version != NULL) {
3750  xsltGetHTMLIDs(version, &doctypePublic,
3751  &doctypeSystem);
3752  if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
3753  res->intSubset =
3754  xmlCreateIntSubset(res, doctype,
3755  doctypePublic,
3756  doctypeSystem);
3757 #endif
3758  }
3759  }
3760 
3761  }
3762  if (ctxt->type == XSLT_OUTPUT_XML) {
3763  XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
3764  XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
3765  if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
3766  res->intSubset = xmlCreateIntSubset(res, doctype,
3767  doctypePublic,
3768  doctypeSystem);
3769  }
3770  }
3771 
3772  /*
3773  * Calls to redirect:write also take an optional attribute append.
3774  * Attribute append="true|yes" which will attempt to simply append
3775  * to an existing file instead of always opening a new file. The
3776  * default behavior of always overwriting the file still happens
3777  * if we do not specify append.
3778  * Note that append use will forbid use of remote URI target.
3779  */
3780  prop = xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *)"append",
3781  NULL);
3782  if (prop != NULL) {
3783  if (xmlStrEqual(prop, (const xmlChar *) "true") ||
3784  xmlStrEqual(prop, (const xmlChar *) "yes")) {
3785  style->omitXmlDeclaration = 1;
3786  redirect_write_append = 1;
3787  } else
3788  style->omitXmlDeclaration = 0;
3789  xmlFree(prop);
3790  }
3791 
3792  if (redirect_write_append) {
3793  FILE *f;
3794 
3795  f = fopen((const char *) filename, "ab");
3796  if (f == NULL) {
3797  ret = -1;
3798  } else {
3800  fclose(f);
3801  }
3802  } else {
3803  ret = xsltSaveResultToFilename((const char *) filename, res, style, 0);
3804  }
3805  if (ret < 0) {
3806  xsltTransformError(ctxt, NULL, inst,
3807  "xsltDocumentElem: unable to save to %s\n",
3808  filename);
3809 #ifdef WITH_XSLT_DEBUG_EXTRA
3810  } else {
3812  "Wrote %d bytes to %s\n", ret, filename);
3813 #endif
3814  }
3815 
3816  error:
3817  ctxt->output = oldOutput;
3818  ctxt->insert = oldInsert;
3819  ctxt->type = oldType;
3820  ctxt->outputFile = oldOutputFile;
3821  if (URL != NULL)
3822  xmlFree(URL);
3823  if (filename != NULL)
3824  xmlFree(filename);
3825  if (style != NULL)
3827  if (res != NULL)
3828  xmlFreeDoc(res);
3829 }
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:934
static int xsltGetHTMLIDs(const xmlChar *version, const xmlChar **publicID, const xmlChar **systemID)
Definition: transform.c:5653
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:638
#define error(str)
Definition: mkdosfs.c:1605
const xmlChar * name
Definition: tree.h:492
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:41
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:404
struct _root root
XMLPUBFUN xmlChar *XMLCALL xmlURIEscapeStr(const xmlChar *str, const xmlChar *list)
Definition: uri.c:1670
xsltOutputType
XMLPUBFUN int XMLCALL xmlIsBlankNode(const xmlNode *node)
GLuint GLuint end
Definition: gl.h:1545
#define cmp(status, error)
Definition: error.c:114
const char * filename
Definition: ioapi.h:135
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:384
const xmlChar * filename
#define IS_BLANK_CH(c)
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1882
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:64
xmlNode * xmlNodePtr
Definition: tree.h:488
#define BAD_CAST
Definition: xmlstring.h:35
GLuint GLfloat * val
Definition: glext.h:7180
xmlChar * xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp)
Definition: templates.c:171
#define XSLT_SAXON_NAMESPACE
Definition: extra.h:34
GLfloat f
Definition: glext.h:7540
void * xsltGenericDebugContext
Definition: xsltutils.c:549
int xsltSaveResultToFile(FILE *file, xmlDocPtr result, xsltStylesheetPtr style)
Definition: xsltutils.c:1633
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
method
Definition: dragdrop.c:53
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreate(int size)
Definition: hash.c:174
Definition: tree.h:489
int ret
int xsltSaveResultToFilename(const char *URL, xmlDocPtr result, xsltStylesheetPtr style, int compression)
Definition: xsltutils.c:1589
unsigned char xmlChar
Definition: xmlstring.h:28
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
XMLPUBFUN const xmlChar *XMLCALL xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name)
Definition: dict.c:1106
xmlElementType type
Definition: tree.h:491
ed encoding
Definition: write.c:2847
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
xsltStylePreComp * xsltStylePreCompPtr
struct _xmlNode * next
Definition: tree.h:496
#define f
Definition: ke_i.h:83
XMLPUBFUN xmlDtdPtr XMLCALL xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
#define XSLT_GET_IMPORT_PTR(res, style, name)
Definition: imports.h:27
Definition: tree.h:551
int xsltCheckWrite(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:335
struct _xmlNode * children
Definition: tree.h:493
GLuint res
Definition: glext.h:9613
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#define XSLT_XALAN_NAMESPACE
Definition: extra.h:48
Arabic default style
Definition: afstyles.h:93
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
XMLPUBFUN int XMLCALL xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:271
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
Definition: dlist.c:348
xsltStylesheetPtr xsltNewStylesheet(void)
Definition: xslt.c:742
const xmlChar * xsltGetQNameURI(xmlNodePtr node, xmlChar **name)
Definition: xsltutils.c:753

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 4026 of file transform.c.

4027  {
4028 #ifdef XSLT_REFACTORED
4029  xsltStyleItemElementPtr comp = (xsltStyleItemElementPtr) castedComp;
4030 #else
4031  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4032 #endif
4033  xmlChar *prop = NULL;
4034  const xmlChar *name, *prefix = NULL, *nsName = NULL;
4035  xmlNodePtr copy;
4036  xmlNodePtr oldInsert;
4037 
4038  if (ctxt->insert == NULL)
4039  return;
4040 
4041  /*
4042  * A comp->has_name == 0 indicates that we need to skip this instruction,
4043  * since it was evaluated to be invalid already during compilation.
4044  */
4045  if (!comp->has_name)
4046  return;
4047 
4048  /*
4049  * stack and saves
4050  */
4051  oldInsert = ctxt->insert;
4052 
4053  if (comp->name == NULL) {
4054  /* TODO: fix attr acquisition wrt to the XSLT namespace */
4055  prop = xsltEvalAttrValueTemplate(ctxt, inst,
4056  (const xmlChar *) "name", XSLT_NAMESPACE);
4057  if (prop == NULL) {
4058  xsltTransformError(ctxt, NULL, inst,
4059  "xsl:element: The attribute 'name' is missing.\n");
4060  goto error;
4061  }
4062  if (xmlValidateQName(prop, 0)) {
4063  xsltTransformError(ctxt, NULL, inst,
4064  "xsl:element: The effective name '%s' is not a "
4065  "valid QName.\n", prop);
4066  /* we fall through to catch any further errors, if possible */
4067  }
4068  name = xsltSplitQName(ctxt->dict, prop, &prefix);
4069  xmlFree(prop);
4070  } else {
4071  /*
4072  * The "name" value was static.
4073  */
4074 #ifdef XSLT_REFACTORED
4075  prefix = comp->nsPrefix;
4076  name = comp->name;
4077 #else
4078  name = xsltSplitQName(ctxt->dict, comp->name, &prefix);
4079 #endif
4080  }
4081 
4082  /*
4083  * Create the new element
4084  */
4085  if (ctxt->output->dict == ctxt->dict) {
4087  } else {
4088  copy = xmlNewDocNode(ctxt->output, NULL, (xmlChar *)name, NULL);
4089  }
4090  if (copy == NULL) {
4091  xsltTransformError(ctxt, NULL, inst,
4092  "xsl:element : creation of %s failed\n", name);
4093  return;
4094  }
4095  copy = xsltAddChild(ctxt->insert, copy);
4096  if (copy == NULL) {
4097  xsltTransformError(ctxt, NULL, inst,
4098  "xsl:element : xsltAddChild failed\n");
4099  return;
4100  }
4101 
4102  /*
4103  * Namespace
4104  * ---------
4105  */
4106  if (comp->has_ns) {
4107  if (comp->ns != NULL) {
4108  /*
4109  * No AVT; just plain text for the namespace name.
4110  */
4111  if (comp->ns[0] != 0)
4112  nsName = comp->ns;
4113  } else {
4114  xmlChar *tmpNsName;
4115  /*
4116  * Eval the AVT.
4117  */
4118  /* TODO: check attr acquisition wrt to the XSLT namespace */
4119  tmpNsName = xsltEvalAttrValueTemplate(ctxt, inst,
4120  (const xmlChar *) "namespace", XSLT_NAMESPACE);
4121  /*
4122  * SPEC XSLT 1.0:
4123  * "If the string is empty, then the expanded-name of the
4124  * attribute has a null namespace URI."
4125  */
4126  if ((tmpNsName != NULL) && (tmpNsName[0] != 0))
4127  nsName = xmlDictLookup(ctxt->dict, BAD_CAST tmpNsName, -1);
4128  xmlFree(tmpNsName);
4129  }
4130 
4131  if (xmlStrEqual(nsName, BAD_CAST "http://www.w3.org/2000/xmlns/")) {
4132  xsltTransformError(ctxt, NULL, inst,
4133  "xsl:attribute: Namespace http://www.w3.org/2000/xmlns/ "
4134  "forbidden.\n");
4135  goto error;
4136  }
4137  if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
4138  prefix = BAD_CAST "xml";
4139  } else if (xmlStrEqual(prefix, BAD_CAST "xml")) {
4140  prefix = NULL;
4141  }
4142  } else {
4143  xmlNsPtr ns;
4144  /*
4145  * SPEC XSLT 1.0:
4146  * "If the namespace attribute is not present, then the QName is
4147  * expanded into an expanded-name using the namespace declarations
4148  * in effect for the xsl:element element, including any default
4149  * namespace declaration.
4150  */
4151  ns = xmlSearchNs(inst->doc, inst, prefix);
4152  if (ns == NULL) {
4153  /*
4154  * TODO: Check this in the compilation layer in case it's a
4155  * static value.
4156  */
4157  if (prefix != NULL) {
4158  xsltTransformError(ctxt, NULL, inst,
4159  "xsl:element: The QName '%s:%s' has no "
4160  "namespace binding in scope in the stylesheet; "
4161  "this is an error, since the namespace was not "
4162  "specified by the instruction itself.\n", prefix, name);
4163  }
4164  } else
4165  nsName = ns->href;
4166  }
4167  /*
4168  * Find/create a matching ns-decl in the result tree.
4169  */
4170  if (nsName != NULL) {
4171  if (xmlStrEqual(prefix, BAD_CAST "xmlns")) {
4172  /* Don't use a prefix of "xmlns" */
4173  xmlChar *pref = xmlStrdup(BAD_CAST "ns_1");
4174 
4175  copy->ns = xsltGetSpecialNamespace(ctxt, inst, nsName, pref, copy);
4176 
4177  xmlFree(pref);
4178  } else {
4179  copy->ns = xsltGetSpecialNamespace(ctxt, inst, nsName, prefix,
4180  copy);
4181  }
4182  } else if ((copy->parent != NULL) &&
4183  (copy->parent->type == XML_ELEMENT_NODE) &&
4184  (copy->parent->ns != NULL))
4185  {
4186  /*
4187  * "Undeclare" the default namespace.
4188  */
4189  xsltGetSpecialNamespace(ctxt, inst, NULL, NULL, copy);
4190  }
4191 
4192  ctxt->insert = copy;
4193 
4194  if (comp->has_use) {
4195  if (comp->use != NULL) {
4196  xsltApplyAttributeSet(ctxt, node, inst, comp->use);
4197  } else {
4198  xmlChar *attrSets = NULL;
4199  /*
4200  * BUG TODO: use-attribute-sets is not a value template.
4201  * use-attribute-sets = qnames
4202  */
4203  attrSets = xsltEvalAttrValueTemplate(ctxt, inst,
4204  (const xmlChar *)"use-attribute-sets", NULL);
4205  if (attrSets != NULL) {
4206  xsltApplyAttributeSet(ctxt, node, inst, attrSets);
4207  xmlFree(attrSets);
4208  }
4209  }
4210  }
4211  /*
4212  * Instantiate the sequence constructor.
4213  */
4214  if (inst->children != NULL)
4215  xsltApplySequenceConstructor(ctxt, ctxt->node, inst->children,
4216  NULL);
4217 
4218 error:
4219  ctxt->insert = oldInsert;
4220  return;
4221 }
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:748
const xmlChar * use
#define error(str)
Definition: mkdosfs.c:1605
Definition: tree.h:389
const xmlChar * ns
xmlNsPtr xsltGetSpecialNamespace(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, const xmlChar *nsName, const xmlChar *nsPrefix, xmlNodePtr target)
Definition: namespaces.c:299
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns, xmlChar *name, const xmlChar *content)
#define XSLT_NAMESPACE
Definition: xslt.h:46
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:384
struct _xmlDoc * doc
Definition: tree.h:498
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
smooth NULL
Definition: ftsmooth.c:416
#define XML_XML_NAMESPACE
Definition: tree.h:140
#define BAD_CAST
Definition: xmlstring.h:35
const xmlChar * xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
Definition: xsltutils.c:720
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:858
Definition: tree.h:489
void xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, const xmlChar *attrSets)
Definition: attributes.c:1086
Definition: mxnamespace.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
xsltStylePreComp * xsltStylePreCompPtr
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content)
const xmlChar * name
struct _xmlNode * children
Definition: tree.h:493
Definition: name.c:36
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
struct _xmlDict * dict
Definition: tree.h:580
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
Definition: dlist.c:348
GLuint const GLchar * name
Definition: glext.h:6031

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 5433 of file transform.c.

5435 {
5436 #ifdef XSLT_REFACTORED
5437  xsltStyleItemForEachPtr comp = (xsltStyleItemForEachPtr) castedComp;
5438 #else
5439  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
5440 #endif
5441  int i;
5442  xmlXPathObjectPtr res = NULL;
5443  xmlNodePtr cur, curInst;
5444  xmlNodeSetPtr list = NULL;
5445  xmlNodeSetPtr oldList;
5446  int oldXPProximityPosition, oldXPContextSize;
5447  xmlNodePtr oldContextNode;
5448  xsltTemplatePtr oldCurTemplRule;
5449  xmlDocPtr oldXPDoc;
5450  xsltDocumentPtr oldDocInfo;
5451  xmlXPathContextPtr xpctxt;
5452 
5453  if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL)) {
5455  "xsltForEach(): Bad arguments.\n");
5456  return;
5457  }
5458 
5459  if (comp == NULL) {
5460  xsltTransformError(ctxt, NULL, inst,
5461  "Internal error in xsltForEach(): "
5462  "The XSLT 'for-each' instruction was not compiled.\n");
5463  return;
5464  }
5465  if ((comp->select == NULL) || (comp->comp == NULL)) {
5466  xsltTransformError(ctxt, NULL, inst,
5467  "Internal error in xsltForEach(): "
5468  "The selecting expression of the XSLT 'for-each' "
5469  "instruction was not compiled correctly.\n");
5470  return;
5471  }
5472  xpctxt = ctxt->xpathCtxt;
5473 
5474 #ifdef WITH_XSLT_DEBUG_PROCESS
5476  "xsltForEach: select %s\n", comp->select));
5477 #endif
5478 
5479  /*
5480  * Save context states.
5481  */
5482  oldDocInfo = ctxt->document;
5483  oldList = ctxt->nodeList;
5484  oldContextNode = ctxt->node;
5485  /*
5486  * The "current template rule" is cleared for the instantiation of
5487  * xsl:for-each.
5488  */
5489  oldCurTemplRule = ctxt->currentTemplateRule;
5490  ctxt->currentTemplateRule = NULL;
5491 
5492  oldXPDoc = xpctxt->doc;
5493  oldXPProximityPosition = xpctxt->proximityPosition;
5494  oldXPContextSize = xpctxt->contextSize;
5495 
5496  /*
5497  * Evaluate the 'select' expression.
5498  */
5499  res = xsltPreCompEval(ctxt, contextNode, comp);
5500 
5501  if (res != NULL) {
5502  if (res->type == XPATH_NODESET)
5503  list = res->nodesetval;
5504  else {
5505  xsltTransformError(ctxt, NULL, inst,
5506  "The 'select' expression does not evaluate to a node set.\n");
5507 
5508 #ifdef WITH_XSLT_DEBUG_PROCESS
5510  "xsltForEach: select didn't evaluate to a node list\n"));
5511 #endif
5512  goto error;
5513  }
5514  } else {
5515  xsltTransformError(ctxt, NULL, inst,
5516  "Failed to evaluate the 'select' expression.\n");
5517  ctxt->state = XSLT_STATE_STOPPED;
5518  goto error;
5519  }
5520 
5521  if ((list == NULL) || (list->nodeNr <= 0))
5522  goto exit;
5523 
5524 #ifdef WITH_XSLT_DEBUG_PROCESS
5526  "xsltForEach: select evaluates to %d nodes\n", list->nodeNr));
5527 #endif
5528 
5529  /*
5530  * Set the list; this has to be done already here for xsltDoSortFunction().
5531  */
5532  ctxt->nodeList = list;
5533  /*
5534  * Handle xsl:sort instructions and skip them for further processing.
5535  * BUG TODO: We are not using namespaced potentially defined on the
5536  * xsl:sort element; XPath expression might fail.
5537  */
5538  curInst = inst->children;
5539  if (IS_XSLT_ELEM(curInst) && IS_XSLT_NAME(curInst, "sort")) {
5540  int nbsorts = 0;
5541  xmlNodePtr sorts[XSLT_MAX_SORT];
5542 
5543  sorts[nbsorts++] = curInst;
5544 
5545 #ifdef WITH_DEBUGGER
5547  xslHandleDebugger(curInst, contextNode, NULL, ctxt);
5548 #endif
5549 
5550  curInst = curInst->next;
5551  while (IS_XSLT_ELEM(curInst) && IS_XSLT_NAME(curInst, "sort")) {
5552  if (nbsorts >= XSLT_MAX_SORT) {
5553  xsltTransformError(ctxt, NULL, curInst,
5554  "The number of xsl:sort instructions exceeds the "
5555  "maximum (%d) allowed by this processor.\n",
5556  XSLT_MAX_SORT);
5557  goto error;
5558  } else {
5559  sorts[nbsorts++] = curInst;
5560  }
5561 
5562 #ifdef WITH_DEBUGGER
5564  xslHandleDebugger(curInst, contextNode, NULL, ctxt);
5565 #endif
5566  curInst = curInst->next;
5567  }
5568  xsltDoSortFunction(ctxt, sorts, nbsorts);
5569  }
5570  xpctxt->contextSize = list->nodeNr;
5571  /*
5572  * Instantiate the sequence constructor for each selected node.
5573  */
5574  for (i = 0; i < list->nodeNr; i++) {
5575  cur = list->nodeTab[i];
5576  /*
5577  * The selected node becomes the "current node".
5578  */
5579  ctxt->node = cur;
5580  /*
5581  * An xsl:for-each can change the current context doc.
5582  * OPTIMIZE TODO: Get rid of the need to set the context doc.
5583  */
5584  if ((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL))
5585  xpctxt->doc = cur->doc;
5586 
5587  xpctxt->proximityPosition = i + 1;
5588 
5589  xsltApplySequenceConstructor(ctxt, cur, curInst, NULL);
5590  }
5591 
5592 exit:
5593 error:
5594  if (res != NULL)
5595  xmlXPathFreeObject(res);
5596  /*
5597  * Restore old states.
5598  */
5599  ctxt->document = oldDocInfo;
5600  ctxt->nodeList = oldList;
5601  ctxt->node = oldContextNode;
5602  ctxt->currentTemplateRule = oldCurTemplRule;
5603 
5604  xpctxt->doc = oldXPDoc;
5605  xpctxt->contextSize = oldXPContextSize;
5606  xpctxt->proximityPosition = oldXPProximityPosition;
5607 }
xmlNodeSetPtr nodeList
#define error(str)
Definition: mkdosfs.c:1605
int xslDebugStatus
Definition: xsltutils.c:2357
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
struct _xmlDoc * doc
Definition: tree.h:498
struct _xmlDoc * doc
Definition: tree.h:560
void xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
Definition: xsltutils.c:1332
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 XSLT_MAX_SORT
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:502
xsltTransformState state
smooth NULL
Definition: ftsmooth.c:416
xsltDocumentPtr document
xmlXPathContextPtr xpathCtxt
static xmlXPathObjectPtr xsltPreCompEval(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:317
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xsltTemplatePtr currentTemplateRule
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
void * xsltGenericErrorContext
Definition: xsltutils.c:503
Definition: tree.h:489
Definition: _list.h:228
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlElementType type
Definition: tree.h:491
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
void xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
Definition: xsltutils.c:2422
xsltStylePreComp * xsltStylePreCompPtr
struct _xmlNode * next
Definition: tree.h:496
xmlXPathCompExprPtr comp
#define list
Definition: rosglue.h:35
Definition: tree.h:551
const xmlChar * select
struct _xmlNode * children
Definition: tree.h:493
GLuint res
Definition: glext.h:9613
void exit(int exitcode)
Definition: _exit.c:33
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:63

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltFreeTransformContext()

XSLTPUBFUN void XSLTCALL xsltFreeTransformContext ( xsltTransformContextPtr  ctxt)

xsltFreeTransformContext: @ctxt: an XSLT parser context

Free up the memory allocated by @ctxt

Definition at line 686 of file transform.c.

686  {
687  if (ctxt == NULL)
688  return;
689 
690  /*
691  * Shutdown the extension modules associated to the stylesheet
692  * used if needed.
693  */
694  xsltShutdownCtxtExts(ctxt);
695 
696  if (ctxt->xpathCtxt != NULL) {
697  ctxt->xpathCtxt->nsHash = NULL;
698  xmlXPathFreeContext(ctxt->xpathCtxt);
699  }
700  if (ctxt->templTab != NULL)
701  xmlFree(ctxt->templTab);
702  if (ctxt->varsTab != NULL)
703  xmlFree(ctxt->varsTab);
704  if (ctxt->profTab != NULL)
705  xmlFree(ctxt->profTab);
706  if ((ctxt->extrasNr > 0) && (ctxt->extras != NULL)) {
707  int i;
708 
709  for (i = 0;i < ctxt->extrasNr;i++) {
710  if ((ctxt->extras[i].deallocate != NULL) &&
711  (ctxt->extras[i].info != NULL))
712  ctxt->extras[i].deallocate(ctxt->extras[i].info);
713  }
714  xmlFree(ctxt->extras);
715  }
717  xsltFreeDocuments(ctxt);
718  xsltFreeCtxtExts(ctxt);
719  xsltFreeRVTs(ctxt);
721  xmlDictFree(ctxt->dict);
722 #ifdef WITH_XSLT_DEBUG
724  "freeing transformation dictionary\n");
725 #endif
726  memset(ctxt, -1, sizeof(xsltTransformContext));
727  xmlFree(ctxt);
728 }
xsltTransformCachePtr cache
xsltRuntimeExtraPtr extras
void xsltFreeRVTs(xsltTransformContextPtr ctxt)
Definition: variables.c:419
void xsltFreeGlobalVariables(xsltTransformContextPtr ctxt)
Definition: variables.c:2222
void xsltShutdownCtxtExts(xsltTransformContextPtr ctxt)
Definition: extensions.c:1081
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
xsltTemplatePtr * templTab
smooth NULL
Definition: ftsmooth.c:416
xmlXPathContextPtr xpathCtxt
static void xsltTransformCacheFree(xsltTransformCachePtr cache)
Definition: transform.c:482
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
void xsltFreeDocuments(xsltTransformContextPtr ctxt)
Definition: documents.c:234
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
XMLPUBFUN void XMLCALL xmlDictFree(xmlDictPtr dict)
Definition: dict.c:793
xsltStackElemPtr * varsTab
xmlFreeFunc deallocate
void xsltFreeCtxtExts(xsltTransformContextPtr ctxt)
Definition: extensions.c:642
#define memset(x, y, z)
Definition: compat.h:39

Referenced by 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 433 of file transform.c.

433  {
434  return(xsltDoXIncludeDefault);
435 }
static int xsltDoXIncludeDefault
Definition: transform.c:412

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 5327 of file transform.c.

5329 {
5330  int res = 0;
5331 
5332 #ifdef XSLT_REFACTORED
5333  xsltStyleItemIfPtr comp = (xsltStyleItemIfPtr) castedComp;
5334 #else
5335  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
5336 #endif
5337 
5338  if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
5339  return;
5340  if ((comp == NULL) || (comp->test == NULL) || (comp->comp == NULL)) {
5341  xsltTransformError(ctxt, NULL, inst,
5342  "Internal error in xsltIf(): "
5343  "The XSLT 'if' instruction was not compiled.\n");
5344  return;
5345  }
5346 
5347 #ifdef WITH_XSLT_DEBUG_PROCESS
5349  "xsltIf: test %s\n", comp->test));
5350 #endif
5351 
5352 #ifdef XSLT_FAST_IF
5353  {
5354  xmlDocPtr oldLocalFragmentTop = ctxt->localRVT;
5355 
5356  res = xsltPreCompEvalToBoolean(ctxt, contextNode, comp);
5357 
5358  /*
5359  * Cleanup fragments created during evaluation of the
5360  * "select" expression.
5361  */
5362  if (oldLocalFragmentTop != ctxt->localRVT)
5363  xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
5364  }
5365 
5366 #ifdef WITH_XSLT_DEBUG_PROCESS
5368  "xsltIf: test evaluate to %d\n", res));
5369 #endif
5370 
5371  if (res == -1) {
5372  ctxt->state = XSLT_STATE_STOPPED;
5373  goto error;
5374  }
5375  if (res == 1) {
5376  /*
5377  * Instantiate the sequence constructor of xsl:if.
5378  */
5380  contextNode, inst->children, NULL);
5381  }
5382 
5383 #else /* XSLT_FAST_IF */
5384  {
5385  /*
5386  * OLD CODE:
5387  */
5388  xmlXPathObjectPtr xpobj = xsltPreCompEval(ctxt, contextNode, comp);
5389  if (xpobj != NULL) {
5390  if (xpobj->type != XPATH_BOOLEAN)
5391  xpobj = xmlXPathConvertBoolean(xpobj);
5392  if (xpobj->type == XPATH_BOOLEAN) {
5393  res = xpobj->boolval;
5394 
5395 #ifdef WITH_XSLT_DEBUG_PROCESS
5397  "xsltIf: test evaluate to %d\n", res));
5398 #endif
5399  if (res) {
5401  contextNode, inst->children, NULL);
5402  }
5403  } else {
5404 
5405 #ifdef WITH_XSLT_DEBUG_PROCESS
5406  XSLT_TRACE(ctxt, XSLT_TRACE_IF,
5408  "xsltIf: test didn't evaluate to a boolean\n"));
5409 #endif
5410  ctxt->state = XSLT_STATE_STOPPED;
5411  }
5412  xmlXPathFreeObject(xpobj);
5413  } else {
5414  ctxt->state = XSLT_STATE_STOPPED;
5415  }
5416  }
5417 #endif /* else of XSLT_FAST_IF */
5418 
5419 error:
5420  return;
5421 }
#define error(str)
Definition: mkdosfs.c:1605
const xmlChar * test
xsltTransformState state
smooth NULL
Definition: ftsmooth.c:416
static xmlXPathObjectPtr xsltPreCompEval(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:317
static int xsltPreCompEvalToBoolean(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:366
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
xsltStylePreComp * xsltStylePreCompPtr
xmlXPathCompExprPtr comp
Definition: tree.h:551
struct _xmlNode * children
Definition: tree.h:493
GLuint res
Definition: glext.h:9613
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
static void xsltReleaseLocalRVTs(xsltTransformContextPtr ctxt, xmlDocPtr base)
Definition: transform.c:2260

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 150 of file transform.c.

151 {
153 
154  if (ctxt->varsNr <= 0)
155  return;
156 
157  do {
158  if (ctxt->varsNr <= limitNr)
159  break;
160  variable = ctxt->varsTab[ctxt->varsNr - 1];
161  if (variable->level <= level)
162  break;
163  if (variable->level >= 0)
165  ctxt->varsNr--;
166  } while (ctxt->varsNr != 0);
167  if (ctxt->varsNr > 0)
168  ctxt->vars = ctxt->varsTab[ctxt->varsNr - 1];
169  else
170  ctxt->vars = NULL;
171 }
GLint level
Definition: gl.h:1546
xsltStackElemPtr vars
smooth NULL
Definition: ftsmooth.c:416
GLenum GLenum variable
Definition: glext.h:9031
xsltStackElemPtr * varsTab
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:606

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 2222 of file transform.c.

2225 {
2226  if (ctxt->varsMax == 0) {
2227  ctxt->varsMax = 10;
2228  ctxt->varsTab =
2229  (xsltStackElemPtr *) xmlMalloc(ctxt->varsMax *
2230  sizeof(ctxt->varsTab[0]));
2231  if (ctxt->varsTab == NULL) {
2232  xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
2233  return (-1);
2234  }
2235  }
2236  if (ctxt->varsNr >= ctxt->varsMax) {
2237  ctxt->varsMax *= 2;
2238  ctxt->varsTab =
2240  ctxt->varsMax *
2241  sizeof(ctxt->varsTab[0]));
2242  if (ctxt->varsTab == NULL) {
2243  xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
2244  return (-1);
2245  }
2246  }
2247  ctxt->varsTab[ctxt->varsNr++] = variable;
2248  ctxt->vars = variable;
2249  variable->level = level;
2250  return(0);
2251 }
GLint level
Definition: gl.h:1546
xsltStackElemPtr vars
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
GLenum GLenum variable
Definition: glext.h:9031
xsltStackElemPtr * varsTab
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 532 of file transform.c.

532  {
534  xsltDocumentPtr docu;
535  int i;
536 
537  xsltInitGlobals();
538 
540  if (cur == NULL) {
542  "xsltNewTransformContext : malloc failed\n");
543  return(NULL);
544  }
545  memset(cur, 0, sizeof(xsltTransformContext));
546 
548  if (cur->cache == NULL)
549  goto internal_err;
550  /*
551  * setup of the dictionary must be done early as some of the
552  * processing later like key handling may need it.
553  */
554  cur->dict = xmlDictCreateSub(style->dict);
555  cur->internalized = ((style->internalized) && (cur->dict != NULL));
556 #ifdef WITH_XSLT_DEBUG
558  "Creating sub-dictionary from stylesheet for transformation\n");
559 #endif
560 
561  /*
562  * initialize the template stack
563  */
564  cur->templTab = (xsltTemplatePtr *)
565  xmlMalloc(10 * sizeof(xsltTemplatePtr));
566  if (cur->templTab == NULL) {
568  "xsltNewTransformContext: out of memory\n");
569  goto internal_err;
570  }
571  cur->templNr = 0;
572  cur->templMax = 5;
573  cur->templ = NULL;
575 
576  /*
577  * initialize the variables stack
578  */
579  cur->varsTab = (xsltStackElemPtr *)
580  xmlMalloc(10 * sizeof(xsltStackElemPtr));
581  if (cur->varsTab == NULL) {
583  "xsltNewTransformContext: out of memory\n");
584  goto internal_err;
585  }
586  cur->varsNr = 0;
587  cur->varsMax = 10;
588  cur->vars = NULL;
589  cur->varsBase = 0;
591 
592  /*
593  * the profiling stack is not initialized by default
594  */
595  cur->profTab = NULL;
596  cur->profNr = 0;
597  cur->profMax = 0;
598  cur->prof = 0;
599 
600  cur->style = style;
601  xmlXPathInit();
602  cur->xpathCtxt = xmlXPathNewContext(doc);
603  if (cur->xpathCtxt == NULL) {
605  "xsltNewTransformContext : xmlXPathNewContext failed\n");
606  goto internal_err;
607  }
608  /*
609  * Create an XPath cache.
610  */
611  if (xmlXPathContextSetCache(cur->xpathCtxt, 1, -1, 0) == -1)
612  goto internal_err;
613  /*
614  * Initialize the extras array
615  */
616  if (style->extrasNr != 0) {
617  cur->extrasMax = style->extrasNr + 20;
618  cur->extras = (xsltRuntimeExtraPtr)
619  xmlMalloc(cur->extrasMax * sizeof(xsltRuntimeExtra));
620  if (cur->extras == NULL) {
622  "xsltNewTransformContext: out of memory\n");
623  goto internal_err;
624  }
625  cur->extrasNr = style->extrasNr;
626  for (i = 0;i < cur->extrasMax;i++) {
627  cur->extras[i].info = NULL;
628  cur->extras[i].deallocate = NULL;
629  cur->extras[i].val.ptr = NULL;
630  }
631  } else {
632  cur->extras = NULL;
633  cur->extrasNr = 0;
634  cur->extrasMax = 0;
635  }
636 
639  cur->xpathCtxt->nsHash = style->nsHash;
640  /*
641  * Initialize the registered external modules
642  */
643  xsltInitCtxtExts(cur);
644  /*
645  * Setup document element ordering for later efficiencies
646  * (bug 133289)
647  */
649  xmlXPathOrderDocElems(doc);
650  /*
651  * Must set parserOptions before calling xsltNewDocument
652  * (bug 164530)
653  */
655  docu = xsltNewDocument(cur, doc);
656  if (docu == NULL) {
658  "xsltNewTransformContext : xsltNewDocument failed\n");
659  goto internal_err;
660  }
661  docu->main = 1;
662  cur->document = docu;
663  cur->inst = NULL;
664  cur->outputFile = NULL;
667  cur->traceCode = (unsigned long*) &xsltDefaultTrace;
669  cur->keyInitLevel = 0;
670 
671  return(cur);
672 
673 internal_err:
674  if (cur != NULL)
676  return(NULL);
677 }
int xsltInitCtxtExts(xsltTransformContextPtr ctxt)
Definition: extensions.c:1016
xsltTransformCachePtr cache
xsltRuntimeExtraPtr extras
int xslDebugStatus
Definition: xsltutils.c:2357
xsltStackElemPtr vars
XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreateSub(xmlDictPtr sub)
Definition: dict.c:615
unsigned long * traceCode
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54
union _xsltRuntimeExtra::@3306 val
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
xsltTransformContext * xsltTransformContextPtr
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
xsltTemplatePtr * templTab
smooth NULL
Definition: ftsmooth.c:416
xsltDocumentPtr document
xmlXPathContextPtr xpathCtxt
int xsltMaxDepth
Definition: transform.c:35
void * xsltGenericDebugContext
Definition: xsltutils.c:549
#define XSLT_REGISTER_VARIABLE_LOOKUP(ctxt)
Definition: variables.h:30
xsltTemplatePtr templ
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
int xsltGetXIncludeDefault(void)
Definition: transform.c:433
void xsltFreeTransformContext(xsltTransformContextPtr ctxt)
Definition: transform.c:686
xsltStackElemPtr * varsTab
static unsigned long xsltDefaultTrace
Definition: transform.c:437
xsltStylesheetPtr style
static xsltTransformCachePtr xsltTransformCacheCreate(void)
Definition: transform.c:467
xmlFreeFunc deallocate
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:163
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
xsltRuntimeExtra * xsltRuntimeExtraPtr
void xsltInitGlobals(void)
Definition: extensions.c:2263
Arabic default style
Definition: afstyles.h:93
#define memset(x, y, z)
Definition: compat.h:39
int xsltMaxVars
Definition: transform.c:36
#define XSLT_REGISTER_FUNCTION_LOOKUP(ctxt)
Definition: functions.h:27
xsltDocumentPtr xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc)
Definition: documents.c:127
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by 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 4562 of file transform.c.

4564 {
4565 #ifdef XSLT_REFACTORED
4566  xsltStyleItemNumberPtr comp = (xsltStyleItemNumberPtr) castedComp;
4567 #else
4568  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4569 #endif
4570  xmlXPathContextPtr xpctxt;
4571  xmlNsPtr *oldXPNamespaces;
4572  int oldXPNsNr;
4573 
4574  if (comp == NULL) {
4575  xsltTransformError(ctxt, NULL, inst,
4576  "xsl:number : compilation failed\n");
4577  return;
4578  }
4579 
4580  if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
4581  return;
4582 
4583  comp->numdata.doc = inst->doc;
4584  comp->numdata.node = inst;
4585 
4586  xpctxt = ctxt->xpathCtxt;
4587  oldXPNsNr = xpctxt->nsNr;
4588  oldXPNamespaces = xpctxt->namespaces;
4589 
4590 #ifdef XSLT_REFACTORED
4591  if (comp->inScopeNs != NULL) {
4592  xpctxt->namespaces = comp->inScopeNs->list;
4593  xpctxt->nsNr = comp->inScopeNs->xpathNumber;
4594  } else {
4595  xpctxt->namespaces = NULL;
4596  xpctxt->nsNr = 0;
4597  }
4598 #else
4599  xpctxt->namespaces = comp->nsList;
4600  xpctxt->nsNr = comp->nsNr;
4601 #endif
4602 
4603  xsltNumberFormat(ctxt, &comp->numdata, node);
4604 
4605  xpctxt->nsNr = oldXPNsNr;
4606  xpctxt->namespaces = oldXPNamespaces;
4607 }
Definition: tree.h:389
struct _xmlDoc * doc
Definition: tree.h:498
smooth NULL
Definition: ftsmooth.c:416
void xsltNumberFormat(xsltTransformContextPtr ctxt, xsltNumberDataPtr data, xmlNodePtr node)
Definition: numbers.c:708
xmlXPathContextPtr xpathCtxt
xsltNumberData numdata
xsltStylePreComp * xsltStylePreCompPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Definition: dlist.c:348

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 4278 of file transform.c.

4279  {
4280 #ifdef XSLT_REFACTORED
4281  xsltStyleItemPIPtr comp = (xsltStyleItemPIPtr) castedComp;
4282 #else
4283  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4284 #endif
4285  const xmlChar *name;
4286  xmlChar *value = NULL;
4287  xmlNodePtr pi;
4288 
4289 
4290  if (ctxt->insert == NULL)
4291  return;
4292  if (comp->has_name == 0)
4293  return;
4294  if (comp->name == NULL) {
4295  name = xsltEvalAttrValueTemplate(ctxt, inst,
4296  (const xmlChar *)"name", NULL);
4297  if (name == NULL) {
4298  xsltTransformError(ctxt, NULL, inst,
4299  "xsl:processing-instruction : name is missing\n");
4300  goto error;
4301  }
4302  } else {
4303  name = comp->name;
4304  }
4305  /* TODO: check that it's both an an NCName and a PITarget. */
4306 
4307 
4308  value = xsltEvalTemplateString(ctxt, node, inst);
4309  if (xmlStrstr(value, BAD_CAST "?>") != NULL) {
4310  xsltTransformError(ctxt, NULL, inst,
4311  "xsl:processing-instruction: '?>' not allowed within PI content\n");
4312  goto error;
4313  }
4314 #ifdef WITH_XSLT_DEBUG_PROCESS
4315  if (value == NULL) {
4317  "xsltProcessingInstruction: %s empty\n", name));
4318  } else {
4320  "xsltProcessingInstruction: %s content %s\n", name, value));
4321  }
4322 #endif
4323 
4324  pi = xmlNewDocPI(ctxt->insert->doc, name, value);
4325  pi = xsltAddChild(ctxt->insert, pi);
4326 
4327 error:
4328  if ((name != NULL) && (name != comp->name))
4329  xmlFree((xmlChar *) name);
4330  if (value != NULL)
4331  xmlFree(value);
4332 }
XMLPUBFUN const xmlChar *XMLCALL xmlStrstr(const xmlChar *str, const xmlChar *val)
Definition: xmlstring.c:341
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:748
#define error(str)
Definition: mkdosfs.c:1605
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:384
struct _xmlDoc * doc
Definition: tree.h:498
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
static DWORD pi
Definition: protocol.c:150
Definition: tree.h:489
unsigned char xmlChar
Definition: xmlstring.h:28
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xsltStylePreComp * xsltStylePreCompPtr
const xmlChar * name
xmlChar * xsltEvalTemplateString(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst)
Definition: templates.c:189
Definition: name.c:36
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Definition: dlist.c:348
GLuint const GLchar * name
Definition: glext.h:6031

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 2100 of file transform.c.

2102 {
2103  xsltTemplatePtr templ;
2104  xmlNodePtr oldNode;
2105 
2106  templ = xsltGetTemplate(ctxt, contextNode, NULL);
2107  /*
2108  * If no template is found, apply the default rule.
2109  */
2110  if (templ == NULL) {
2111 #ifdef WITH_XSLT_DEBUG_PROCESS
2112  if (contextNode->type == XML_DOCUMENT_NODE) {
2114  "xsltProcessOneNode: no template found for /\n"));
2115  } else if (contextNode->type == XML_CDATA_SECTION_NODE) {
2117  "xsltProcessOneNode: no template found for CDATA\n"));
2118  } else if (contextNode->type == XML_ATTRIBUTE_NODE) {
2120  "xsltProcessOneNode: no template found for attribute %s\n",
2121  ((xmlAttrPtr) contextNode)->name));
2122  } else {
2124  "xsltProcessOneNode: no template found for %s\n", contextNode->name));
2125  }
2126 #endif
2127  oldNode = ctxt->node;
2128  ctxt->node = contextNode;
2129  xsltDefaultProcessOneNode(ctxt, contextNode, withParams);
2130  ctxt->node = oldNode;
2131  return;
2132  }
2133 
2134  if (contextNode->type == XML_ATTRIBUTE_NODE) {
2135  xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
2136  /*
2137  * Set the "current template rule".
2138  */
2139  ctxt->currentTemplateRule = templ;
2140 
2141 #ifdef WITH_XSLT_DEBUG_PROCESS
2143  "xsltProcessOneNode: applying template '%s' for attribute %s\n",
2144  templ->match, contextNode->name));
2145 #endif
2146  xsltApplyXSLTTemplate(ctxt, contextNode, templ->content, templ, withParams);
2147 
2148  ctxt->currentTemplateRule = oldCurTempRule;
2149  } else {
2150  xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
2151  /*
2152  * Set the "current template rule".
2153  */
2154  ctxt->currentTemplateRule = templ;
2155 
2156 #ifdef WITH_XSLT_DEBUG_PROCESS
2157  if (contextNode->type == XML_DOCUMENT_NODE) {
2159  "xsltProcessOneNode: applying template '%s' for /\n",
2160  templ->match));
2161  } else {
2163  "xsltProcessOneNode: applying template '%s' for %s\n",
2164  templ->match, contextNode->name));
2165  }
2166 #endif
2167  xsltApplyXSLTTemplate(ctxt, contextNode, templ->content, templ, withParams);
2168 
2169  ctxt->currentTemplateRule = oldCurTempRule;
2170  }
2171 }
const xmlChar * name
Definition: tree.h:492
xmlNodePtr content
static void xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ, xsltStackElemPtr withParams)
Definition: transform.c:3047
xsltTemplatePtr xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylesheetPtr style)
Definition: pattern.c:2318
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
static void xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStackElemPtr params)
Definition: transform.c:1854
xsltTemplatePtr currentTemplateRule
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlElementType type
Definition: tree.h:491
Definition: tree.h:434
Definition: name.c:36
xmlChar * match

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 6223 of file transform.c.

6225 {
6226  xmlDocPtr res;
6227 
6229  return (res);
6230 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
static xmlDocPtr xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, FILE *profile, xsltTransformContextPtr userCtxt)
Definition: transform.c:5801
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
Definition: tree.h:551
GLuint res
Definition: glext.h:9613
Arabic default style
Definition: afstyles.h:93

◆ xsltRegisterAllElement()

XSLTPUBFUN void XSLTCALL xsltRegisterAllElement ( xsltTransformContextPtr  ctxt)

xsltRegisterAllElement: @ctxt: the XPath context

Registers all default XSLT elements in this context

Definition at line 6367 of file transform.c.

6368 {
6369  xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-templates",
6372  xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-imports",
6375  xsltRegisterExtElement(ctxt, (const xmlChar *) "call-template",
6378  xsltRegisterExtElement(ctxt, (const xmlChar *) "element",
6380  xsltElement);
6381  xsltRegisterExtElement(ctxt, (const xmlChar *) "attribute",
6383  xsltAttribute);
6384  xsltRegisterExtElement(ctxt, (const xmlChar *) "text",
6386  xsltText);
6387  xsltRegisterExtElement(ctxt, (const xmlChar *) "processing-instruction",
6390  xsltRegisterExtElement(ctxt, (const xmlChar *) "comment",
6392  xsltComment);
6393  xsltRegisterExtElement(ctxt, (const xmlChar *) "copy",
6395  xsltCopy);
6396  xsltRegisterExtElement(ctxt, (const xmlChar *) "value-of",
6398  xsltValueOf);
6399  xsltRegisterExtElement(ctxt, (const xmlChar *) "number",
6401  xsltNumber);
6402  xsltRegisterExtElement(ctxt, (const xmlChar *) "for-each",
6404  xsltForEach);
6405  xsltRegisterExtElement(ctxt, (const xmlChar *) "if",
6407  xsltIf);
6408  xsltRegisterExtElement(ctxt, (const xmlChar *) "choose",
6410  xsltChoose);
6411  xsltRegisterExtElement(ctxt, (const xmlChar *) "sort",
6413  xsltSort);
6414  xsltRegisterExtElement(ctxt, (const xmlChar *) "copy-of",
6416  xsltCopyOf);
6417  xsltRegisterExtElement(ctxt, (const xmlChar *) "message",
6420 
6421  /*
6422  * Those don't have callable entry points but are registered anyway
6423  */
6424  xsltRegisterExtElement(ctxt, (const xmlChar *) "variable",
6426  xsltDebug);
6427  xsltRegisterExtElement(ctxt, (const xmlChar *) "param",
6429  xsltDebug);
6430  xsltRegisterExtElement(ctxt, (const xmlChar *) "with-param",
6432  xsltDebug);
6433  xsltRegisterExtElement(ctxt, (const xmlChar *) "decimal-format",
6435  xsltDebug);
6436  xsltRegisterExtElement(ctxt, (const