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

Go to the source code of this file.

Functions

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

Function Documentation

◆ xslHandleDebugger()

◆ xsltApplyImports()

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

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

Process the XSLT apply-imports element.

Definition at line 4650 of file transform.c.

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

3320 {
3321  if ((ctxt == NULL) || (list == NULL))
3322  return;
3323  CHECK_STOPPED;
3324 
3325  if (params) {
3326  /*
3327  * This code should be obsolete - was previously used
3328  * by libexslt/functions.c, but due to bug 381319 the
3329  * logic there was changed.
3330  */
3331  int oldVarsNr = ctxt->varsNr;
3332 
3333  /*
3334  * Push the given xsl:param(s) onto the variable stack.
3335  */
3336  while (params != NULL) {
3337  xsltLocalVariablePush(ctxt, params, -1);
3338  params = params->next;
3339  }
3340  xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
3341  /*
3342  * Pop the given xsl:param(s) from the stack but don't free them.
3343  */
3344  xsltLocalVariablePop(ctxt, oldVarsNr, -2);
3345  } else
3346  xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
3347 }
#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:2230
Definition: _list.h:228
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2320
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 5712 of file transform.c.

5712  {
5714 #ifdef WITH_XSLT_DEBUG_PROCESS
5715  int nb = 0;
5716 #endif
5717 
5718 
5719  current = node;
5720  while (current != NULL) {
5721  /*
5722  * Cleanup children empty nodes if asked for
5723  */
5724  if ((IS_XSLT_REAL_NODE(current)) &&
5725  (current->children != NULL) &&
5727  xmlNodePtr delete = NULL, cur = current->children;
5728 
5729  while (cur != NULL) {
5730  if (IS_BLANK_NODE(cur))
5731  delete = cur;
5732 
5733  cur = cur->next;
5734  if (delete != NULL) {
5735  xmlUnlinkNode(delete);
5736  xmlFreeNode(delete);
5737  delete = NULL;
5738 #ifdef WITH_XSLT_DEBUG_PROCESS
5739  nb++;
5740 #endif
5741  }
5742  }
5743  }
5744 
5745  /*
5746  * Skip to next node in document order.
5747  */
5748  if (node->type == XML_ENTITY_REF_NODE) {
5749  /* process deep in entities */
5750  xsltApplyStripSpaces(ctxt, node->children);
5751  }
5752  if ((current->children != NULL) &&
5753  (current->type != XML_ENTITY_REF_NODE)) {
5754  current = current->children;
5755  } else if (current->next != NULL) {
5756  current = current->next;
5757  } else {
5758  do {
5759  current = current->parent;
5760  if (current == NULL)
5761  break;
5762  if (current == node)
5763  goto done;
5764  if (current->next != NULL) {
5765  current = current->next;
5766  break;
5767  }
5768  } while (current != NULL);
5769  }
5770  }
5771 
5772 done:
5773 #ifdef WITH_XSLT_DEBUG_PROCESS
5775  "xsltApplyStripSpaces: removed %d ignorable blank node\n", nb));
5776 #endif
5777  return;
5778 }
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:303
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
void xsltApplyStripSpaces(xsltTransformContextPtr ctxt, xmlNodePtr node)
Definition: transform.c:5712
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 6247 of file transform.c.

6249 {
6251 }
static xmlDocPtr xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, FILE *profile, xsltTransformContextPtr userCtxt)
Definition: transform.c:5832
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 6290 of file transform.c.

6293 {
6294  xmlDocPtr res;
6295 
6297  profile, userCtxt);
6298  return (res);
6299 }
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:5832
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 4822 of file transform.c.

