ReactOS  0.4.14-dev-606-g14ebc0b
transform.c File Reference
#include "precomp.h"
#include <libxml/debugXML.h>
Include dependency graph for transform.c:

Go to the source code of this file.

Classes

struct  xsltHTMLVersion
 

Macros

#define XSLT_GENERATE_HTML_DOCTYPE
 
#define FALSE   (0 == 1)
 
#define TRUE   (!FALSE)
 
#define IS_BLANK_NODE(n)   (((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
 

Typedefs

typedef struct xsltHTMLVersion xsltHTMLVersion
 

Functions

static int xsltGetHTMLIDs (const xmlChar *version, const xmlChar **publicID, const xmlChar **systemID)
 
static xmlNsPtr xsltCopyNamespaceListInternal (xmlNodePtr node, xmlNsPtr cur)
 
static xmlNodePtr xsltCopyTree (xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr node, xmlNodePtr insert, int isLRE, int topElemVisited)
 
static void xsltApplySequenceConstructor (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
 
static void xsltApplyXSLTTemplate (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ, xsltStackElemPtr withParams)
 
static int templPush (xsltTransformContextPtr ctxt, xsltTemplatePtr value)
 
static xsltTemplatePtr templPop (xsltTransformContextPtr ctxt)
 
void xsltLocalVariablePop (xsltTransformContextPtr ctxt, int limitNr, int level)
 
static void xsltTemplateParamsCleanup (xsltTransformContextPtr ctxt)
 
static int profPush (xsltTransformContextPtr ctxt, long value)
 
static long profPop (xsltTransformContextPtr ctxt)
 
static void profCallgraphAdd (xsltTemplatePtr templ, xsltTemplatePtr parent)
 
static xmlXPathObjectPtr xsltPreCompEval (xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
 
static int xsltPreCompEvalToBoolean (xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylePreCompPtr comp)
 
void xsltSetXIncludeDefault (int xinclude)
 
int xsltGetXIncludeDefault (void)
 
void xsltDebugSetDefaultTrace (xsltDebugTraceCodes val)
 
xsltDebugTraceCodes xsltDebugGetDefaultTrace ()
 
static xsltTransformCachePtr xsltTransformCacheCreate (void)
 
static void xsltTransformCacheFree (xsltTransformCachePtr cache)
 
xsltTransformContextPtr xsltNewTransformContext (xsltStylesheetPtr style, xmlDocPtr doc)
 
void xsltFreeTransformContext (xsltTransformContextPtr ctxt)
 
static xmlNodePtr xsltAddChild (xmlNodePtr parent, xmlNodePtr cur)
 
static xmlNodePtr xsltAddTextString (xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int len)
 
xmlNodePtr xsltCopyTextString (xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int noescape)
 
static xmlNodePtr xsltCopyText (xsltTransformContextPtr ctxt, xmlNodePtr target, xmlNodePtr cur, int interned)
 
static xmlAttrPtr xsltShallowCopyAttr (xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr target, xmlAttrPtr attr)
 
static int xsltCopyAttrListNoOverwrite (xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr target, xmlAttrPtr attr)
 
static xmlNodePtr xsltShallowCopyElem (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr insert, int isLRE)
 
static xmlNodePtr xsltCopyTreeList (xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr list, xmlNodePtr insert, int isLRE, int topElemVisited)
 
static xmlNsPtr xsltShallowCopyNsNode (xsltTransformContextPtr ctxt, xmlNodePtr invocNode, xmlNodePtr insert, xmlNsPtr ns)
 
static int xsltApplyFallbacks (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst)
 
static void xsltDefaultProcessOneNode (xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStackElemPtr params)
 
void xsltProcessOneNode (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xsltStackElemPtr withParams)
 
static xmlNodePtr xsltDebuggerStartSequenceConstructor (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ, int *addCallResult)
 
int xsltLocalVariablePush (xsltTransformContextPtr ctxt, xsltStackElemPtr variable, int level)
 
static void xsltReleaseLocalRVTs (xsltTransformContextPtr ctxt, xmlDocPtr base)
 
void xsltApplyOneTemplate (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ ATTRIBUTE_UNUSED, xsltStackElemPtr params)
 
void xsltDocumentElem (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltSort (xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
void xsltCopy (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltText (xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
 
void xsltElement (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltComment (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
 
void xsltProcessingInstruction (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltCopyOf (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltValueOf (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltNumber (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltApplyImports (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
 
void xsltCallTemplate (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltApplyTemplates (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltChoose (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
 
void xsltIf (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltForEach (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
 
void xsltApplyStripSpaces (xsltTransformContextPtr ctxt, xmlNodePtr node)
 
static int xsltCountKeys (xsltTransformContextPtr ctxt)
 
static xmlDocPtr xsltApplyStylesheetInternal (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, FILE *profile, xsltTransformContextPtr userCtxt)
 
xmlDocPtr xsltApplyStylesheet (xsltStylesheetPtr style, xmlDocPtr doc, const char **params)
 
xmlDocPtr xsltProfileStylesheet (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, FILE *output)
 
xmlDocPtr xsltApplyStylesheetUser (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, FILE *profile, xsltTransformContextPtr userCtxt)
 
int xsltRunStylesheetUser (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf, FILE *profile, xsltTransformContextPtr userCtxt)
 
int xsltRunStylesheet (xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf)
 
static void xsltMessageWrapper (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
 
void xsltRegisterAllElement (xsltTransformContextPtr ctxt)
 

Variables

int xsltMaxDepth = 3000
 
int xsltMaxVars = 15000
 
static int xsltDoXIncludeDefault = 0
 
static unsigned long xsltDefaultTrace = (unsigned long) XSLT_TRACE_ALL
 
static xsltHTMLVersion xsltHTMLVersions []
 

Macro Definition Documentation

◆ FALSE

#define FALSE   (0 == 1)

Definition at line 43 of file transform.c.

◆ IS_BLANK_NODE

#define IS_BLANK_NODE (   n)    (((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))

Definition at line 47 of file transform.c.

◆ TRUE

#define TRUE   (!FALSE)

Definition at line 44 of file transform.c.

◆ XSLT_GENERATE_HTML_DOCTYPE

#define XSLT_GENERATE_HTML_DOCTYPE

Definition at line 29 of file transform.c.

Typedef Documentation

◆ xsltHTMLVersion

Function Documentation

◆ profCallgraphAdd()

static void profCallgraphAdd ( xsltTemplatePtr  templ,
xsltTemplatePtr  parent 
)
static

Definition at line 261 of file transform.c.

262 {
263  int i;
264 
265  if (templ->templMax == 0) {
266  templ->templMax = 4;
267  templ->templCalledTab =
268  (xsltTemplatePtr *) xmlMalloc(templ->templMax *
269  sizeof(templ->templCalledTab[0]));
270  templ->templCountTab =
271  (int *) xmlMalloc(templ->templMax *
272  sizeof(templ->templCountTab[0]));
273  if (templ->templCalledTab == NULL || templ->templCountTab == NULL) {
274  xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
275  return;
276  }
277  }
278  else if (templ->templNr >= templ->templMax) {
279  templ->templMax *= 2;
280  templ->templCalledTab =
282  templ->templMax *
283  sizeof(templ->templCalledTab[0]));
284  templ->templCountTab =
285  (int *) xmlRealloc(templ->templCountTab,
286  templ->templMax *
287  sizeof(templ->templCountTab[0]));
288  if (templ->templCalledTab == NULL || templ->templCountTab == NULL) {
289  xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
290  return;
291  }
292  }
293 
294  for (i = 0; i < templ->templNr; i++) {
295  if (templ->templCalledTab[i] == parent) {
296  templ->templCountTab[i]++;
297  break;
298  }
299  }
300  if (i == templ->templNr) {
301  /* not found, add new one */
302  templ->templCalledTab[templ->templNr] = parent;
303  templ->templCountTab[templ->templNr] = 1;
304  templ->templNr++;
305  }
306 }
xsltTemplatePtr * templCalledTab
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
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
r parent
Definition: btrfs.c:2869
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xsltApplyXSLTTemplate().

◆ profPop()

static long profPop ( xsltTransformContextPtr  ctxt)
static

profPop: @ctxt: the transformation context

Pop a profiling value from the stack

Returns the stored profiling value

Definition at line 244 of file transform.c.

245 {
246  long ret;
247 
248  if (ctxt->profNr <= 0)
249  return (0);
250  ctxt->profNr--;
251  if (ctxt->profNr > 0)
252  ctxt->prof = ctxt->profTab[ctxt->profNr - 1];
253  else
254  ctxt->prof = (long) 0;
255  ret = ctxt->profTab[ctxt->profNr];
256  ctxt->profTab[ctxt->profNr] = 0;
257  return (ret);
258 }
int ret
#define long
Definition: qsort.c:33

Referenced by xsltApplyXSLTTemplate().

◆ profPush()

static int profPush ( xsltTransformContextPtr  ctxt,
long  value 
)
static

profPush: @ctxt: the transformation context @value: the profiling value to push on the stack

Push a profiling value on the stack

Returns the new index in the stack or 0 in case of error

Definition at line 210 of file transform.c.

211 {
212  if (ctxt->profMax == 0) {
213  ctxt->profMax = 4;
214  ctxt->profTab =
215  (long *) xmlMalloc(ctxt->profMax * sizeof(ctxt->profTab[0]));
216  if (ctxt->profTab == NULL) {
217  xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
218  return (0);
219  }
220  }
221  else if (ctxt->profNr >= ctxt->profMax) {
222  ctxt->profMax *= 2;
223  ctxt->profTab =
224  (long *) xmlRealloc(ctxt->profTab,
225  ctxt->profMax * sizeof(ctxt->profTab[0]));
226  if (ctxt->profTab == NULL) {
227  xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
228  return (0);
229  }
230  }
231  ctxt->profTab[ctxt->profNr] = value;
232  ctxt->prof = value;
233  return (ctxt->profNr++);
234 }
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
GLsizei const GLfloat * value
Definition: glext.h:6069
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xsltApplyXSLTTemplate().

◆ templPop()

static xsltTemplatePtr templPop ( xsltTransformContextPtr  ctxt)
static

templPop: @ctxt: the transformation context

Pop a template value from the stack

Returns the stored template value

Definition at line 121 of file transform.c.

122 {
124 
125  if (ctxt->templNr <= 0)
126  return (0);
127  ctxt->templNr--;
128  if (ctxt->templNr > 0)
129  ctxt->templ = ctxt->templTab[ctxt->templNr - 1];
130  else
131  ctxt->templ = (xsltTemplatePtr) 0;
132  ret = ctxt->templTab[ctxt->templNr];
133  ctxt->templTab[ctxt->templNr] = 0;
134  return (ret);
135 }
xsltTemplate * xsltTemplatePtr
xsltTemplatePtr * templTab
xsltTemplatePtr templ
int ret

Referenced by xsltApplyXSLTTemplate().

◆ templPush()

static int templPush ( xsltTransformContextPtr  ctxt,
xsltTemplatePtr  value 
)
static

templPush: @ctxt: the transformation context @value: the template to push on the stack

Push a template on the stack

Returns the new index in the stack or 0 in case of error

Definition at line 85 of file transform.c.

86 {
87  if (ctxt->templMax == 0) {
88  ctxt->templMax = 4;
89  ctxt->templTab =
91  sizeof(ctxt->templTab[0]));
92  if (ctxt->templTab == NULL) {
93  xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
94  return (0);
95  }
96  }
97  else if (ctxt->templNr >= ctxt->templMax) {
98  ctxt->templMax *= 2;
99  ctxt->templTab =
101  ctxt->templMax *
102  sizeof(ctxt->templTab[0]));
103  if (ctxt->templTab == NULL) {
104  xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
105  return (0);
106  }
107  }
108  ctxt->templTab[ctxt->templNr] = value;
109  ctxt->templ = value;
110  return (ctxt->templNr++);
111 }
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
xsltTemplatePtr * templTab
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
xsltTemplatePtr templ
GLsizei const GLfloat * value
Definition: glext.h:6069
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xsltApplyXSLTTemplate().

◆ xsltAddChild()

static xmlNodePtr xsltAddChild ( xmlNodePtr  parent,
xmlNodePtr  cur 
)
static

xsltAddChild: @parent: the parent node @cur: the child node

Wrapper version of xmlAddChild with a more consistent behaviour on error. One expect the use to be child = xsltAddChild(parent, child); and the routine will take care of not leaking on errors or node merge

Returns the child is successfully attached or NULL if merged or freed

Definition at line 748 of file transform.c.

748  {
749  xmlNodePtr ret;
750 
751  if (cur == NULL)
752  return(NULL);
753  if (parent == NULL) {
754  xmlFreeNode(cur);
755  return(NULL);
756  }
757  ret = xmlAddChild(parent, cur);
758 
759  return(ret);
760 }
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
r parent
Definition: btrfs.c:2869
Definition: tree.h:489
int ret
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)

Referenced by xsltApplySequenceConstructor(), xsltComment(), xsltCopy(), xsltCopyText(), xsltCopyTextString(), xsltCopyTree(), xsltElement(), xsltProcessingInstruction(), xsltShallowCopyElem(), and xsltText().

◆ xsltAddTextString()

static xmlNodePtr xsltAddTextString ( xsltTransformContextPtr  ctxt,
xmlNodePtr  target,
const xmlChar string,
int  len 
)
static

xsltAddTextString: @ctxt: a XSLT process context @target: the text node where the text will be attached @string: the text string @len: the string length in byte

Extend the current text node with the new string, it handles coalescing

Returns: the text node

Definition at line 774 of file transform.c.

775  {
776  /*
777  * optimization
778  */
779  if ((len <= 0) || (string == NULL) || (target == NULL))
780  return(target);
781 
782  if (ctxt->lasttext == target->content) {
783  int minSize;
784 
785  /* Check for integer overflow accounting for NUL terminator. */
786  if (len >= INT_MAX - ctxt->lasttuse) {
788  "xsltCopyText: text allocation failed\n");
789  return(NULL);
790  }
791  minSize = ctxt->lasttuse + len + 1;
792 
793  if (ctxt->lasttsize < minSize) {
794  xmlChar *newbuf;
795  int size;
796  int extra;
797 
798  /* Double buffer size but increase by at least 100 bytes. */
799  extra = minSize < 100 ? 100 : minSize;
800 
801  /* Check for integer overflow. */
802  if (extra > INT_MAX - ctxt->lasttsize) {
803  size = INT_MAX;
804  }
805  else {
806  size = ctxt->lasttsize + extra;
807  }
808 
809  newbuf = (xmlChar *) xmlRealloc(target->content,size);
810  if (newbuf == NULL) {
812  "xsltCopyText: text allocation failed\n");
813  return(NULL);
814  }
815  ctxt->lasttsize = size;
816  ctxt->lasttext = newbuf;
817  target->content = newbuf;
818  }
819  memcpy(&(target->content[ctxt->lasttuse]), string, len);
820  ctxt->lasttuse += len;
821  target->content[ctxt->lasttuse] = 0;
822  } else {
823  xmlNodeAddContent(target, string);
824  ctxt->lasttext = target->content;
825  len = xmlStrlen(target->content);
826  ctxt->lasttsize = len;
827  ctxt->lasttuse = len;
828  }
829  return(target);
830 }
XMLPUBFUN void XMLCALL xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content)
#define INT_MAX
Definition: limits.h:40
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
GLsizeiptr size
Definition: glext.h:5919
Definition: id3.c:18
const xmlChar * lasttext
unsigned char xmlChar
Definition: xmlstring.h:28
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLenum target
Definition: glext.h:7315
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

Referenced by xsltCopyText(), and xsltCopyTextString().

◆ xsltApplyFallbacks()

static int xsltApplyFallbacks ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst 
)
static

xsltApplyFallbacks: @ctxt: a XSLT process context @node: the node in the source tree. @inst: the node generating the error

Process possible xsl:fallback nodes present under @inst

Returns the number of xsl:fallback element found and processed

Definition at line 1798 of file transform.c.

1799  {
1800 
1801  xmlNodePtr child;
1802  int ret = 0;
1803 
1804  if ((ctxt == NULL) || (node == NULL) || (inst == NULL) ||
1805  (inst->children == NULL))
1806  return(0);
1807 
1808  child = inst->children;
1809  while (child != NULL) {
1810  if ((IS_XSLT_ELEM(child)) &&
1811  (xmlStrEqual(child->name, BAD_CAST "fallback"))) {
1812 #ifdef WITH_XSLT_DEBUG_PARSING
1814  "applying xsl:fallback\n");
1815 #endif
1816  ret++;
1817  xsltApplySequenceConstructor(ctxt, node, child->children,
1818  NULL);
1819  }
1820  child = child->next;
1821  }
1822  return(ret);
1823 }
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
static HWND child
Definition: cursoricon.c:298
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
int ret
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
struct _xmlNode * children
Definition: tree.h:493
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
Definition: dlist.c:348

Referenced by xsltApplySequenceConstructor().

◆ xsltApplyImports()

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

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

Process the XSLT apply-imports element.

Definition at line 4619 of file transform.c.

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

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltApplyOneTemplate()

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

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

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

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

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

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

Called by:

Definition at line 3285 of file transform.c.

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

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

◆ xsltApplySequenceConstructor()

static void xsltApplySequenceConstructor ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  list,
xsltTemplatePtr  templ 
)
static

xsltApplySequenceConstructor: @ctxt: a XSLT process context @contextNode: the "current node" in the source tree @list: the nodes of a sequence constructor; (plus leading xsl:param elements) @templ: the compiled xsl:template (optional)

Processes a sequence constructor.

NOTE: ctxt->currentTemplateRule was introduced to reflect the semantics of "current template rule". I.e. the field ctxt->templ is not intended to reflect this, thus always pushed onto the template stack.

Definition at line 2312 of file transform.c.

2315 {
2316  xmlNodePtr oldInsert, oldInst, oldCurInst, oldContextNode;
2317  xmlNodePtr cur, insert, copy = NULL;
2318  int level = 0, oldVarsNr;
2319  xmlDocPtr oldLocalFragmentTop;
2320 
2321 #ifdef XSLT_REFACTORED
2323 #endif
2324 
2325 #ifdef WITH_DEBUGGER
2326  int addCallResult = 0;
2327  xmlNodePtr debuggedNode = NULL;
2328 #endif
2329 
2330  if (ctxt == NULL)
2331  return;
2332 
2333 #ifdef WITH_DEBUGGER
2334  if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
2335  debuggedNode =
2336  xsltDebuggerStartSequenceConstructor(ctxt, contextNode,
2337  list, templ, &addCallResult);
2338  if (debuggedNode == NULL)
2339  return;
2340  }
2341 #endif
2342 
2343  if (list == NULL)
2344  return;
2345  CHECK_STOPPED;
2346 
2347  /*
2348  * Check for infinite recursion: stop if the maximum of nested templates
2349  * is excceeded. Adjust xsltMaxDepth if you need more.
2350  */
2351  if (ctxt->depth >= ctxt->maxTemplateDepth) {
2352  xsltTransformError(ctxt, NULL, list,
2353  "xsltApplySequenceConstructor: A potential infinite template "
2354  "recursion was detected.\n"
2355  "You can adjust xsltMaxDepth (--maxdepth) in order to "
2356  "raise the maximum number of nested template calls and "
2357  "variables/params (currently set to %d).\n",
2358  ctxt->maxTemplateDepth);
2359  xsltDebug(ctxt, contextNode, list, NULL);
2360  ctxt->state = XSLT_STATE_STOPPED;
2361  return;
2362  }
2363  ctxt->depth++;
2364 
2365  oldLocalFragmentTop = ctxt->localRVT;
2366  oldInsert = insert = ctxt->insert;
2367  oldInst = oldCurInst = ctxt->inst;
2368  oldContextNode = ctxt->node;
2369  /*
2370  * Save current number of variables on the stack; new vars are popped when
2371  * exiting.
2372  */
2373  oldVarsNr = ctxt->varsNr;
2374  /*
2375  * Process the sequence constructor.
2376  */
2377  cur = list;
2378  while (cur != NULL) {
2379  ctxt->inst = cur;
2380 
2381 #ifdef WITH_DEBUGGER
2382  switch (ctxt->debugStatus) {
2384  case XSLT_DEBUG_QUIT:
2385  break;
2386 
2387  }
2388 #endif
2389  /*
2390  * Test; we must have a valid insertion point.
2391  */
2392  if (insert == NULL) {
2393 
2394 #ifdef WITH_XSLT_DEBUG_PROCESS
2396  "xsltApplySequenceConstructor: insert == NULL !\n"));
2397 #endif
2398  goto error;
2399  }
2400 
2401 #ifdef WITH_DEBUGGER
2402  if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (debuggedNode != cur))
2403  xslHandleDebugger(cur, contextNode, templ, ctxt);
2404 #endif
2405 
2406 #ifdef XSLT_REFACTORED
2407  if (cur->type == XML_ELEMENT_NODE) {
2408  info = (xsltStylePreCompPtr) cur->psvi;
2409  /*
2410  * We expect a compiled representation on:
2411  * 1) XSLT instructions of this XSLT version (1.0)
2412  * (with a few exceptions)
2413  * 2) Literal result elements
2414  * 3) Extension instructions
2415  * 4) XSLT instructions of future XSLT versions
2416  * (forwards-compatible mode).
2417  */
2418  if (info == NULL) {
2419  /*
2420  * Handle the rare cases where we don't expect a compiled
2421  * representation on an XSLT element.
2422  */
2423  if (IS_XSLT_ELEM_FAST(cur) && IS_XSLT_NAME(cur, "message")) {
2424  xsltMessage(ctxt, contextNode, cur);
2425  goto skip_children;
2426  }
2427  /*
2428  * Something really went wrong:
2429  */
2430  xsltTransformError(ctxt, NULL, cur,
2431  "Internal error in xsltApplySequenceConstructor(): "
2432  "The element '%s' in the stylesheet has no compiled "
2433  "representation.\n",
2434  cur->name);
2435  goto skip_children;
2436  }
2437 
2438  if (info->type == XSLT_FUNC_LITERAL_RESULT_ELEMENT) {
2439  xsltStyleItemLRElementInfoPtr lrInfo =
2440  (xsltStyleItemLRElementInfoPtr) info;
2441  /*
2442  * Literal result elements
2443  * --------------------------------------------------------
2444  */
2445 #ifdef WITH_XSLT_DEBUG_PROCESS
2448  "xsltApplySequenceConstructor: copy literal result "
2449  "element '%s'\n", cur->name));
2450 #endif
2451  /*
2452  * Copy the raw element-node.
2453  * OLD: if ((copy = xsltShallowCopyElem(ctxt, cur, insert))
2454  * == NULL)
2455  * goto error;
2456  */
2457  copy = xmlDocCopyNode(cur, insert->doc, 0);
2458  if (copy == NULL) {
2459  xsltTransformError(ctxt, NULL, cur,
2460  "Internal error in xsltApplySequenceConstructor(): "
2461  "Failed to copy literal result element '%s'.\n",
2462  cur->name);
2463  goto error;
2464  } else {
2465  /*
2466  * Add the element-node to the result tree.
2467  */
2468  copy->doc = ctxt->output;
2470  /*
2471  * Create effective namespaces declarations.
2472  * OLD: xsltCopyNamespaceList(ctxt, copy, cur->nsDef);
2473  */
2474  if (lrInfo->effectiveNs != NULL) {
2475  xsltEffectiveNsPtr effNs = lrInfo->effectiveNs;
2476  xmlNsPtr ns, lastns = NULL;
2477 
2478  while (effNs != NULL) {
2479  /*
2480  * Avoid generating redundant namespace
2481  * declarations; thus lookup if there is already
2482  * such a ns-decl in the result.
2483  */
2484  ns = xmlSearchNs(copy->doc, copy, effNs->prefix);
2485  if ((ns != NULL) &&
2486  (xmlStrEqual(ns->href, effNs->nsName)))
2487  {
2488  effNs = effNs->next;
2489  continue;
2490  }
2491  ns = xmlNewNs(copy, effNs->nsName, effNs->prefix);
2492  if (ns == NULL) {
2493  xsltTransformError(ctxt, NULL, cur,
2494  "Internal error in "
2495  "xsltApplySequenceConstructor(): "
2496  "Failed to copy a namespace "
2497  "declaration.\n");
2498  goto error;
2499  }
2500 
2501  if (lastns == NULL)
2502  copy->nsDef = ns;
2503  else
2504  lastns->next =ns;
2505  lastns = ns;
2506 
2507  effNs = effNs->next;
2508  }
2509 
2510  }
2511  /*
2512  * NOTE that we don't need to apply ns-alising: this was
2513  * already done at compile-time.
2514  */
2515  if (cur->ns != NULL) {
2516  /*
2517  * If there's no such ns-decl in the result tree,
2518  * then xsltGetSpecialNamespace() will
2519  * create a ns-decl on the copied node.
2520  */
2521  copy->ns = xsltGetSpecialNamespace(ctxt, cur,
2522  cur->ns->href, cur->ns->prefix, copy);
2523  } else {
2524  /*
2525  * Undeclare the default namespace if needed.
2526  * This can be skipped, if the result element has
2527  * no ns-decls, in which case the result element
2528  * obviously does not declare a default namespace;
2529  * AND there's either no parent, or the parent
2530  * element is in no namespace; this means there's no
2531  * default namespace is scope to care about.
2532  *
2533  * REVISIT: This might result in massive
2534  * generation of ns-decls if nodes in a default
2535  * namespaces are mixed with nodes in no namespace.
2536  *
2537  */
2538  if (copy->nsDef ||
2539  ((insert != NULL) &&
2540  (insert->type == XML_ELEMENT_NODE) &&
2541  (insert->ns != NULL)))
2542  {
2543  xsltGetSpecialNamespace(ctxt, cur,
2544  NULL, NULL, copy);
2545  }
2546  }
2547  }
2548  /*
2549  * SPEC XSLT 2.0 "Each attribute of the literal result
2550  * element, other than an attribute in the XSLT namespace,
2551  * is processed to produce an attribute for the element in
2552  * the result tree."
2553  * NOTE: See bug #341325.
2554  */
2555  if (cur->properties != NULL) {
2557  }
2558  } else if (IS_XSLT_ELEM_FAST(cur)) {
2559  /*
2560  * XSLT instructions
2561  * --------------------------------------------------------
2562  */
2563  if (info->type == XSLT_FUNC_UNKOWN_FORWARDS_COMPAT) {
2564  /*
2565  * We hit an unknown XSLT element.
2566  * Try to apply one of the fallback cases.
2567  */
2568  ctxt->insert = insert;
2569  if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
2570  xsltTransformError(ctxt, NULL, cur,
2571  "The is no fallback behaviour defined for "
2572  "the unknown XSLT element '%s'.\n",
2573  cur->name);
2574  }
2575  ctxt->insert = oldInsert;
2576  } else if (info->func != NULL) {
2577  /*
2578  * Execute the XSLT instruction.
2579  */
2580  ctxt->insert = insert;
2581 
2582  info->func(ctxt, contextNode, cur,
2584 
2585  /*
2586  * Cleanup temporary tree fragments.
2587  */
2588  if (oldLocalFragmentTop != ctxt->localRVT)
2589  xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
2590 
2591  ctxt->insert = oldInsert;
2592  } else if (info->type == XSLT_FUNC_VARIABLE) {
2593  xsltStackElemPtr tmpvar = ctxt->vars;
2594 
2595  xsltParseStylesheetVariable(ctxt, cur);
2596 
2597  if (tmpvar != ctxt->vars) {
2598  /*
2599  * TODO: Using a @tmpvar is an annoying workaround, but
2600  * the current mechanisms do not provide any other way
2601  * of knowing if the var was really pushed onto the
2602  * stack.
2603  */
2604  ctxt->vars->level = level;
2605  }
2606  } else if (info->type == XSLT_FUNC_MESSAGE) {
2607  /*
2608  * TODO: Won't be hit, since we don't compile xsl:message.
2609  */
2610  xsltMessage(ctxt, contextNode, cur);
2611  } else {
2612  xsltTransformError(ctxt, NULL, cur,
2613  "Unexpected XSLT element '%s'.\n", cur->name);
2614  }
2615  goto skip_children;
2616 
2617  } else {
2619  /*
2620  * Extension intructions (elements)
2621  * --------------------------------------------------------
2622  */
2623  if (cur->psvi == xsltExtMarker) {
2624  /*
2625  * The xsltExtMarker was set during the compilation
2626  * of extension instructions if there was no registered
2627  * handler for this specific extension function at
2628  * compile-time.
2629  * Libxslt will now lookup if a handler is
2630  * registered in the context of this transformation.
2631  */
2632  func = xsltExtElementLookup(ctxt, cur->name,
2633  cur->ns->href);
2634  } else
2635  func = ((xsltElemPreCompPtr) cur->psvi)->func;
2636 
2637  if (func == NULL) {
2638  /*
2639  * No handler available.
2640  * Try to execute fallback behaviour via xsl:fallback.
2641  */
2642 #ifdef WITH_XSLT_DEBUG_PROCESS
2645  "xsltApplySequenceConstructor: unknown extension %s\n",
2646  cur->name));
2647 #endif
2648  ctxt->insert = insert;
2649  if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
2650  xsltTransformError(ctxt, NULL, cur,
2651  "Unknown extension instruction '{%s}%s'.\n",
2652  cur->ns->href, cur->name);
2653  }
2654  ctxt->insert = oldInsert;
2655  } else {
2656  /*
2657  * Execute the handler-callback.
2658  */
2659 #ifdef WITH_XSLT_DEBUG_PROCESS
2661  "xsltApplySequenceConstructor: extension construct %s\n",
2662  cur->name));
2663 #endif
2664  /*
2665  * Disable the xsltCopyTextString optimization for
2666  * extension elements. Extensions could append text using
2667  * xmlAddChild which will free the buffer pointed to by
2668  * 'lasttext'. This buffer could later be reallocated with
2669  * a different size than recorded in 'lasttsize'. See bug
2670  * #777432.
2671  */
2672  if (cur->psvi == xsltExtMarker) {
2673  ctxt->lasttext = NULL;
2674  }
2675 
2676  ctxt->insert = insert;
2677 
2678  func(ctxt, contextNode, cur, cur->psvi);
2679 
2680  /*
2681  * Cleanup temporary tree fragments.
2682  */
2683  if (oldLocalFragmentTop != ctxt->localRVT)
2684  xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
2685 
2686  ctxt->insert = oldInsert;
2687  }
2688  goto skip_children;
2689  }
2690 
2691  } else if (XSLT_IS_TEXT_NODE(cur)) {
2692  /*
2693  * Text
2694  * ------------------------------------------------------------
2695  */
2696 #ifdef WITH_XSLT_DEBUG_PROCESS
2697  if (cur->name == xmlStringTextNoenc) {
2700  "xsltApplySequenceConstructor: copy unescaped text '%s'\n",
2701  cur->content));
2702  } else {
2705  "xsltApplySequenceConstructor: copy text '%s'\n",
2706  cur->content));
2707  }
2708 #endif
2709  if (xsltCopyText(ctxt, insert, cur, ctxt->internalized) == NULL)
2710  goto error;
2711  }
2712 
2713 #else /* XSLT_REFACTORED */
2714 
2715  if (IS_XSLT_ELEM(cur)) {
2716  /*
2717  * This is an XSLT node
2718  */
2720 
2721  if (info == NULL) {
2722  if (IS_XSLT_NAME(cur, "message")) {
2723  xsltMessage(ctxt, contextNode, cur);
2724  } else {
2725  /*
2726  * That's an error try to apply one of the fallback cases
2727  */
2728  ctxt->insert = insert;
2729  if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
2731  "xsltApplySequenceConstructor: %s was not compiled\n",
2732  cur->name);
2733  }
2734  ctxt->insert = oldInsert;
2735  }
2736  goto skip_children;
2737  }
2738 
2739  if (info->func != NULL) {
2740  oldCurInst = ctxt->inst;
2741  ctxt->inst = cur;
2742  ctxt->insert = insert;
2743 
2744  info->func(ctxt, contextNode, cur, (xsltElemPreCompPtr) info);
2745 
2746  /*
2747  * Cleanup temporary tree fragments.
2748  */
2749  if (oldLocalFragmentTop != ctxt->localRVT)
2750  xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
2751 
2752  ctxt->insert = oldInsert;
2753  ctxt->inst = oldCurInst;
2754  goto skip_children;
2755  }
2756 
2757  if (IS_XSLT_NAME(cur, "variable")) {
2758  xsltStackElemPtr tmpvar = ctxt->vars;
2759 
2760  oldCurInst = ctxt->inst;
2761  ctxt->inst = cur;
2762 
2763  xsltParseStylesheetVariable(ctxt, cur);
2764 
2765  ctxt->inst = oldCurInst;
2766 
2767  if (tmpvar != ctxt->vars) {
2768  /*
2769  * TODO: Using a @tmpvar is an annoying workaround, but
2770  * the current mechanisms do not provide any other way
2771  * of knowing if the var was really pushed onto the
2772  * stack.
2773  */
2774  ctxt->vars->level = level;
2775  }
2776  } else if (IS_XSLT_NAME(cur, "message")) {
2777  xsltMessage(ctxt, contextNode, cur);
2778  } else {
2779  xsltTransformError(ctxt, NULL, cur,
2780  "Unexpected XSLT element '%s'.\n", cur->name);
2781  }
2782  goto skip_children;
2783  } else if ((cur->type == XML_TEXT_NODE) ||
2784  (cur->type == XML_CDATA_SECTION_NODE)) {
2785 
2786  /*
2787  * This text comes from the stylesheet
2788  * For stylesheets, the set of whitespace-preserving
2789  * element names consists of just xsl:text.
2790  */
2791 #ifdef WITH_XSLT_DEBUG_PROCESS
2792  if (cur->type == XML_CDATA_SECTION_NODE) {
2794  "xsltApplySequenceConstructor: copy CDATA text %s\n",
2795  cur->content));
2796  } else if (cur->name == xmlStringTextNoenc) {
2798  "xsltApplySequenceConstructor: copy unescaped text %s\n",
2799  cur->content));
2800  } else {
2802  "xsltApplySequenceConstructor: copy text %s\n",
2803  cur->content));
2804  }
2805 #endif
2806  if (xsltCopyText(ctxt, insert, cur, ctxt->internalized) == NULL)
2807  goto error;
2808  } else if ((cur->type == XML_ELEMENT_NODE) &&
2809  (cur->ns != NULL) && (cur->psvi != NULL)) {
2810  xsltTransformFunction function;
2811 
2812  oldCurInst = ctxt->inst;
2813  ctxt->inst = cur;
2814  /*
2815  * Flagged as an extension element
2816  */
2817  if (cur->psvi == xsltExtMarker)
2818  function = xsltExtElementLookup(ctxt, cur->name,
2819  cur->ns->href);
2820  else
2821  function = ((xsltElemPreCompPtr) cur->psvi)->func;
2822 
2823  if (function == NULL) {
2824  xmlNodePtr child;
2825  int found = 0;
2826 
2827 #ifdef WITH_XSLT_DEBUG_PROCESS
2829  "xsltApplySequenceConstructor: unknown extension %s\n",
2830  cur->name));
2831 #endif
2832  /*
2833  * Search if there are fallbacks
2834  */
2835  child = cur->children;
2836  while (child != NULL) {
2837  if ((IS_XSLT_ELEM(child)) &&
2838  (IS_XSLT_NAME(child, "fallback")))
2839  {
2840  found = 1;
2841  xsltApplySequenceConstructor(ctxt, contextNode,
2842  child->children, NULL);
2843  }
2844  child = child->next;
2845  }
2846 
2847  if (!found) {
2848  xsltTransformError(ctxt, NULL, cur,
2849  "xsltApplySequenceConstructor: failed to find extension %s\n",
2850  cur->name);
2851  }
2852  } else {
2853 #ifdef WITH_XSLT_DEBUG_PROCESS
2855  "xsltApplySequenceConstructor: extension construct %s\n",
2856  cur->name));
2857 #endif
2858 
2859  /*
2860  * Disable the xsltCopyTextString optimization for
2861  * extension elements. Extensions could append text using
2862  * xmlAddChild which will free the buffer pointed to by
2863  * 'lasttext'. This buffer could later be reallocated with
2864  * a different size than recorded in 'lasttsize'. See bug
2865  * #777432.
2866  */
2867  if (cur->psvi == xsltExtMarker) {
2868  ctxt->lasttext = NULL;
2869  }
2870 
2871  ctxt->insert = insert;
2872 
2873  function(ctxt, contextNode, cur, cur->psvi);
2874  /*
2875  * Cleanup temporary tree fragments.
2876  */
2877  if (oldLocalFragmentTop != ctxt->localRVT)
2878  xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
2879 
2880  ctxt->insert = oldInsert;
2881 
2882  }
2883  ctxt->inst = oldCurInst;
2884  goto skip_children;
2885  } else if (cur->type == XML_ELEMENT_NODE) {
2886 #ifdef WITH_XSLT_DEBUG_PROCESS
2888  "xsltApplySequenceConstructor: copy node %s\n",
2889  cur->name));
2890 #endif
2891  oldCurInst = ctxt->inst;
2892  ctxt->inst = cur;
2893 
2894  if ((copy = xsltShallowCopyElem(ctxt, cur, insert, 1)) == NULL)
2895  goto error;
2896  /*
2897  * Add extra namespaces inherited from the current template
2898  * if we are in the first level children and this is a
2899  * "real" template.
2900  */
2901  if ((templ != NULL) && (oldInsert == insert) &&
2902  (ctxt->templ != NULL) && (ctxt->templ->inheritedNs != NULL)) {
2903  int i;
2904  xmlNsPtr ns, ret;
2905 
2906  for (i = 0; i < ctxt->templ->inheritedNsNr; i++) {
2907  const xmlChar *URI = NULL;
2909  ns = ctxt->templ->inheritedNs[i];
2910 
2911  /* Note that the XSLT namespace was already excluded
2912  * in xsltGetInheritedNsList().
2913  */
2914 #if 0
2915  if (xmlStrEqual(ns->href, XSLT_NAMESPACE))
2916  continue;
2917 #endif
2918  style = ctxt->style;
2919  while (style != NULL) {
2920  if (style->nsAliases != NULL)
2921  URI = (const xmlChar *)
2922  xmlHashLookup(style->nsAliases, ns->href);
2923  if (URI != NULL)
2924  break;
2925 
2927  }
2928  if (URI == UNDEFINED_DEFAULT_NS)
2929  continue;
2930  if (URI == NULL)
2931  URI = ns->href;
2932  /*
2933  * TODO: The following will still be buggy for the
2934  * non-refactored code.
2935  */
2936  ret = xmlSearchNs(copy->doc, copy, ns->prefix);
2937  if ((ret == NULL) || (!xmlStrEqual(ret->href, URI)))
2938  {
2939  xmlNewNs(copy, URI, ns->prefix);
2940  }
2941  }
2942  if (copy->ns != NULL) {
2943  /*
2944  * Fix the node namespace if needed
2945  */
2946  copy->ns = xsltGetNamespace(ctxt, cur, copy->ns, copy);
2947  }
2948  }
2949  /*
2950  * all the attributes are directly inherited
2951  */
2952  if (cur->properties != NULL) {
2954  }
2955  ctxt->inst = oldCurInst;
2956  }
2957 #endif /* else of XSLT_REFACTORED */
2958 
2959  /*
2960  * Descend into content in document order.
2961  */
2962  if (cur->children != NULL) {
2963  if (cur->children->type != XML_ENTITY_DECL) {
2964  cur = cur->children;
2965  level++;
2966  if (copy != NULL)
2967  insert = copy;
2968  continue;
2969  }
2970  }
2971 
2972 skip_children:
2973  /*
2974  * If xslt:message was just processed, we might have hit a
2975  * terminate='yes'; if so, then break the loop and clean up.
2976  * TODO: Do we need to check this also before trying to descend
2977  * into the content?
2978  */
2979  if (ctxt->state == XSLT_STATE_STOPPED)
2980  break;
2981  if (cur->next != NULL) {
2982  cur = cur->next;
2983  continue;
2984  }
2985 
2986  do {
2987  cur = cur->parent;
2988  level--;
2989  /*
2990  * Pop variables/params (xsl:variable and xsl:param).
2991  */
2992  if ((ctxt->varsNr > oldVarsNr) && (ctxt->vars->level > level)) {
2993  xsltLocalVariablePop(ctxt, oldVarsNr, level);
2994  }
2995 
2996  insert = insert->parent;
2997  if (cur == NULL)
2998  break;
2999  if (cur == list->parent) {
3000  cur = NULL;
3001  break;
3002  }
3003  if (cur->next != NULL) {
3004  cur = cur->next;
3005  break;
3006  }
3007  } while (cur != NULL);
3008  }
3009 
3010 error:
3011  /*
3012  * In case of errors: pop remaining variables.
3013  */
3014  if (ctxt->varsNr > oldVarsNr)
3015  xsltLocalVariablePop(ctxt, oldVarsNr, -1);
3016 
3017  ctxt->node = oldContextNode;
3018  ctxt->inst = oldInst;
3019  ctxt->insert = oldInsert;
3020 
3021  ctxt->depth--;
3022 
3023 #ifdef WITH_DEBUGGER
3024  if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
3025  xslDropCall();
3026  }
3027 #endif
3028 }
void * psvi
Definition: tree.h:505
GLenum func
Definition: glext.h:6028
void xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst)
Definition: xsltutils.c:408
GLint level
Definition: gl.h:1546
static int xsltApplyFallbacks(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst)
Definition: transform.c:1798
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:748
#define error(str)
Definition: mkdosfs.c:1605
const xmlChar * name
Definition: tree.h:492
void xsltParseStylesheetVariable(xsltTransformContextPtr ctxt, xmlNodePtr inst)
Definition: variables.c:2144
struct _xmlNs * next
Definition: tree.h:390
#define XSLT_IS_TEXT_NODE(n)
Definition: xsltInternals.h:38
void(* xsltTransformFunction)(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
Definition: tree.h:389
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
xmlNsPtr * inheritedNs
xmlNsPtr xsltGetNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur, xmlNsPtr ns, xmlNodePtr out)
Definition: namespaces.c:596
xsltStackElemPtr vars
xmlNsPtr xsltGetSpecialNamespace(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, const xmlChar *nsName, const xmlChar *nsPrefix, xmlNodePtr target)
Definition: namespaces.c:299
static int insert
Definition: xmllint.c:144
#define XSLT_NAMESPACE
Definition: xslt.h:46
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
static HWND child
Definition: cursoricon.c:298
static xmlNodePtr xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target, xmlNodePtr cur, int interned)
Definition: transform.c:942
struct _test_info info[]
Definition: SetCursorPos.c:19
#define CHECK_STOPPED
#define UNDEFINED_DEFAULT_NS
Definition: namespaces.h:30
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
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:502
xsltTransformState state
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
smooth NULL
Definition: ftsmooth.c:416
xsltTransformFunction xsltExtElementLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *URI)
Definition: extensions.c:1668
struct _xmlNode * parent
Definition: tree.h:495
static xmlNodePtr xsltDebuggerStartSequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ, int *addCallResult)
Definition: transform.c:2174
void * xsltGenericDebugContext
Definition: xsltutils.c:549
if(!(yy_init))
Definition: macro.lex.yy.c:714
xsltTemplatePtr templ
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
xmlChar * content
Definition: tree.h:502
void * xsltGenericErrorContext
Definition: xsltutils.c:503
Definition: tree.h:489
int ret
Definition: mxnamespace.c:44
const xmlChar * lasttext
xmlAttrPtr xsltAttrListTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target, xmlAttrPtr attrs)
Definition: templates.c:627
unsigned char xmlChar
Definition: xmlstring.h:28
Definition: _list.h:228
struct _xmlAttr * properties
Definition: tree.h:503
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
BSTR prefix
Definition: mxnamespace.c:46
xmlElementType type
Definition: tree.h:491
XMLPUBFUN xmlNsPtr XMLCALL xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix)
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
void xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
Definition: xsltutils.c:2422
xsltElemPreComp * xsltElemPreCompPtr
xsltStylePreComp * xsltStylePreCompPtr
xsltStylesheetPtr style
struct _xmlNode * next
Definition: tree.h:496
static xmlNodePtr xsltShallowCopyElem(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr insert, int isLRE)
Definition: transform.c:1291
#define list
Definition: rosglue.h:35
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
XMLPUBVAR const xmlChar xmlStringTextNoenc[]
Definition: tree.h:551
struct _xmlNode * children
Definition: tree.h:493
void xsltLocalVariablePop(xsltTransformContextPtr ctxt, int limitNr, int level)
Definition: transform.c:150
XMLPUBFUN xmlNodePtr XMLCALL xmlDocCopyNode(xmlNodePtr node, xmlDocPtr doc, int recursive)
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:459
void xsltDebug(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst ATTRIBUTE_UNUSED, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: extra.c:35
xmlNs * ns
Definition: tree.h:501
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xslDropCall(void)
Definition: xsltutils.c:2452
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
const xmlChar * prefix
Definition: tree.h:393
Arabic default style
Definition: afstyles.h:93
const xmlChar * href
Definition: tree.h:392
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:63
static void xsltReleaseLocalRVTs(xsltTransformContextPtr ctxt, xmlDocPtr base)
Definition: transform.c:2260
const xmlChar * xsltExtMarker
Definition: preproc.c:24

Referenced by xsltApplyFallbacks(), xsltApplyOneTemplate(), xsltApplyXSLTTemplate(), xsltChoose(), xsltCopy(), xsltDocumentElem(), xsltElement(), xsltForEach(), and xsltIf().

◆ xsltApplyStripSpaces()

void xsltApplyStripSpaces ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node 
)

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