4824 {
4825 #ifdef XSLT_REFACTORED
4826  xsltStyleItemApplyTemplatesPtr comp =
4827  (xsltStyleItemApplyTemplatesPtr) castedComp;
4828 #else
4829  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
4830 #endif
4831  int i;
4832  xmlNodePtr cur, delNode = NULL, oldContextNode;
4833  xmlNodeSetPtr list = NULL, oldList;
4834  xsltStackElemPtr withParams = NULL;
4835  int oldXPProximityPosition, oldXPContextSize;
4836  const xmlChar *oldMode, *oldModeURI;
4837  xmlDocPtr oldXPDoc;
4838  xsltDocumentPtr oldDocInfo;
4839  xmlXPathContextPtr xpctxt;
4840 
4841  if (comp == NULL) {
4842  xsltTransformError(ctxt, NULL, inst,
4843  "xsl:apply-templates : compilation failed\n");
4844  return;
4845  }
4846  if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
4847  return;
4848 
4849 #ifdef WITH_XSLT_DEBUG_PROCESS
4850  if ((node != NULL) && (node->name != NULL))
4852  "xsltApplyTemplates: node: '%s'\n", node->name));
4853 #endif
4854 
4855  xpctxt = ctxt->xpathCtxt;
4856  /*
4857  * Save context states.
4858  */
4859  oldContextNode = ctxt->node;
4860  oldMode = ctxt->mode;
4861  oldModeURI = ctxt->modeURI;
4862  oldDocInfo = ctxt->document;
4863  oldList = ctxt->nodeList;
4864 
4865  /*
4866  * The xpath context size and proximity position, as
4867  * well as the xpath and context documents, may be changed
4868  * so we save their initial state and will restore on exit
4869  */
4870  oldXPContextSize = xpctxt->contextSize;
4871  oldXPProximityPosition = xpctxt->proximityPosition;
4872  oldXPDoc = xpctxt->doc;
4873 
4874  /*
4875  * Set up contexts.
4876  */
4877  ctxt->mode = comp->mode;
4878  ctxt->modeURI = comp->modeURI;
4879 
4880  if (comp->select != NULL) {
4881  xmlXPathObjectPtr res = NULL;
4882 
4883  if (comp->comp == NULL) {
4884  xsltTransformError(ctxt, NULL, inst,
4885  "xsl:apply-templates : compilation failed\n");
4886  goto error;
4887  }
4888 #ifdef WITH_XSLT_DEBUG_PROCESS
4890  "xsltApplyTemplates: select %s\n", comp->select));
4891 #endif
4892 
4893  res = xsltPreCompEval(ctxt, node, comp);
4894 
4895  if (res != NULL) {
4896  if (res->type == XPATH_NODESET) {
4897  list = res->nodesetval; /* consume the node set */
4898  res->nodesetval = NULL;
4899  } else {
4900  xsltTransformError(ctxt, NULL, inst,
4901  "The 'select' expression did not evaluate to a "
4902  "node set.\n");
4903  ctxt->state = XSLT_STATE_STOPPED;
4904  xmlXPathFreeObject(res);
4905  goto error;
4906  }
4907  xmlXPathFreeObject(res);
4908  /*
4909  * Note: An xsl:apply-templates with a 'select' attribute,
4910  * can change the current source doc.
4911  */
4912  } else {
4913  xsltTransformError(ctxt, NULL, inst,
4914  "Failed to evaluate the 'select' expression.\n");
4915  ctxt->state = XSLT_STATE_STOPPED;
4916  goto error;
4917  }
4918  if (list == NULL) {
4919 #ifdef WITH_XSLT_DEBUG_PROCESS
4921  "xsltApplyTemplates: select didn't evaluate to a node list\n"));
4922 #endif
4923  goto exit;
4924  }
4925  /*
4926  *
4927  * NOTE: Previously a document info (xsltDocument) was
4928  * created and attached to the Result Tree Fragment.
4929  * But such a document info is created on demand in
4930  * xsltKeyFunction() (functions.c), so we need to create
4931  * it here beforehand.
4932  * In order to take care of potential keys we need to
4933  * do some extra work for the case when a Result Tree Fragment
4934  * is converted into a nodeset (e.g. exslt:node-set()) :
4935  * We attach a "pseudo-doc" (xsltDocument) to _private.
4936  * This xsltDocument, together with the keyset, will be freed
4937  * when the Result Tree Fragment is freed.
4938  *
4939  */
4940 #if 0
4941  if ((ctxt->nbKeys > 0) &&
4942  (list->nodeNr != 0) &&
4943  (list->nodeTab[0]->doc != NULL) &&
4944  XSLT_IS_RES_TREE_FRAG(list->nodeTab[0]->doc))
4945  {
4946  /*
4947  * NOTE that it's also OK if @effectiveDocInfo will be
4948  * set to NULL.
4949  */
4950  isRTF = 1;
4951  effectiveDocInfo = list->nodeTab[0]->doc->_private;
4952  }
4953 #endif
4954  } else {
4955  /*
4956  * Build an XPath node set with the children
4957  */
4958  list = xmlXPathNodeSetCreate(NULL);
4959  if (list == NULL)
4960  goto error;
4961  if (node->type != XML_NAMESPACE_DECL)
4962  cur = node->children;
4963  else
4964  cur = NULL;
4965  while (cur != NULL) {
4966  switch (cur->type) {
4967  case XML_TEXT_NODE:
4968  if ((IS_BLANK_NODE(cur)) &&
4969  (cur->parent != NULL) &&
4970  (cur->parent->type == XML_ELEMENT_NODE) &&
4971  (ctxt->style->stripSpaces != NULL)) {
4972  const xmlChar *val;
4973 
4974  if (cur->parent->ns != NULL) {
4975  val = (const xmlChar *)
4977  cur->parent->name,
4978  cur->parent->ns->href);
4979  if (val == NULL) {
4980  val = (const xmlChar *)
4982  BAD_CAST "*",
4983  cur->parent->ns->href);
4984  }
4985  } else {
4986  val = (const xmlChar *)
4988  cur->parent->name, NULL);
4989  }
4990  if ((val != NULL) &&
4991  (xmlStrEqual(val, (xmlChar *) "strip"))) {
4992  delNode = cur;
4993  break;
4994  }
4995  }
4996  /* Intentional fall-through */
4997  case XML_ELEMENT_NODE:
4998  case XML_DOCUMENT_NODE:
5001  case XML_PI_NODE:
5002  case XML_COMMENT_NODE:
5003  xmlXPathNodeSetAddUnique(list, cur);
5004  break;
5005  case XML_DTD_NODE:
5006  /* Unlink the DTD, it's still reachable
5007  * using doc->intSubset */
5008  if (cur->next != NULL)
5009  cur->next->prev = cur->prev;
5010  if (cur->prev != NULL)
5011  cur->prev->next = cur->next;
5012  break;
5013  case XML_NAMESPACE_DECL:
5014  break;
5015  default:
5016 #ifdef WITH_XSLT_DEBUG_PROCESS
5018  "xsltApplyTemplates: skipping cur type %d\n",
5019  cur->type));
5020 #endif
5021  delNode = cur;
5022  }
5023  cur = cur->next;
5024  if (delNode != NULL) {
5025 #ifdef WITH_XSLT_DEBUG_PROCESS
5027  "xsltApplyTemplates: removing ignorable blank cur\n"));
5028 #endif
5029  xmlUnlinkNode(delNode);
5030  xmlFreeNode(delNode);
5031  delNode = NULL;
5032  }
5033  }
5034  }
5035 
5036 #ifdef WITH_XSLT_DEBUG_PROCESS
5037  if (list != NULL)
5039  "xsltApplyTemplates: list of %d nodes\n", list->nodeNr));
5040 #endif
5041 
5042  if ((list == NULL) || (list->nodeNr == 0))
5043  goto exit;
5044 
5045  /*
5046  * Set the context's node set and size; this is also needed for
5047  * for xsltDoSortFunction().
5048  */
5049  ctxt->nodeList = list;
5050  /*
5051  * Process xsl:with-param and xsl:sort instructions.
5052  * (The code became so verbose just to avoid the
5053  * xmlNodePtr sorts[XSLT_MAX_SORT] if there's no xsl:sort)
5054  * BUG TODO: We are not using namespaced potentially defined on the
5055  * xsl:sort or xsl:with-param elements; XPath expression might fail.
5056  */
5057  if (inst->children) {
5059 
5060  cur = inst->children;
5061  while (cur) {
5062 
5063 #ifdef WITH_DEBUGGER
5064  if (ctxt->debugStatus != XSLT_DEBUG_NONE)
5065  xslHandleDebugger(cur, node, NULL, ctxt);
5066 #endif
5067  if (ctxt->state == XSLT_STATE_STOPPED)
5068  break;
5069  if (cur->type == XML_TEXT_NODE) {
5070  cur = cur->next;
5071  continue;
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  xsltTemplatePtr oldCurTempRule =
5084  ctxt->currentTemplateRule;
5085  int nbsorts = 0;
5086  xmlNodePtr sorts[XSLT_MAX_SORT];
5087 
5088  sorts[nbsorts++] = cur;
5089 
5090  while (cur) {
5091 
5092 #ifdef WITH_DEBUGGER
5093  if (ctxt->debugStatus != XSLT_DEBUG_NONE)
5094  xslHandleDebugger(cur, node, NULL, ctxt);
5095 #endif
5096  if (ctxt->state == XSLT_STATE_STOPPED)
5097  break;
5098 
5099  if (cur->type == XML_TEXT_NODE) {
5100  cur = cur->next;
5101  continue;
5102  }
5103 
5104  if (! IS_XSLT_ELEM(cur))
5105  break;
5106  if (IS_XSLT_NAME(cur, "with-param")) {
5108  if (param != NULL) {
5109  param->next = withParams;
5110  withParams = param;
5111  }
5112  }
5113  if (IS_XSLT_NAME(cur, "sort")) {
5114  if (nbsorts >= XSLT_MAX_SORT) {
5115  xsltTransformError(ctxt, NULL, cur,
5116  "The number (%d) of xsl:sort instructions exceeds the "
5117  "maximum allowed by this processor's settings.\n",
5118  nbsorts);
5119  ctxt->state = XSLT_STATE_STOPPED;
5120  break;
5121  } else {
5122  sorts[nbsorts++] = cur;
5123  }
5124  }
5125  cur = cur->next;
5126  }
5127  /*
5128  * The "current template rule" is cleared for xsl:sort.
5129  */
5130  ctxt->currentTemplateRule = NULL;
5131  /*
5132  * Sort.
5133  */
5134  xsltDoSortFunction(ctxt, sorts, nbsorts);
5135  ctxt->currentTemplateRule = oldCurTempRule;
5136  break;
5137  }
5138  cur = cur->next;
5139  }
5140  }
5141  xpctxt->contextSize = list->nodeNr;
5142  /*
5143  * Apply templates for all selected source nodes.
5144  */
5145  for (i = 0; i < list->nodeNr; i++) {
5146  cur = list->nodeTab[i];
5147  /*
5148  * The node becomes the "current node".
5149  */
5150  ctxt->node = cur;
5151  /*
5152  * An xsl:apply-templates can change the current context doc.
5153  * OPTIMIZE TODO: Get rid of the need to set the context doc.
5154  */
5155  if ((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL))
5156  xpctxt->doc = cur->doc;
5157 
5158  xpctxt->proximityPosition = i + 1;
5159  /*
5160  * Find and apply a template for this node.
5161  */
5162  xsltProcessOneNode(ctxt, cur, withParams);
5163  }
5164 
5165 exit:
5166 error:
5167  /*
5168  * Free the parameter list.
5169  */
5170  if (withParams != NULL)
5171  xsltFreeStackElemList(withParams);
5172  if (list != NULL)
5173  xmlXPathFreeNodeSet(list);
5174  /*
5175  * Restore context states.
5176  */
5177  xpctxt->doc = oldXPDoc;
5178  xpctxt->contextSize = oldXPContextSize;
5179  xpctxt->proximityPosition = oldXPProximityPosition;
5180 
5181  ctxt->document = oldDocInfo;
5182  ctxt->nodeList = oldList;
5183  ctxt->node = oldContextNode;
5184  ctxt->mode = oldMode;
5185  ctxt->modeURI = oldModeURI;
5186 }
xmlNodeSetPtr nodeList
void xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xsltStackElemPtr withParams)
Definition: transform.c:2106
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:481
xsltStackElemPtr xsltParseStylesheetCallerParam(xsltTransformContextPtr ctxt, xmlNodePtr inst)
Definition: variables.c:1959
#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
XSLTPUBFUN void XSLTCALL xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
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:321
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
xsltStylePreComp * xsltStylePreCompPtr
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:608
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
XSLTPUBFUN void XSLTCALL xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
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:865
Definition: cookie.c:201
xmlChar * content
Definition: tree.h:502
Definition: tree.h:489
XMLPUBFUN int XMLCALL xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
Definition: valid.c:2747
__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:2645
xmlElementType type
Definition: tree.h:491
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:38
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 4719 of file transform.c.

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