Strip the unwanted ignorable spaces from the input tree

Definition at line 5681 of file transform.c.

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

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

◆ xsltApplyStylesheet()

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

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

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

Returns the result document or NULL in case of error

Definition at line 6204 of file transform.c.

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

◆ xsltApplyStylesheetInternal()

static xmlDocPtr xsltApplyStylesheetInternal ( xsltStylesheetPtr  style,
xmlDocPtr  doc,
const char **  params,
const char output,
FILE profile,
xsltTransformContextPtr  userCtxt 
)
static

xsltApplyStylesheetInternal: @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 @user: user provided parameter

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

5804 {
5805  xmlDocPtr res = NULL;
5807  xmlNodePtr root, node;
5808  const xmlChar *method;
5809  const xmlChar *doctypePublic;
5810  const xmlChar *doctypeSystem;
5811  const xmlChar *version;
5812  const xmlChar *encoding;
5813  xsltStackElemPtr variables;
5814  xsltStackElemPtr vptr;
5815 
5816  xsltInitGlobals();
5817 
5818  if ((style == NULL) || (doc == NULL))
5819  return (NULL);
5820 
5821  if (style->internalized == 0) {
5822 #ifdef WITH_XSLT_DEBUG
5824  "Stylesheet was not fully internalized !\n");
5825 #endif
5826  }
5827  if (doc->intSubset != NULL) {
5828  /*
5829  * Avoid hitting the DTD when scanning nodes
5830  * but keep it linked as doc->intSubset
5831  */
5832  xmlNodePtr cur = (xmlNodePtr) doc->intSubset;
5833  if (cur->next != NULL)
5834  cur->next->prev = cur->prev;
5835  if (cur->prev != NULL)
5836  cur->prev->next = cur->next;
5837  if (doc->children == cur)
5838  doc->children = cur->next;
5839  if (doc->last == cur)
5840  doc->last = cur->prev;
5841  cur->prev = cur->next = NULL;
5842  }
5843 
5844  /*
5845  * Check for XPath document order availability
5846  */
5847  root = xmlDocGetRootElement(doc);
5848  if (root != NULL) {
5849  if (((ptrdiff_t) root->content >= 0) &&
5851  xmlXPathOrderDocElems(doc);
5852  }
5853 
5854  if (userCtxt != NULL)
5855  ctxt = userCtxt;
5856  else
5857  ctxt = xsltNewTransformContext(style, doc);
5858 
5859  if (ctxt == NULL)
5860  return (NULL);
5861 
5862  ctxt->initialContextDoc = doc;
5863  ctxt->initialContextNode = (xmlNodePtr) doc;
5864 
5865  if (profile != NULL)
5866  ctxt->profile = 1;
5867 
5868  if (output != NULL)
5869  ctxt->outputFile = output;
5870  else
5871  ctxt->outputFile = NULL;
5872 
5873  /*
5874  * internalize the modes if needed
5875  */
5876  if (ctxt->dict != NULL) {
5877  if (ctxt->mode != NULL)
5878  ctxt->mode = xmlDictLookup(ctxt->dict, ctxt->mode, -1);
5879  if (ctxt->modeURI != NULL)
5880  ctxt->modeURI = xmlDictLookup(ctxt->dict, ctxt->modeURI, -1);
5881  }
5882 
5884  XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
5885  XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
5888 
5889  if ((method != NULL) &&
5890  (!xmlStrEqual(method, (const xmlChar *) "xml")))
5891  {
5892  if (xmlStrEqual(method, (const xmlChar *) "html")) {
5893  ctxt->type = XSLT_OUTPUT_HTML;
5894  if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
5895  res = htmlNewDoc(doctypeSystem, doctypePublic);
5896  } else {
5897  if (version == NULL) {
5898  xmlDtdPtr dtd;
5899 
5900  res = htmlNewDoc(NULL, NULL);
5901  /*
5902  * Make sure no DTD node is generated in this case
5903  */
5904  if (res != NULL) {
5905  dtd = xmlGetIntSubset(res);
5906  if (dtd != NULL) {
5907  xmlUnlinkNode((xmlNodePtr) dtd);
5908  xmlFreeDtd(dtd);
5909  }
5910  res->intSubset = NULL;
5911  res->extSubset = NULL;
5912  }
5913  } else {
5914 
5915 #ifdef XSLT_GENERATE_HTML_DOCTYPE
5916  xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem);
5917 #endif
5918  res = htmlNewDoc(doctypeSystem, doctypePublic);
5919  }
5920  }
5921  if (res == NULL)
5922  goto error;
5923  res->dict = ctxt->dict;
5924  xmlDictReference(res->dict);
5925 
5926 #ifdef WITH_XSLT_DEBUG
5928  "reusing transformation dict for output\n");
5929 #endif
5930  } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
5931  xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
5932  "xsltApplyStylesheetInternal: unsupported method xhtml, using html\n");
5933  ctxt->type = XSLT_OUTPUT_HTML;
5934  res = htmlNewDoc(doctypeSystem, doctypePublic);
5935  if (res == NULL)
5936  goto error;
5937  res->dict = ctxt->dict;
5938  xmlDictReference(res->dict);
5939 
5940 #ifdef WITH_XSLT_DEBUG
5942  "reusing transformation dict for output\n");
5943 #endif
5944  } else if (xmlStrEqual(method, (const xmlChar *) "text")) {
5945  ctxt->type = XSLT_OUTPUT_TEXT;
5946  res = xmlNewDoc(style->version);
5947  if (res == NULL)
5948  goto error;
5949  res->dict = ctxt->dict;
5950  xmlDictReference(res->dict);
5951 
5952 #ifdef WITH_XSLT_DEBUG
5954  "reusing transformation dict for output\n");
5955 #endif
5956  } else {
5957  xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
5958  "xsltApplyStylesheetInternal: unsupported method (%s)\n",
5959  method);
5960  goto error;
5961  }
5962  } else {
5963  ctxt->type = XSLT_OUTPUT_XML;
5964  res = xmlNewDoc(style->version);
5965  if (res == NULL)
5966  goto error;
5967  res->dict = ctxt->dict;
5968  xmlDictReference(ctxt->dict);
5969 #ifdef WITH_XSLT_DEBUG
5971  "reusing transformation dict for output\n");
5972 #endif
5973  }
5974  res->charset = XML_CHAR_ENCODING_UTF8;
5975  if (encoding != NULL)
5976  res->encoding = xmlStrdup(encoding);
5977  variables = style->variables;
5978 
5979  /*
5980  * Start the evaluation, evaluate the params, the stylesheets globals
5981  * and start by processing the top node.
5982  */
5983  if (xsltNeedElemSpaceHandling(ctxt))
5985  /*
5986  * Evaluate global params and user-provided params.
5987  */
5988  ctxt->node = (xmlNodePtr) doc;
5989  if (ctxt->globalVars == NULL)
5990  ctxt->globalVars = xmlHashCreate(20);
5991  if (params != NULL) {
5992  xsltEvalUserParams(ctxt, params);
5993  }
5994 
5995  /* need to be called before evaluating global variables */
5996  xsltCountKeys(ctxt);
5997 
5999 
6000  /* Clean up any unused RVTs. */
6001  xsltReleaseLocalRVTs(ctxt, NULL);
6002 
6003  ctxt->node = (xmlNodePtr) doc;
6004  ctxt->output = res;
6005  ctxt->insert = (xmlNodePtr) res;
6006  ctxt->varsBase = ctxt->varsNr - 1;
6007 
6008  ctxt->xpathCtxt->contextSize = 1;
6009  ctxt->xpathCtxt->proximityPosition = 1;
6010  ctxt->xpathCtxt->node = NULL; /* TODO: Set the context node here? */
6011  /*
6012  * Start processing the source tree -----------------------------------
6013  */
6014  xsltProcessOneNode(ctxt, ctxt->node, NULL);
6015  /*
6016  * Remove all remaining vars from the stack.
6017  */
6018  xsltLocalVariablePop(ctxt, 0, -2);
6019  xsltShutdownCtxtExts(ctxt);
6020 
6021  xsltCleanupTemplates(style); /* TODO: <- style should be read only */
6022 
6023  /*
6024  * Now cleanup our variables so stylesheet can be re-used
6025  *
6026  * TODO: this is not needed anymore global variables are copied
6027  * and not evaluated directly anymore, keep this as a check
6028  */
6029  if (style->variables != variables) {
6030  vptr = style->variables;
6031  while (vptr->next != variables)
6032  vptr = vptr->next;
6033  vptr->next = NULL;
6034  xsltFreeStackElemList(style->variables);
6035  style->variables = variables;
6036  }
6037  vptr = style->variables;
6038  while (vptr != NULL) {
6039  if (vptr->computed) {
6040  if (vptr->value != NULL) {
6041  xmlXPathFreeObject(vptr->value);
6042  vptr->value = NULL;
6043  vptr->computed = 0;
6044  }
6045  }
6046  vptr = vptr->next;
6047  }
6048 #if 0
6049  /*
6050  * code disabled by wmb; awaiting kb's review
6051  * problem is that global variable(s) may contain xpath objects
6052  * from doc associated with RVT, so can't be freed at this point.
6053  * xsltFreeTransformContext includes a call to xsltFreeRVTs, so
6054  * I assume this shouldn't be required at this point.
6055  */
6056  /*
6057  * Free all remaining tree fragments.
6058  */
6059  xsltFreeRVTs(ctxt);
6060 #endif
6061  /*
6062  * Do some post processing work depending on the generated output
6063  */
6065  if (root != NULL) {
6066  const xmlChar *doctype = NULL;
6067 
6068  if ((root->ns != NULL) && (root->ns->prefix != NULL))
6069  doctype = xmlDictQLookup(ctxt->dict, root->ns->prefix, root->name);
6070  if (doctype == NULL)
6071  doctype = root->name;
6072 
6073  /*
6074  * Apply the default selection of the method
6075  */
6076  if ((method == NULL) &&
6077  (root->ns == NULL) &&
6078  (!xmlStrcasecmp(root->name, (const xmlChar *) "html"))) {
6079  xmlNodePtr tmp;
6080 
6081  tmp = res->children;
6082  while ((tmp != NULL) && (tmp != root)) {
6083  if (tmp->type == XML_ELEMENT_NODE)
6084  break;
6085  if ((tmp->type == XML_TEXT_NODE) && (!xmlIsBlankNode(tmp)))
6086  break;
6087  tmp = tmp->next;
6088  }
6089  if (tmp == root) {
6090  ctxt->type = XSLT_OUTPUT_HTML;
6091  /*
6092  * REVISIT TODO: XML_HTML_DOCUMENT_NODE is set after the
6093  * transformation on the doc, but functions like
6094  */
6095  res->type = XML_HTML_DOCUMENT_NODE;
6096  if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
6097  res->intSubset = xmlCreateIntSubset(res, doctype,
6098  doctypePublic,
6099  doctypeSystem);
6100 #ifdef XSLT_GENERATE_HTML_DOCTYPE
6101  } else if (version != NULL) {
6102  xsltGetHTMLIDs(version, &doctypePublic,
6103  &doctypeSystem);
6104  if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
6105  res->intSubset =
6106  xmlCreateIntSubset(res, doctype,
6107  doctypePublic,
6108  doctypeSystem);
6109 #endif
6110  }
6111  }
6112 
6113  }
6114  if (ctxt->type == XSLT_OUTPUT_XML) {
6115  XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
6116  XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
6117  if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
6118  xmlNodePtr last;
6119  /* Need a small "hack" here to assure DTD comes before
6120  possible comment nodes */
6121  node = res->children;
6122  last = res->last;
6123  res->children = NULL;
6124  res->last = NULL;
6125  res->intSubset = xmlCreateIntSubset(res, doctype,
6126  doctypePublic,
6127  doctypeSystem);
6128  if (res->children != NULL) {
6129  res->children->next = node;
6130  node->prev = res->children;
6131  res->last = last;
6132  } else {
6133  res->children = node;
6134  res->last = last;
6135  }
6136  }
6137  }
6138  }
6139  xmlXPathFreeNodeSet(ctxt->nodeList);
6140  if (profile != NULL) {
6141  xsltSaveProfiling(ctxt, profile);
6142  }
6143 
6144  /*
6145  * Be pedantic.
6146  */
6147  if ((ctxt != NULL) && (ctxt->state != XSLT_STATE_OK)) {
6148  xmlFreeDoc(res);
6149  res = NULL;
6150  }
6151  if ((res != NULL) && (ctxt != NULL) && (output != NULL)) {
6152  int ret;
6153 
6154  ret = xsltCheckWrite(ctxt->sec, ctxt, (const xmlChar *) output);
6155  if (ret == 0) {
6156  xsltTransformError(ctxt, NULL, NULL,
6157  "xsltApplyStylesheet: forbidden to save to %s\n",
6158  output);
6159  } else if (ret < 0) {
6160  xsltTransformError(ctxt, NULL, NULL,
6161  "xsltApplyStylesheet: saving to %s may not be possible\n",
6162  output);
6163  }
6164  }
6165 
6166 #ifdef XSLT_DEBUG_PROFILE_CACHE
6167  printf("# Cache:\n");
6168  printf("# Reused tree fragments: %d\n", ctxt->cache->dbgReusedRVTs);
6169  printf("# Reused variables : %d\n", ctxt->cache->dbgReusedVars);
6170 #endif
6171 
6172  if ((ctxt != NULL) && (userCtxt == NULL))
6174 
6175  return (res);
6176 
6177 error:
6178  if (res != NULL)
6179  xmlFreeDoc(res);
6180 
6181 #ifdef XSLT_DEBUG_PROFILE_CACHE
6182  printf("# Cache:\n");
6183  printf("# Reused tree fragments: %d\n", ctxt->cache->dbgReusedRVTs);
6184  printf("# Reused variables : %d\n", ctxt->cache->dbgReusedVars);
6185 #endif
6186 
6187  if ((ctxt != NULL) && (userCtxt == NULL))
6189  return (NULL);
6190 }
xmlNodeSetPtr nodeList
static int xsltGetHTMLIDs(const xmlChar *version, const xmlChar **publicID, const xmlChar **systemID)
Definition: transform.c:5653
xsltTransformCachePtr cache
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:638
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
void xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xsltStackElemPtr withParams)
Definition: transform.c:2100
xmlNodePtr initialContextNode
struct _xmlNode * prev
Definition: tree.h:497
#define error(str)
Definition: mkdosfs.c:1605
void xsltFreeRVTs(xsltTransformContextPtr ctxt)
Definition: variables.c:419
struct _xmlDtd * intSubset
Definition: tree.h:570
int xslDebugStatus
Definition: xsltutils.c:2357
POINT last
Definition: font.c:46
struct _root root
XMLPUBFUN int XMLCALL xmlIsBlankNode(const xmlNode *node)
int xsltEvalGlobalVariables(xsltTransformContextPtr ctxt)
Definition: variables.c:1255
struct _xsltStackElem * next
void xsltShutdownCtxtExts(xsltTransformContextPtr ctxt)
Definition: extensions.c:1081
Definition: tree.h:406
struct node node
xsltTransformContextPtr xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc)
Definition: transform.c:532
GLenum const GLfloat * params
Definition: glext.h:5645
xsltTransformState state
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:66
XMLPUBFUN void XMLCALL xmlFreeDtd(xmlDtdPtr cur)
xmlNode * xmlNodePtr
Definition: tree.h:488
xmlXPathContextPtr xpathCtxt
const xmlChar * modeURI
void * xsltGenericDebugContext
Definition: xsltutils.c:549
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:858
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
method
Definition: dragdrop.c:53
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreate(int size)
Definition: hash.c:174
Definition: tree.h:489
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
void xsltFreeTransformContext(xsltTransformContextPtr ctxt)
Definition: transform.c:686
void xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output)
Definition: xsltutils.c:1937
XMLPUBFUN const xmlChar *XMLCALL xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name)
Definition: dict.c:1106
xmlElementType type
Definition: tree.h:491
ed encoding
Definition: write.c:2839
int xsltNeedElemSpaceHandling(xsltTransformContextPtr ctxt)
Definition: imports.c:275
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:606
const xmlChar * mode
struct _xmlNode * next
Definition: tree.h:496
void xsltApplyStripSpaces(xsltTransformContextPtr ctxt, xmlNodePtr node)
Definition: transform.c:5681
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
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
static int xsltCountKeys(xsltTransformContextPtr ctxt)
Definition: transform.c:5750
struct _xmlNode * last
Definition: tree.h:556
Definition: tree.h:551
XMLPUBFUN xmlDtdPtr XMLCALL xmlGetIntSubset(const xmlDoc *doc)
int xsltCheckWrite(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:335
void xsltCleanupTemplates(xsltStylesheetPtr style ATTRIBUTE_UNUSED)
Definition: pattern.c:2563
struct _xmlNode * children
Definition: tree.h:493
void xsltLocalVariablePop(xsltTransformContextPtr ctxt, int limitNr, int level)
Definition: transform.c:150
GLuint res
Definition: glext.h:9613
xmlXPathObjectPtr value
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
#define profile
Definition: kernel32.h:12
struct _xmlNode * children
Definition: tree.h:555
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
void xsltInitGlobals(void)
Definition: extensions.c:2263
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
xmlHashTablePtr globalVars
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
int xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params)
Definition: variables.c:1657
static void xsltReleaseLocalRVTs(xsltTransformContextPtr ctxt, xmlDocPtr base)
Definition: transform.c:2260
#define printf
Definition: config.h:203
Definition: dlist.c:348

Referenced by xsltApplyStylesheet(), xsltApplyStylesheetUser(), xsltProfileStylesheet(), and xsltRunStylesheetUser().

◆ xsltApplyStylesheetUser()

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

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

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

Returns the result document or NULL in case of error

Definition at line 6247 of file transform.c.

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

◆ xsltApplyTemplates()

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

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

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

Definition at line 4791 of file transform.c.

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

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltApplyXSLTTemplate()

static void xsltApplyXSLTTemplate ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  list,
xsltTemplatePtr  templ,
xsltStackElemPtr  withParams 
)
static

Definition at line 3047 of file transform.c.

3052 {
3053  int oldVarsBase = 0;
3054  long start = 0;
3055  xmlNodePtr cur;
3056  xsltStackElemPtr tmpParam = NULL;
3057  xmlDocPtr oldUserFragmentTop;
3058 
3059 #ifdef XSLT_REFACTORED
3060  xsltStyleItemParamPtr iparam;
3061 #else
3062  xsltStylePreCompPtr iparam;
3063 #endif
3064 
3065 #ifdef WITH_DEBUGGER
3066  int addCallResult = 0;
3067 #endif
3068 
3069  if (ctxt == NULL)
3070  return;
3071  if (templ == NULL) {
3072  xsltTransformError(ctxt, NULL, list,
3073  "xsltApplyXSLTTemplate: Bad arguments; @templ is mandatory.\n");
3074  return;
3075  }
3076 
3077 #ifdef WITH_DEBUGGER
3078  if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
3079  if (xsltDebuggerStartSequenceConstructor(ctxt, contextNode,
3080  list, templ, &addCallResult) == NULL)
3081  return;
3082  }
3083 #endif
3084 
3085  if (list == NULL)
3086  return;
3087  CHECK_STOPPED;
3088 
3089  if (ctxt->varsNr >= ctxt->maxTemplateVars)
3090  {
3091  xsltTransformError(ctxt, NULL, list,
3092  "xsltApplyXSLTTemplate: A potential infinite template recursion "
3093  "was detected.\n"
3094  "You can adjust maxTemplateVars (--maxvars) in order to "
3095  "raise the maximum number of variables/params (currently set to %d).\n",
3096  ctxt->maxTemplateVars);
3097  xsltDebug(ctxt, contextNode, list, NULL);
3098  ctxt->state = XSLT_STATE_STOPPED;
3099  return;
3100  }
3101 
3102  oldUserFragmentTop = ctxt->tmpRVT;
3103  ctxt->tmpRVT = NULL;
3104 
3105  /*
3106  * Initiate a distinct scope of local params/variables.
3107  */
3108  oldVarsBase = ctxt->varsBase;
3109  ctxt->varsBase = ctxt->varsNr;
3110 
3111  ctxt->node = contextNode;
3112  if (ctxt->profile) {
3113  templ->nbCalls++;
3114  start = xsltTimestamp();
3115  profPush(ctxt, 0);
3116  profCallgraphAdd(templ, ctxt->templ);
3117  }
3118  /*
3119  * Push the xsl:template declaration onto the stack.
3120  */
3121  templPush(ctxt, templ);
3122 
3123 #ifdef WITH_XSLT_DEBUG_PROCESS
3124  if (templ->name != NULL)
3126  "applying xsl:template '%s'\n", templ->name));
3127 #endif
3128  /*
3129  * Process xsl:param instructions and skip those elements for
3130  * further processing.
3131  */
3132  cur = list;
3133  do {
3134  if (cur->type == XML_TEXT_NODE) {
3135  cur = cur->next;
3136  continue;
3137  }
3138  if ((cur->type != XML_ELEMENT_NODE) ||
3139  (cur->name[0] != 'p') ||
3140  (cur->psvi == NULL) ||
3141  (! xmlStrEqual(cur->name, BAD_CAST "param")) ||
3142  (! IS_XSLT_ELEM(cur)))
3143  {
3144  break;
3145  }
3146 
3147  list = cur->next;
3148 
3149 #ifdef XSLT_REFACTORED
3150  iparam = (xsltStyleItemParamPtr) cur->psvi;
3151 #else
3152  iparam = (xsltStylePreCompPtr) cur->psvi;
3153 #endif
3154 
3155  /*
3156  * Substitute xsl:param for a given xsl:with-param.
3157  * Since the XPath expression will reference the params/vars
3158  * by index, we need to slot the xsl:with-params in the
3159  * order of encountered xsl:params to keep the sequence of
3160  * params/variables in the stack exactly as it was at
3161  * compile time,
3162  */
3163  tmpParam = NULL;
3164  if (withParams) {
3165  tmpParam = withParams;
3166  do {
3167  if ((tmpParam->name == (iparam->name)) &&
3168  (tmpParam->nameURI == (iparam->ns)))
3169  {
3170  /*
3171  * Push the caller-parameter.
3172  */
3173  xsltLocalVariablePush(ctxt, tmpParam, -1);
3174  break;
3175  }
3176  tmpParam = tmpParam->next;
3177  } while (tmpParam != NULL);
3178  }
3179  /*
3180  * Push the xsl:param.
3181  */
3182  if (tmpParam == NULL) {
3183  /*
3184  * Note that we must assume that the added parameter
3185  * has a @depth of 0.
3186  */
3187  xsltParseStylesheetParam(ctxt, cur);
3188  }
3189  cur = cur->next;
3190  } while (cur != NULL);
3191  /*
3192  * Process the sequence constructor.
3193  */
3194  xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
3195 
3196  /*
3197  * Remove remaining xsl:param and xsl:with-param items from
3198  * the stack. Don't free xsl:with-param items.
3199  */
3200  if (ctxt->varsNr > ctxt->varsBase)
3202  ctxt->varsBase = oldVarsBase;
3203 
3204  /*
3205  * Release user-created fragments stored in the scope
3206  * of xsl:template. Note that this mechanism is deprecated:
3207  * user code should now use xsltRegisterLocalRVT() instead
3208  * of the obsolete xsltRegisterTmpRVT().
3209  */
3210  if (ctxt->tmpRVT) {
3211  xmlDocPtr curdoc = ctxt->tmpRVT, tmp;
3212 
3213  while (curdoc != NULL) {
3214  tmp = curdoc;
3215  curdoc = (xmlDocPtr) curdoc->next;
3216  xsltReleaseRVT(ctxt, tmp);
3217  }
3218  }
3219  ctxt->tmpRVT = oldUserFragmentTop;
3220 
3221  /*
3222  * Pop the xsl:template declaration from the stack.
3223  */
3224  templPop(ctxt);
3225  if (ctxt->profile) {
3226  long spent, child, total, end;
3227 
3228  end = xsltTimestamp();
3229  child = profPop(ctxt);
3230  total = end - start;
3231  spent = total - child;
3232  if (spent <= 0) {
3233  /*
3234  * Not possible unless the original calibration failed
3235  * we can try to correct it on the fly.
3236  */
3237  xsltCalibrateAdjust(spent);
3238  spent = 0;
3239  }
3240 
3241  templ->time += spent;
3242  if (ctxt->profNr > 0)
3243  ctxt->profTab[ctxt->profNr - 1] += total;
3244  }
3245 
3246 #ifdef WITH_DEBUGGER
3247  if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
3248  xslDropCall();
3249  }
3250 #endif
3251 }
void * psvi
Definition: tree.h:505
const xmlChar * name
const xmlChar * name
Definition: tree.h:492
static void profCallgraphAdd(xsltTemplatePtr templ, xsltTemplatePtr parent)
Definition: transform.c:261
void xsltParseStylesheetParam(xsltTransformContextPtr ctxt, xmlNodePtr cur)
Definition: variables.c:2186
const xmlChar * ns
void xsltReleaseRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
Definition: variables.c:326
GLuint GLuint end
Definition: gl.h:1545
struct _xsltStackElem * next
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
static HWND child
Definition: cursoricon.c:298
#define CHECK_STOPPED
xsltTransformState state
static int profPush(xsltTransformContextPtr ctxt, long value)
Definition: transform.c:210
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
static int templPush(xsltTransformContextPtr ctxt, xsltTemplatePtr value)
Definition: transform.c:85
static xmlNodePtr xsltDebuggerStartSequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ, int *addCallResult)
Definition: transform.c:2174
void * xsltGenericDebugContext
Definition: xsltutils.c:549
int xsltLocalVariablePush(xsltTransformContextPtr ctxt, xsltStackElemPtr variable, int level)
Definition: transform.c:2222
xsltTemplatePtr templ
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
const xmlChar * nameURI
long xsltTimestamp(void)
Definition: xsltutils.c:1815
Definition: tree.h:489
struct _xmlNode * next
Definition: tree.h:558
static xsltTemplatePtr templPop(xsltTransformContextPtr ctxt)
Definition: transform.c:121
unsigned long time
Definition: _list.h:228
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlElementType type
Definition: tree.h:491
static long profPop(xsltTransformContextPtr ctxt)
Definition: transform.c:244
static void xsltApplySequenceConstructor(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ)
Definition: transform.c:2312
void xsltCalibrateAdjust(long delta)
Definition: xsltutils.c:1802
xmlDoc * xmlDocPtr
Definition: tree.h:550
struct _xmlNode * next
Definition: tree.h:496
GLuint start
Definition: gl.h:1545
#define list
Definition: rosglue.h:35
Definition: tree.h:551
const xmlChar * name
static void xsltTemplateParamsCleanup(xsltTransformContextPtr ctxt)
Definition: transform.c:180
void xsltDebug(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst ATTRIBUTE_UNUSED, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: extra.c:35
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xslDropCall(void)
Definition: xsltutils.c:2452
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
const xmlChar * name

Referenced by xsltApplyImports(), xsltCallTemplate(), xsltDefaultProcessOneNode(), and xsltProcessOneNode().

◆ xsltCallTemplate()

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

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

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

Definition at line 4688 of file transform.c.

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

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltChoose()

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

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

Processes the xsl:choose instruction on the source node.

Definition at line 5168 of file transform.c.

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

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltComment()

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

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

Process the xslt comment node on the source node

Definition at line 4234 of file transform.c.

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

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltCopy()

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

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

Execute the XSLT-copy instruction on the source node.

Definition at line 3870 of file transform.c.

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

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltCopyAttrListNoOverwrite()

static int xsltCopyAttrListNoOverwrite ( xsltTransformContextPtr  ctxt,
xmlNodePtr  invocNode,
xmlNodePtr  target,
xmlAttrPtr  attr 
)
static

xsltCopyAttrListNoOverwrite: @ctxt: a XSLT process context @invocNode: responsible node in the stylesheet; used for error reports @target: the element where the new attributes will be grafted @attr: the first attribute in the list to be copied

Copies a list of attribute nodes, starting with @attr, over to the @target element node.

Called by:

Returns 0 on success and -1 on errors and internal errors.

Definition at line 1215 of file transform.c.

1218 {
1219  xmlAttrPtr copy;
1220  xmlNsPtr origNs = NULL, copyNs = NULL;
1221  xmlChar *value;
1222 
1223  /*
1224  * Don't use xmlCopyProp() here, since it will try to
1225  * reconciliate namespaces.
1226  */
1227  while (attr != NULL) {
1228  /*
1229  * Find a namespace node in the tree of @target.
1230  * Avoid searching for the same ns.
1231  */
1232  if (attr->ns != origNs) {
1233  origNs = attr->ns;
1234  if (attr->ns != NULL) {
1235  copyNs = xsltGetSpecialNamespace(ctxt, invocNode,
1236  attr->ns->href, attr->ns->prefix, target);
1237  if (copyNs == NULL)
1238  return(-1);
1239  } else
1240  copyNs = NULL;
1241  }
1242  /*
1243  * If attribute has a value, we need to copy it (watching out
1244  * for possible entities)
1245  */
1246  if ((attr->children) && (attr->children->type == XML_TEXT_NODE) &&
1247  (attr->children->next == NULL)) {
1248  copy = xmlNewNsProp(target, copyNs, attr->name,
1249  attr->children->content);
1250  } else if (attr->children != NULL) {
1251  value = xmlNodeListGetString(attr->doc, attr->children, 1);
1252  copy = xmlNewNsProp(target, copyNs, attr->name, BAD_CAST value);
1253  xmlFree(value);
1254  } else {
1255  copy = xmlNewNsProp(target, copyNs, attr->name, NULL);
1256  }
1257 
1258  if (copy == NULL)
1259  return(-1);
1260 
1261  attr = attr->next;
1262  }
1263  return(0);
1264 }
Definition: tree.h:389
xmlNsPtr xsltGetSpecialNamespace(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, const xmlChar *nsName, const xmlChar *nsPrefix, xmlNodePtr target)
Definition: namespaces.c:299
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
Definition: cookie.c:201
XMLPUBFUN xmlChar *XMLCALL xmlNodeListGetString(xmlDocPtr doc, const xmlNode *list, int inLine)
XMLPUBFUN xmlAttrPtr XMLCALL xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value)
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
Definition: tree.h:434
WCHAR * name
Definition: cookie.c:203
GLenum target
Definition: glext.h:7315