5201 {
5202  xmlNodePtr cur;
5203 
5204  if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
5205  return;
5206 
5207  /*
5208  * TODO: Content model checks should be done only at compilation
5209  * time.
5210  */
5211  cur = inst->children;
5212  if (cur == NULL) {
5213  xsltTransformError(ctxt, NULL, inst,
5214  "xsl:choose: The instruction has no content.\n");
5215  return;
5216  }
5217 
5218 #ifdef XSLT_REFACTORED
5219  /*
5220  * We don't check the content model during transformation.
5221  */
5222 #else
5223  if ((! IS_XSLT_ELEM(cur)) || (! IS_XSLT_NAME(cur, "when"))) {
5224  xsltTransformError(ctxt, NULL, inst,
5225  "xsl:choose: xsl:when expected first\n");
5226  return;
5227  }
5228 #endif
5229 
5230  {
5231  int testRes = 0, res = 0;
5232 
5233 #ifdef XSLT_REFACTORED
5234  xsltStyleItemWhenPtr wcomp = NULL;
5235 #else
5236  xsltStylePreCompPtr wcomp = NULL;
5237 #endif
5238 
5239  /*
5240  * Process xsl:when ---------------------------------------------------
5241  */
5242  while (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "when")) {
5243  wcomp = cur->psvi;
5244 
5245  if ((wcomp == NULL) || (wcomp->test == NULL) ||
5246  (wcomp->comp == NULL))
5247  {
5248  xsltTransformError(ctxt, NULL, cur,
5249  "Internal error in xsltChoose(): "
5250  "The XSLT 'when' instruction was not compiled.\n");
5251  goto error;
5252  }
5253 
5254 
5255 #ifdef WITH_DEBUGGER
5257  /*
5258  * TODO: Isn't comp->templ always NULL for xsl:choose?
5259  */
5260  xslHandleDebugger(cur, contextNode, NULL, ctxt);
5261  }
5262 #endif
5263 #ifdef WITH_XSLT_DEBUG_PROCESS
5265  "xsltChoose: test %s\n", wcomp->test));
5266 #endif
5267 
5268 #ifdef XSLT_FAST_IF
5269  res = xsltPreCompEvalToBoolean(ctxt, contextNode, wcomp);
5270 
5271  if (res == -1) {
5272  ctxt->state = XSLT_STATE_STOPPED;
5273  goto error;
5274  }
5275  testRes = (res == 1) ? 1 : 0;
5276 
5277 #else /* XSLT_FAST_IF */
5278 
5279  res = xsltPreCompEval(ctxt, cotextNode, wcomp);
5280 
5281  if (res != NULL) {
5282  if (res->type != XPATH_BOOLEAN)
5283  res = xmlXPathConvertBoolean(res);
5284  if (res->type == XPATH_BOOLEAN)
5285  testRes = res->boolval;
5286  else {
5287 #ifdef WITH_XSLT_DEBUG_PROCESS
5289  "xsltChoose: test didn't evaluate to a boolean\n"));
5290 #endif
5291  goto error;
5292  }
5293  xmlXPathFreeObject(res);
5294  res = NULL;
5295  } else {
5296  ctxt->state = XSLT_STATE_STOPPED;
5297  goto error;
5298  }
5299 
5300 #endif /* else of XSLT_FAST_IF */
5301 
5302 #ifdef WITH_XSLT_DEBUG_PROCESS
5304  "xsltChoose: test evaluate to %d\n", testRes));
5305 #endif
5306  if (testRes)
5307  goto test_is_true;
5308 
5309  cur = cur->next;
5310  }
5311 
5312  /*
5313  * Process xsl:otherwise ----------------------------------------------
5314  */
5315  if (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "otherwise")) {
5316 
5317 #ifdef WITH_DEBUGGER
5319  xslHandleDebugger(cur, contextNode, NULL, ctxt);
5320 #endif
5321 
5322 #ifdef WITH_XSLT_DEBUG_PROCESS
5324  "evaluating xsl:otherwise\n"));
5325 #endif
5326  goto test_is_true;
5327  }
5328  goto exit;
5329 
5330 test_is_true:
5331 
5332  goto process_sequence;
5333  }
5334 
5335 process_sequence:
5336 
5337  /*
5338  * Instantiate the sequence constructor.
5339  */
5340  xsltApplySequenceConstructor(ctxt, ctxt->node, cur->children,
5341  NULL);
5342 
5343 exit:
5344 error:
5345  return;
5346 }
void * psvi
Definition: tree.h:505
#define error(str)
Definition: mkdosfs.c:1605
const xmlChar * test
int xslDebugStatus
Definition: xsltutils.c:2329
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
XSLTPUBFUN void XSLTCALL xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
xsltTransformState state
smooth NULL
Definition: ftsmooth.c:416
static xmlXPathObjectPtr xsltPreCompEval(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:321
static int xsltPreCompEvalToBoolean(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:370
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:2320
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 4265 of file transform.c.

4266  {
4267  xmlChar *value = NULL;
4268  xmlNodePtr commentNode;
4269  int len;
4270 
4271  value = xsltEvalTemplateString(ctxt, node, inst);
4272  /* TODO: use or generate the compiled form */
4273  len = xmlStrlen(value);
4274  if (len > 0) {
4275  if ((value[len-1] == '-') ||
4276  (xmlStrstr(value, BAD_CAST "--"))) {
4277  xsltTransformError(ctxt, NULL, inst,
4278  "xsl:comment : '--' or ending '-' not allowed in comment\n");
4279  /* fall through to try to catch further errors */
4280  }
4281  }
4282 #ifdef WITH_XSLT_DEBUG_PROCESS
4283  if (value == NULL) {
4285  "xsltComment: empty\n"));
4286  } else {
4288  "xsltComment: content %s\n", value));
4289  }
4290 #endif
4291 
4292  commentNode = xmlNewComment(value);
4293  commentNode = xsltAddChild(ctxt->insert, commentNode);
4294 
4295  if (value != NULL)
4296  xmlFree(value);
4297 }
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:752
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 3901 of file transform.c.

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

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