Referenced by xsltCopyTree().

◆ xsltCopyNamespaceListInternal()

static xmlNsPtr xsltCopyNamespaceListInternal ( xmlNodePtr  elem,
xmlNsPtr  ns 
)
static

xsltCopyNamespaceListInternal: @node: the target node @cur: the first namespace

Do a copy of a namespace list. If @node is non-NULL the new namespaces are added automatically. Called by: xsltCopyTree()

QUESTION: What is the exact difference between this function and xsltCopyNamespaceList() in "namespaces.c"? ANSWER: xsltCopyNamespaceList() tries to apply ns-aliases.

Returns: a new xmlNsPtr, or NULL in case of error.

Definition at line 1419 of file transform.c.

1419  {
1420  xmlNsPtr ret = NULL;
1421  xmlNsPtr p = NULL, q, luNs;
1422 
1423  if (ns == NULL)
1424  return(NULL);
1425  /*
1426  * One can add namespaces only on element nodes
1427  */
1428  if ((elem != NULL) && (elem->type != XML_ELEMENT_NODE))
1429  elem = NULL;
1430 
1431  do {
1432  if (ns->type != XML_NAMESPACE_DECL)
1433  break;
1434  /*
1435  * Avoid duplicating namespace declarations on the tree.
1436  */
1437  if (elem != NULL) {
1438  if ((elem->ns != NULL) &&
1439  xmlStrEqual(elem->ns->prefix, ns->prefix) &&
1440  xmlStrEqual(elem->ns->href, ns->href))
1441  {
1442  ns = ns->next;
1443  continue;
1444  }
1445  luNs = xmlSearchNs(elem->doc, elem, ns->prefix);
1446  if ((luNs != NULL) && (xmlStrEqual(luNs->href, ns->href)))
1447  {
1448  ns = ns->next;
1449  continue;
1450  }
1451  }
1452  q = xmlNewNs(elem, ns->href, ns->prefix);
1453  if (p == NULL) {
1454  ret = p = q;
1455  } else if (q != NULL) {
1456  p->next = q;
1457  p = q;
1458  }
1459  ns = ns->next;
1460  } while (ns != NULL);
1461  return(ret);
1462 }
Definition: tree.h:389
static size_t elem
Definition: string.c:68
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
smooth NULL
Definition: ftsmooth.c:416
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
int ret
Definition: mxnamespace.c:44
BSTR prefix
Definition: mxnamespace.c:46
XMLPUBFUN xmlNsPtr XMLCALL xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by xsltCopyTree(), and xsltShallowCopyElem().

◆ xsltCopyOf()

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

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

Process the XSLT copy-of instruction.

Definition at line 4344 of file transform.c.

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

Referenced by xsltNewStylePreComp(), and xsltRegisterAllElement().

◆ xsltCopyText()

static xmlNodePtr xsltCopyText ( xsltTransformContextPtr  ctxt,
xmlNodePtr  target,
xmlNodePtr  cur,
int  interned 
)
static

xsltCopyText: @ctxt: a XSLT process context @target: the element where the text will be attached @cur: the text or CDATA node @interned: the string is in the target doc dictionary

Copy the text content of @cur and append it to @target's children.

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

Definition at line 942 of file transform.c.

944 {
946 
947  if ((cur->type != XML_TEXT_NODE) &&
948  (cur->type != XML_CDATA_SECTION_NODE))
949  return(NULL);
950  if (cur->content == NULL)
951  return(NULL);
952 
953 #ifdef WITH_XSLT_DEBUG_PROCESS
954  if (cur->type == XML_CDATA_SECTION_NODE) {
956  "xsltCopyText: copy CDATA text %s\n",
957  cur->content));
958  } else if (cur->name == xmlStringTextNoenc) {
960  "xsltCopyText: copy unescaped text %s\n",
961  cur->content));
962  } else {
964  "xsltCopyText: copy text %s\n",
965  cur->content));
966  }
967 #endif
968 
969  /*
970  * Play save and reset the merging mechanism for every new
971  * target node.
972  */
973  if ((target == NULL) || (target->children == NULL)) {
974  ctxt->lasttext = NULL;
975  }
976 
977  if ((ctxt->style->cdataSection != NULL) &&
978  (ctxt->type == XSLT_OUTPUT_XML) &&
979  (target != NULL) &&
980  (target->type == XML_ELEMENT_NODE) &&
981  (((target->ns == NULL) &&
983  target->name, NULL) != NULL)) ||
984  ((target->ns != NULL) &&
986  target->name, target->ns->href) != NULL))))
987  {
988  /*
989  * Process "cdata-section-elements".
990  */
991  /*
992  * OPTIMIZE TODO: xsltCopyText() is also used for attribute content.
993  */
994  /*
995  * TODO: Since this doesn't merge adjacent CDATA-section nodes,
996  * we'll get: <![CDATA[x]]><!CDATA[y]]>.
997  * TODO: Reported in #321505.
998  */
999  if ((target->last != NULL) &&
1000  (target->last->type == XML_CDATA_SECTION_NODE))
1001  {
1002  /*
1003  * Append to existing CDATA-section node.
1004  */
1005  copy = xsltAddTextString(ctxt, target->last, cur->content,
1006  xmlStrlen(cur->content));
1007  goto exit;
1008  } else {
1009  unsigned int len;
1010 
1011  len = xmlStrlen(cur->content);
1012  copy = xmlNewCDataBlock(ctxt->output, cur->content, len);
1013  if (copy == NULL)
1014  goto exit;
1015  ctxt->lasttext = copy->content;
1016  ctxt->lasttsize = len;
1017  ctxt->lasttuse = len;
1018  }
1019  } else if ((target != NULL) &&
1020  (target->last != NULL) &&
1021  /* both escaped or both non-escaped text-nodes */
1022  (((target->last->type == XML_TEXT_NODE) &&
1023  (target->last->name == cur->name)) ||
1024  /* non-escaped text nodes and CDATA-section nodes */
1025  (((target->last->type == XML_CDATA_SECTION_NODE) &&
1026  (cur->name == xmlStringTextNoenc)))))
1027  {
1028  /*
1029  * we are appending to an existing text node
1030  */
1031  copy = xsltAddTextString(ctxt, target->last, cur->content,
1032  xmlStrlen(cur->content));
1033  goto exit;
1034  } else if ((interned) && (target != NULL) &&
1035  (target->doc != NULL) &&
1036  (target->doc->dict == ctxt->dict))
1037  {
1038  /*
1039  * TODO: DO we want to use this also for "text" output?
1040  */
1041  copy = xmlNewTextLen(NULL, 0);
1042  if (copy == NULL)
1043  goto exit;
1044  if (cur->name == xmlStringTextNoenc)
1045  copy->name = xmlStringTextNoenc;
1046 
1047  /*
1048  * Must confirm that content is in dict (bug 302821)
1049  * TODO: This check should be not needed for text coming
1050  * from the stylesheets
1051  */
1052  if (xmlDictOwns(ctxt->dict, cur->content))
1053  copy->content = cur->content;
1054  else {
1055  if ((copy->content = xmlStrdup(cur->content)) == NULL)
1056  return NULL;
1057  }
1058  } else {
1059  /*
1060  * normal processing. keep counters to extend the text node
1061  * in xsltAddTextString if needed.
1062  */
1063  unsigned int len;
1064 
1065  len = xmlStrlen(cur->content);
1066  copy = xmlNewTextLen(cur->content, len);
1067  if (copy == NULL)
1068  goto exit;
1069  if (cur->name == xmlStringTextNoenc)
1070  copy->name = xmlStringTextNoenc;
1071  ctxt->lasttext = copy->content;
1072  ctxt->lasttsize = len;
1073  ctxt->lasttuse = len;
1074  }
1075  if (copy != NULL) {
1076  if (target != NULL) {
1077  copy->doc = target->doc;
1078  /*
1079  * MAYBE TODO: Maybe we should reset the ctxt->lasttext here
1080  * to ensure that the optimized text-merging mechanism
1081  * won't interfere with normal node-merging in any case.
1082  */
1084  }
1085  } else {
1087  "xsltCopyText: text copy failed\n");
1088  }
1089 
1090 exit:
1091  if ((copy == NULL) || (copy->content == NULL)) {
1093  "Internal error in xsltCopyText(): "
1094  "Failed to copy the string.\n");
1095  ctxt->state = XSLT_STATE_STOPPED;
1096  }
1097  return(copy);
1098 }
static xmlNodePtr xsltAddChild(xmlNodePtr parent, xmlNodePtr cur)
Definition: transform.c:748
const xmlChar * name
Definition: tree.h:492
XMLPUBFUN xmlNodePtr XMLCALL xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len)
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:474
xsltTransformState state
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
xmlChar * content
Definition: tree.h:502
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
xmlElementType type
Definition: tree.h:491
xsltStylesheetPtr style
static xmlNodePtr xsltAddTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int len)
Definition: transform.c:774
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1211
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 exit(int exitcode)
Definition: _exit.c:33
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
XMLPUBFUN xmlNodePtr XMLCALL xmlNewTextLen(const xmlChar *content, int len)
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xsltApplySequenceConstructor(), xsltCopy(), xsltDefaultProcessOneNode(), and xsltShallowCopyElem().