852 {
854  int len;
855 
856  if (string == NULL)
857  return(NULL);
858 
859 #ifdef WITH_XSLT_DEBUG_PROCESS
861  "xsltCopyTextString: copy text %s\n",
862  string));
863 #endif
864 
865  /*
866  * Play safe and reset the merging mechanism for every new
867  * target node.
868  */
869  if ((target == NULL) || (target->children == NULL)) {
870  ctxt->lasttext = NULL;
871  }
872 
873  /* handle coalescing of text nodes here */
874  len = xmlStrlen(string);
875  if ((ctxt->type == XSLT_OUTPUT_XML) &&
876  (ctxt->style->cdataSection != NULL) &&
877  (target != NULL) &&
878  (target->type == XML_ELEMENT_NODE) &&
879  (((target->ns == NULL) &&
881  target->name, NULL) != NULL)) ||
882  ((target->ns != NULL) &&
884  target->name, target->ns->href) != NULL))))
885  {
886  /*
887  * Process "cdata-section-elements".
888  */
889  if ((target->last != NULL) &&
890  (target->last->type == XML_CDATA_SECTION_NODE))
891  {
892  return(xsltAddTextString(ctxt, target->last, string, len));
893  }
894  copy = xmlNewCDataBlock(ctxt->output, string, len);
895  } else if (noescape) {
896  /*
897  * Process "disable-output-escaping".
898  */
899  if ((target != NULL) && (target->last != NULL) &&
900  (target->last->type == XML_TEXT_NODE) &&
901  (target->last->name == xmlStringTextNoenc))
902  {
903  return(xsltAddTextString(ctxt, target->last, string, len));
904  }
905  copy = xmlNewTextLen(string, len);
906  if (copy != NULL)
907  copy->name = xmlStringTextNoenc;
908  } else {
909  /*
910  * Default processing.
911  */
912  if ((target != NULL) && (target->last != NULL) &&
913  (target->last->type == XML_TEXT_NODE) &&
914  (target->last->name == xmlStringText)) {
915  return(xsltAddTextString(ctxt, target->last, string, len));
916  }
917  copy = xmlNewTextLen(string, len);
918  }
919  if (copy != NULL && target != NULL)
921  if (copy != NULL) {
922  ctxt->lasttext = copy->content;
923  ctxt->lasttsize = len;
924  ctxt->lasttuse = len;
925  } else {
927  "xsltCopyTextString: text copy failed\n");
928  ctxt->lasttext = NULL;
929  }
930  return(copy);
931 }
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:752
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:481
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:778
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 3365 of file transform.c.

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

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

5466 {
5467 #ifdef XSLT_REFACTORED
5468  xsltStyleItemForEachPtr comp = (xsltStyleItemForEachPtr) castedComp;
5469 #else
5470  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
5471 #endif
5472  int i;
5473  xmlXPathObjectPtr res = NULL;
5474  xmlNodePtr cur, curInst;
5475  xmlNodeSetPtr list = NULL;
5476  xmlNodeSetPtr oldList;
5477  int oldXPProximityPosition, oldXPContextSize;
5478  xmlNodePtr oldContextNode;
5479  xsltTemplatePtr oldCurTemplRule;
5480  xmlDocPtr oldXPDoc;
5481  xsltDocumentPtr oldDocInfo;
5482  xmlXPathContextPtr xpctxt;
5483 
5484  if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL)) {
5486  "xsltForEach(): Bad arguments.\n");
5487  return;
5488  }
5489 
5490  if (comp == NULL) {
5491  xsltTransformError(ctxt, NULL, inst,
5492  "Internal error in xsltForEach(): "
5493  "The XSLT 'for-each' instruction was not compiled.\n");
5494  return;
5495  }
5496  if ((comp->select == NULL) || (comp->comp == NULL)) {
5497  xsltTransformError(ctxt, NULL, inst,
5498  "Internal error in xsltForEach(): "
5499  "The selecting expression of the XSLT 'for-each' "
5500  "instruction was not compiled correctly.\n");
5501  return;
5502  }
5503  xpctxt = ctxt->xpathCtxt;
5504 
5505 #ifdef WITH_XSLT_DEBUG_PROCESS
5507  "xsltForEach: select %s\n", comp->select));
5508 #endif
5509 
5510  /*
5511  * Save context states.
5512  */
5513  oldDocInfo = ctxt->document;
5514  oldList = ctxt->nodeList;
5515  oldContextNode = ctxt->node;
5516  /*
5517  * The "current template rule" is cleared for the instantiation of
5518  * xsl:for-each.
5519  */
5520  oldCurTemplRule = ctxt->currentTemplateRule;
5521  ctxt->currentTemplateRule = NULL;
5522 
5523  oldXPDoc = xpctxt->doc;
5524  oldXPProximityPosition = xpctxt->proximityPosition;
5525  oldXPContextSize = xpctxt->contextSize;
5526 
5527  /*
5528  * Evaluate the 'select' expression.
5529  */
5530  res = xsltPreCompEval(ctxt, contextNode, comp);
5531 
5532  if (res != NULL) {
5533  if (res->type == XPATH_NODESET)
5534  list = res->nodesetval;
5535  else {
5536  xsltTransformError(ctxt, NULL, inst,
5537  "The 'select' expression does not evaluate to a node set.\n");
5538 
5539 #ifdef WITH_XSLT_DEBUG_PROCESS
5541  "xsltForEach: select didn't evaluate to a node list\n"));
5542 #endif
5543  goto error;
5544  }
5545  } else {
5546  xsltTransformError(ctxt, NULL, inst,
5547  "Failed to evaluate the 'select' expression.\n");
5548  ctxt->state = XSLT_STATE_STOPPED;
5549  goto error;
5550  }
5551 
5552  if ((list == NULL) || (list->nodeNr <= 0))
5553  goto exit;
5554 
5555 #ifdef WITH_XSLT_DEBUG_PROCESS
5557  "xsltForEach: select evaluates to %d nodes\n", list->nodeNr));
5558 #endif
5559 
5560  /*
5561  * Set the list; this has to be done already here for xsltDoSortFunction().
5562  */
5563  ctxt->nodeList = list;
5564  /*
5565  * Handle xsl:sort instructions and skip them for further processing.
5566  * BUG TODO: We are not using namespaced potentially defined on the
5567  * xsl:sort element; XPath expression might fail.
5568  */
5569  curInst = inst->children;
5570  if (IS_XSLT_ELEM(curInst) && IS_XSLT_NAME(curInst, "sort")) {
5571  int nbsorts = 0;
5572  xmlNodePtr sorts[XSLT_MAX_SORT];
5573 
5574  sorts[nbsorts++] = curInst;
5575 
5576 #ifdef WITH_DEBUGGER
5578  xslHandleDebugger(curInst, contextNode, NULL, ctxt);
5579 #endif
5580 
5581  curInst = curInst->next;
5582  while (IS_XSLT_ELEM(curInst) && IS_XSLT_NAME(curInst, "sort")) {
5583  if (nbsorts >= XSLT_MAX_SORT) {
5584  xsltTransformError(ctxt, NULL, curInst,
5585  "The number of xsl:sort instructions exceeds the "
5586  "maximum (%d) allowed by this processor.\n",
5587  XSLT_MAX_SORT);
5588  goto error;
5589  } else {
5590  sorts[nbsorts++] = curInst;
5591  }
5592 
5593 #ifdef WITH_DEBUGGER
5595  xslHandleDebugger(curInst, contextNode, NULL, ctxt);
5596 #endif
5597  curInst = curInst->next;
5598  }
5599  xsltDoSortFunction(ctxt, sorts, nbsorts);
5600  }
5601  xpctxt->contextSize = list->nodeNr;
5602  /*
5603  * Instantiate the sequence constructor for each selected node.
5604  */
5605  for (i = 0; i < list->nodeNr; i++) {
5606  cur = list->nodeTab[i];
5607  /*
5608  * The selected node becomes the "current node".
5609  */
5610  ctxt->node = cur;
5611  /*
5612  * An xsl:for-each can change the current context doc.
5613  * OPTIMIZE TODO: Get rid of the need to set the context doc.
5614  */
5615  if ((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL))
5616  xpctxt->doc = cur->doc;
5617 
5618  xpctxt->proximityPosition = i + 1;
5619 
5620  xsltApplySequenceConstructor(ctxt, cur, curInst, NULL);
5621  }
5622 
5623 exit:
5624 error:
5625  if (res != NULL)
5626  xmlXPathFreeObject(res);
5627  /*
5628  * Restore old states.
5629  */
5630  ctxt->document = oldDocInfo;
5631  ctxt->nodeList = oldList;
5632  ctxt->node = oldContextNode;
5633  ctxt->currentTemplateRule = oldCurTemplRule;
5634 
5635  xpctxt->doc = oldXPDoc;
5636  xpctxt->contextSize = oldXPContextSize;
5637  xpctxt->proximityPosition = oldXPProximityPosition;
5638 }
xmlNodeSetPtr nodeList
#define error(str)
Definition: mkdosfs.c:1605
int xslDebugStatus
Definition: xsltutils.c:2329
#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
XSLTPUBFUN void XSLTCALL xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
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:321
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:2320
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 690 of file transform.c.