◆ xsltCopyTextString()

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

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

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

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

Definition at line 846 of file transform.c.

848 {
850  int len;
851 
852  if (string == NULL)
853  return(NULL);
854 
855 #ifdef WITH_XSLT_DEBUG_PROCESS
857  "xsltCopyTextString: copy text %s\n",
858  string));
859 #endif
860 
861  /*
862  * Play safe and reset the merging mechanism for every new
863  * target node.
864  */
865  if ((target == NULL) || (target->children == NULL)) {
866  ctxt->lasttext = NULL;
867  }
868 
869  /* handle coalescing of text nodes here */
870  len = xmlStrlen(string);
871  if ((ctxt->type == XSLT_OUTPUT_XML) &&
872  (ctxt->style->cdataSection != NULL) &&
873  (target != NULL) &&
874  (target->type == XML_ELEMENT_NODE) &&
875  (((target->ns == NULL) &&
877  target->name, NULL) != NULL)) ||
878  ((target->ns != NULL) &&
880  target->name, target->ns->href) != NULL))))
881  {
882  /*
883  * Process "cdata-section-elements".
884  */
885  if ((target->last != NULL) &&
886  (target->last->type == XML_CDATA_SECTION_NODE))
887  {
888  return(xsltAddTextString(ctxt, target->last, string, len));
889  }
890  copy = xmlNewCDataBlock(ctxt->output, string, len);
891  } else if (noescape) {
892  /*
893  * Process "disable-output-escaping".
894  */
895  if ((target != NULL) && (target->last != NULL) &&
896  (target->last->type == XML_TEXT_NODE) &&
897  (target->last->name == xmlStringTextNoenc))
898  {
899  return(xsltAddTextString(ctxt, target->last, string, len));
900  }
901  copy = xmlNewTextLen(string, len);