690  {
691  if (ctxt == NULL)
692  return;
693 
694  /*
695  * Shutdown the extension modules associated to the stylesheet
696  * used if needed.
697  */
698  xsltShutdownCtxtExts(ctxt);
699 
700  if (ctxt->xpathCtxt != NULL) {
701  ctxt->xpathCtxt->nsHash = NULL;
702  xmlXPathFreeContext(ctxt->xpathCtxt);
703  }
704  if (ctxt->templTab != NULL)
705  xmlFree(ctxt->templTab);
706  if (ctxt->varsTab != NULL)
707  xmlFree(ctxt->varsTab);
708  if (ctxt->profTab != NULL)
709  xmlFree(ctxt->profTab);
710  if ((ctxt->extrasNr > 0) && (ctxt->extras != NULL)) {
711  int i;
712 
713  for (i = 0;i < ctxt->extrasNr;i++) {
714  if ((ctxt->extras[i].deallocate != NULL) &&
715  (ctxt->extras[i].info != NULL))
716  ctxt->extras[i].deallocate(ctxt->extras[i].info);
717  }
718  xmlFree(ctxt->extras);
719  }
721  xsltFreeDocuments(ctxt);
722  xsltFreeCtxtExts(ctxt);
723  xsltFreeRVTs(ctxt);
725  xmlDictFree(ctxt->dict);
726 #ifdef WITH_XSLT_DEBUG
728  "freeing transformation dictionary\n");
729 #endif
730  memset(ctxt, -1, sizeof(xsltTransformContext));
731  xmlFree(ctxt);
732 }
xsltTransformCachePtr cache
xsltRuntimeExtraPtr extras
void xsltFreeRVTs(xsltTransformContextPtr ctxt)
Definition: variables.c:421
void xsltFreeGlobalVariables(xsltTransformContextPtr ctxt)
Definition: variables.c:2224
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:486
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:800
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 437 of file transform.c.

437  {
438  return(xsltDoXIncludeDefault);
439 }
static int xsltDoXIncludeDefault
Definition: transform.c:416

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

5360 {
5361  int res = 0;
5362 
5363 #ifdef XSLT_REFACTORED
5364  xsltStyleItemIfPtr comp = (xsltStyleItemIfPtr) castedComp;
5365 #else
5366  xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
5367 #endif
5368 
5369  if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
5370  return;
5371  if ((comp == NULL) || (comp->test == NULL) || (comp->comp == NULL)) {
5372  xsltTransformError(ctxt, NULL, inst,
5373  "Internal error in xsltIf(): "
5374  "The XSLT 'if' instruction was not compiled.\n");
5375  return;
5376  }
5377 
5378 #ifdef WITH_XSLT_DEBUG_PROCESS
5380  "xsltIf: test %s\n", comp->test));
5381 #endif
5382 
5383 #ifdef XSLT_FAST_IF
5384  {
5385  xmlDocPtr oldLocalFragmentTop = ctxt->localRVT;
5386 
5387  res = xsltPreCompEvalToBoolean(ctxt, contextNode, comp);
5388 
5389  /*
5390  * Cleanup fragments created during evaluation of the
5391  * "select" expression.
5392  */
5393  if (oldLocalFragmentTop != ctxt->localRVT)
5394  xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
5395  }
5396 
5397 #ifdef WITH_XSLT_DEBUG_PROCESS
5399  "xsltIf: test evaluate to %d\n", res));
5400 #endif
5401 
5402  if (res == -1) {
5403  ctxt->state = XSLT_STATE_STOPPED;
5404  goto error;
5405  }
5406  if (res == 1) {
5407  /*
5408  * Instantiate the sequence constructor of xsl:if.
5409  */
5411  contextNode, inst->children, NULL);
5412  }
5413 
5414 #else /* XSLT_FAST_IF */
5415  {
5416  /*
5417  * OLD CODE:
5418  */
5419  xmlXPathObjectPtr xpobj = xsltPreCompEval(ctxt, contextNode, comp);
5420  if (xpobj != NULL) {
5421  if (xpobj->type != XPATH_BOOLEAN)
5422  xpobj = xmlXPathConvertBoolean(xpobj);
5423  if (xpobj->type == XPATH_BOOLEAN) {
5424  res = xpobj->boolval;
5425 
5426 #ifdef WITH_XSLT_DEBUG_PROCESS
5428  "xsltIf: test evaluate to %d\n", res));
5429 #endif
5430  if (res) {
5432  contextNode, inst->children, NULL);
5433  }
5434  } else {
5435 
5436 #ifdef WITH_XSLT_DEBUG_PROCESS
5437  XSLT_TRACE(ctxt, XSLT_TRACE_IF,
5439  "xsltIf: test didn't evaluate to a boolean\n"));
5440 #endif
5441  ctxt->state = XSLT_STATE_STOPPED;
5442  }
5443  xmlXPathFreeObject(xpobj);
5444  } else {
5445  ctxt->state = XSLT_STATE_STOPPED;
5446  }
5447  }
5448 #endif /* else of XSLT_FAST_IF */
5449 
5450 error:
5451  return;
5452 }
#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:321
static int xsltPreCompEvalToBoolean(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
Definition: transform.c:370
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:2320
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:2268

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:608

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

2233 {
2234  if (ctxt->varsMax == 0) {
2235  ctxt->varsMax = 10;
2236  ctxt->varsTab =
2237  (xsltStackElemPtr *) xmlMalloc(ctxt->varsMax *
2238  sizeof(ctxt->varsTab[0]));
2239  if (ctxt->varsTab == NULL) {
2240  xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
2241  return (-1);
2242  }
2243  }
2244  if (ctxt->varsNr >= ctxt->varsMax) {
2245  ctxt->varsMax *= 2;
2246  ctxt->varsTab =
2248  ctxt->varsMax *
2249  sizeof(ctxt->varsTab[0]));
2250  if (ctxt->varsTab == NULL) {
2251  xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
2252  return (-1);
2253  }
2254  }
2255  ctxt->varsTab[ctxt->varsNr++] = variable;
2256  ctxt->vars = variable;
2257  variable->level = level;
2258  return(0);
2259 }
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 536 of file transform.c.

536  {
538  xsltDocumentPtr docu;
539  int i;
540 
541  xsltInitGlobals();
542 
544  if (cur == NULL) {
546  "xsltNewTransformContext : malloc failed\n");
547  return(NULL);
548  }
549  memset(cur, 0, sizeof(xsltTransformContext));
550 
552  if (cur->cache == NULL)
553  goto internal_err;
554  /*
555  * setup of the dictionary must be done early as some of the
556  * processing later like key handling may need it.
557  */
558  cur->dict = xmlDictCreateSub(style->dict);
559  cur->internalized = ((style->internalized) && (cur->dict != NULL));
560 #ifdef WITH_XSLT_DEBUG
562  "Creating sub-dictionary from stylesheet for transformation\n");
563 #endif
564 
565  /*
566  * initialize the template stack
567  */
568  cur->templTab = (xsltTemplatePtr *)
569  xmlMalloc(10 * sizeof(xsltTemplatePtr));
570  if (cur->templTab == NULL) {
572  "xsltNewTransformContext: out of memory\n");
573  goto internal_err;
574  }
575  cur->templNr = 0;
576  cur->templMax = 5;
577  cur->templ = NULL;
579 
580  /*
581  * initialize the variables stack
582  */
583  cur->varsTab = (xsltStackElemPtr *)
584  xmlMalloc(10 * sizeof(xsltStackElemPtr));
585  if (cur->varsTab == NULL) {
587  "xsltNewTransformContext: out of memory\n");
588  goto internal_err;
589  }
590  cur->varsNr = 0;
591  cur->varsMax = 10;
592  cur->vars = NULL;
593  cur->varsBase = 0;
595 
596  /*
597  * the profiling stack is not initialized by default
598  */
599  cur->profTab = NULL;
600  cur->profNr = 0;
601  cur->profMax = 0;
602  cur->prof = 0;
603 
604  cur->style = style;
605  xmlXPathInit();
606  cur->xpathCtxt = xmlXPathNewContext(doc);
607  if (cur->xpathCtxt == NULL) {
609  "xsltNewTransformContext : xmlXPathNewContext failed\n");
610  goto internal_err;
611  }
612  /*
613  * Create an XPath cache.
614  */
615  if (xmlXPathContextSetCache(cur->xpathCtxt, 1, -1, 0) == -1)
616  goto internal_err;
617  /*
618  * Initialize the extras array
619  */
620  if (style->extrasNr != 0) {
621  cur->extrasMax = style->extrasNr + 20;
622  cur->extras = (xsltRuntimeExtraPtr)
623  xmlMalloc(cur->extrasMax * sizeof(xsltRuntimeExtra));
624  if (cur->extras == NULL) {
626  "xsltNewTransformContext: out of memory\n");
627  goto internal_err;
628  }
629  cur->extrasNr = style->extrasNr;
630  for (i = 0;i < cur->extrasMax;i++) {
631  cur->extras[i].info = NULL;
632  cur->extras[i].deallocate = NULL;
633  cur->extras[i].val.ptr = NULL;
634  }
635  } else {
636  cur->extras = NULL;
637  cur->extrasNr = 0;
638  cur->extrasMax = 0;
639  }
640 
643  cur->xpathCtxt->nsHash = style->nsHash;
644  /*
645  * Initialize the registered external modules
646  */
647  xsltInitCtxtExts(cur);
648  /*
649  * Setup document element ordering for later efficiencies
650  * (bug 133289)
651  */
653  xmlXPathOrderDocElems(doc);
654  /*
655  * Must set parserOptions before calling xsltNewDocument
656  * (bug 164530)
657  */
659  docu = xsltNewDocument(cur, doc);
660  if (docu == NULL) {
662  "xsltNewTransformContext : xsltNewDocument failed\n");
663  goto internal_err;
664  }
665  docu->main = 1;
666  cur->document = docu;
667  cur->inst = NULL;
668  cur->outputFile = NULL;
671  cur->traceCode = (unsigned long*) &xsltDefaultTrace;
673  cur->keyInitLevel = 0;
674 
675  return(cur);
676 
677 internal_err:
678  if (cur != NULL)
680  return(NULL);
681 }
int xsltInitCtxtExts(xsltTransformContextPtr ctxt)
Definition: extensions.c:1016
xsltTransformCachePtr cache
xsltRuntimeExtraPtr extras
int xslDebugStatus
Definition: xsltutils.c:2329
xsltStackElemPtr vars
XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreateSub(xmlDictPtr sub)
Definition: dict.c:622
unsigned long * traceCode
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54
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
union _xsltRuntimeExtra::@3429 val
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:437
void xsltFreeTransformContext(xsltTransformContextPtr ctxt)
Definition: transform.c:690
xsltStackElemPtr * varsTab
static unsigned long xsltDefaultTrace
Definition: transform.c:441
xsltStylesheetPtr style
static xsltTransformCachePtr xsltTransformCacheCreate(void)
Definition: transform.c:471
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 4593 of file transform.c.

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

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

2108 {
2109  xsltTemplatePtr templ;
2110  xmlNodePtr oldNode;
2111 
2112  templ = xsltGetTemplate(ctxt, contextNode, NULL);
2113  /*
2114  * If no template is found, apply the default rule.
2115  */
2116  if (templ == NULL) {
2117 #ifdef WITH_XSLT_DEBUG_PROCESS
2118  if (contextNode->type == XML_DOCUMENT_NODE) {
2120  "xsltProcessOneNode: no template found for /\n"));
2121  } else if (contextNode->type == XML_CDATA_SECTION_NODE) {
2123  "xsltProcessOneNode: no template found for CDATA\n"));
2124  } else if (contextNode->type == XML_ATTRIBUTE_NODE) {
2126  "xsltProcessOneNode: no template found for attribute %s\n",
2127  ((xmlAttrPtr) contextNode)->name));
2128  } else {
2130  "xsltProcessOneNode: no template found for %s\n", contextNode->name));
2131  }
2132 #endif
2133  oldNode = ctxt->node;
2134  ctxt->node = contextNode;
2135  xsltDefaultProcessOneNode(ctxt, contextNode, withParams);
2136  ctxt->node = oldNode;
2137  return;
2138  }
2139 
2140  if (contextNode->type == XML_ATTRIBUTE_NODE) {
2141  xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
2142  /*
2143  * Set the "current template rule".
2144  */
2145  ctxt->currentTemplateRule = templ;
2146 
2147 #ifdef WITH_XSLT_DEBUG_PROCESS
2149  "xsltProcessOneNode: applying template '%s' for attribute %s\n",
2150  templ->match, contextNode->name));
2151 #endif
2152  xsltApplyXSLTTemplate(ctxt, contextNode, templ->content, templ, withParams);
2153 
2154  ctxt->currentTemplateRule = oldCurTempRule;
2155  } else {
2156  xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
2157  /*
2158  * Set the "current template rule".
2159  */
2160  ctxt->currentTemplateRule = templ;
2161 
2162 #ifdef WITH_XSLT_DEBUG_PROCESS
2163  if (contextNode->type == XML_DOCUMENT_NODE) {
2165  "xsltProcessOneNode: applying template '%s' for /\n",
2166  templ->match));
2167  } else {
2169  "xsltProcessOneNode: applying template '%s' for %s\n",
2170  templ->match, contextNode->name));
2171  }
2172 #endif
2173  xsltApplyXSLTTemplate(ctxt, contextNode, templ->content, templ, withParams);
2174 
2175  ctxt->currentTemplateRule = oldCurTempRule;
2176  }
2177 }
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:3068
xsltTemplatePtr xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylesheetPtr style)
Definition: pattern.c:2344
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
static void xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStackElemPtr params)
Definition: transform.c:1860
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:38
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 6266 of file transform.c.

6268 {
6269  xmlDocPtr res;
6270 
6272  return (res);
6273 }
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:5832
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 6410 of file transform.c.

6411 {
6412  xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-templates",
6415  xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-imports",
6418  xsltRegisterExtElement(ctxt, (const xmlChar *) "call-template",
6421  xsltRegisterExtElement(ctxt, (const xmlChar *) "element",
6423  xsltElement);
6424  xsltRegisterExtElement(ctxt, (const xmlChar *) "attribute",
6426  xsltAttribute);
6427  xsltRegisterExtElement(ctxt, (const xmlChar *) "text",
6429  xsltText);
6430  xsltRegisterExtElement(ctxt, (const xmlChar *) "processing-instruction",
6433  xsltRegisterExtElement(ctxt, (const xmlChar *) "comment",
6435  xsltComment);
6436  xsltRegisterExtElement(ctxt, (const xmlChar *) "copy",
6438  xsltCopy);
6439  xsltRegisterExtElement(ctxt, (const xmlChar *) "value-of",
6441  xsltValueOf);
6442  xsltRegisterExtElement(ctxt, (const xmlChar *) "number",
6444  xsltNumber);
6445  xsltRegisterExtElement(ctxt, (const xmlChar *) "for-each",
6447  xsltForEach);
6448  xsltRegisterExtElement(ctxt, (const xmlChar *) "if",
6450  xsltIf);
6451  xsltRegisterExtElement(ctxt, (const xmlChar *) "choose",
6453  xsltChoose);
6454  xsltRegisterExtElement(ctxt, (const xmlChar *) "sort",
6456  xsltSort);
6457  xsltRegisterExtElement(ctxt, (const xmlChar *) "copy-of",
6459  xsltCopyOf);
6460  xsltRegisterExtElement(ctxt, (const xmlChar *) "message",
6463 
6464  /*
6465  * Those don't have callable entry points but are registered anyway
6466  */
6467  xsltRegisterExtElement(ctxt, (const xmlChar *) "variable",
6469  xsltDebug);
6470  xsltRegisterExtElement(ctxt, (const xmlChar *) "param",
6472  xsltDebug);
6473  xsltRegisterExtElement(ctxt, (const xmlChar *) "with-param",
6475  xsltDebug);
6476  xsltRegisterExtElement(ctxt, (const xmlChar *) "decimal-format",
6478  xsltDebug);
6479  xsltRegisterExtElement(ctxt, (const xmlChar *) "when",
6481  xsltDebug);
6482  xsltRegisterExtElement(ctxt, (const xmlChar *) "otherwise",
6484  xsltDebug);
6485  xsltRegisterExtElement(ctxt, (const xmlChar *) "fallback",
6487  xsltDebug);
6488 
6489 }
void xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED