ReactOS  0.4.14-dev-608-gd495a4f
preproc.h File Reference
#include <libxml/tree.h>
#include "xsltexports.h"
#include "xsltInternals.h"
Include dependency graph for preproc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

XSLTPUBFUN xsltElemPreCompPtr XSLTCALL xsltDocumentComp (xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function)
 
XSLTPUBFUN void XSLTCALL xsltStylePreCompute (xsltStylesheetPtr style, xmlNodePtr inst)
 
XSLTPUBFUN void XSLTCALL xsltFreeStylePreComps (xsltStylesheetPtr style)
 

Variables

const xmlCharxsltExtMarker
 

Function Documentation

◆ xsltDocumentComp()

XSLTPUBFUN xsltElemPreCompPtr XSLTCALL xsltDocumentComp ( xsltStylesheetPtr  style,
xmlNodePtr  inst,
xsltTransformFunction function  ATTRIBUTE_UNUSED 
)

xsltDocumentComp: @style: the XSLT stylesheet @inst: the instruction in the stylesheet @function: unused

Pre process an XSLT-1.1 document element

Returns a precompiled data structure for the element

Definition at line 508 of file preproc.c.

509  {
510 #ifdef XSLT_REFACTORED
511  xsltStyleItemDocumentPtr comp;
512 #else
513  xsltStylePreCompPtr comp;
514 #endif
515  const xmlChar *filename = NULL;
516 
517  /*
518  * As of 2006-03-30, this function is currently defined in Libxslt
519  * to be used for:
520  * (in libxslt/extra.c)
521  * "output" in XSLT_SAXON_NAMESPACE
522  * "write" XSLT_XALAN_NAMESPACE
523  * "document" XSLT_XT_NAMESPACE
524  * "document" XSLT_NAMESPACE (from the abandoned old working
525  * draft of XSLT 1.1)
526  * (in libexslt/common.c)
527  * "document" in EXSLT_COMMON_NAMESPACE
528  */
529 #ifdef XSLT_REFACTORED
530  comp = (xsltStyleItemDocumentPtr)
532 #else
534 #endif
535 
536  if (comp == NULL)
537  return (NULL);
538  comp->inst = inst;
539  comp->ver11 = 0;
540 
541  if (xmlStrEqual(inst->name, (const xmlChar *) "output")) {
542 #ifdef WITH_XSLT_DEBUG_EXTRA
544  "Found saxon:output extension\n");
545 #endif
546  /*
547  * The element "output" is in the namespace XSLT_SAXON_NAMESPACE
548  * (http://icl.com/saxon)
549  * The @file is in no namespace; it is an AVT.
550  * (http://www.computerwizards.com/saxon/doc/extensions.html#saxon:output)
551  *
552  * TODO: Do we need not to check the namespace here?
553  */
555  (const xmlChar *)"file",
556  NULL, &comp->has_filename);
557  } else if (xmlStrEqual(inst->name, (const xmlChar *) "write")) {
558 #ifdef WITH_XSLT_DEBUG_EXTRA
560  "Found xalan:write extension\n");
561 #endif
562  /* the filename need to be interpreted */
563  /*
564  * TODO: Is "filename need to be interpreted" meant to be a todo?
565  * Where will be the filename of xalan:write be processed?
566  *
567  * TODO: Do we need not to check the namespace here?
568  * The extension ns is "http://xml.apache.org/xalan/redirect".
569  * See http://xml.apache.org/xalan-j/extensionslib.html.
570  */
571  } else if (xmlStrEqual(inst->name, (const xmlChar *) "document")) {
572  if (inst->ns != NULL) {
573  if (xmlStrEqual(inst->ns->href, XSLT_NAMESPACE)) {
574  /*
575  * Mark the instruction as being of
576  * XSLT version 1.1 (abandoned).
577  */
578  comp->ver11 = 1;
579 #ifdef WITH_XSLT_DEBUG_EXTRA
581  "Found xslt11:document construct\n");
582 #endif
583  } else {
584  if (xmlStrEqual(inst->ns->href,
585  (const xmlChar *)"http://exslt.org/common")) {
586  /* EXSLT. */
587 #ifdef WITH_XSLT_DEBUG_EXTRA
589  "Found exslt:document extension\n");
590 #endif
591  } else if (xmlStrEqual(inst->ns->href, XSLT_XT_NAMESPACE)) {
592  /* James Clark's XT. */
593 #ifdef WITH_XSLT_DEBUG_EXTRA
595  "Found xt:document extension\n");
596 #endif
597  }
598  }
599  }
600  /*
601  * The element "document" is used in conjunction with the
602  * following namespaces:
603  *
604  * 1) XSLT_NAMESPACE (http://www.w3.org/1999/XSL/Transform version 1.1)
605  * <!ELEMENT xsl:document %template;>
606  * <!ATTLIST xsl:document
607  * href %avt; #REQUIRED
608  * @href is an AVT
609  * IMPORTANT: xsl:document was in the abandoned XSLT 1.1 draft,
610  * it was removed and isn't available in XSLT 1.1 anymore.
611  * In XSLT 2.0 it was renamed to xsl:result-document.
612  *
613  * All other attributes are identical to the attributes
614  * on xsl:output
615  *
616  * 2) EXSLT_COMMON_NAMESPACE (http://exslt.org/common)
617  * <exsl:document
618  * href = { uri-reference }
619  * TODO: is @href is an AVT?
620  *
621  * 3) XSLT_XT_NAMESPACE (http://www.jclark.com/xt)
622  * Example: <xt:document method="xml" href="myFile.xml">
623  * TODO: is @href is an AVT?
624  *
625  * In all cases @href is in no namespace.
626  */
628  (const xmlChar *)"href", NULL, &comp->has_filename);
629  }
630  if (!comp->has_filename) {
631  goto error;
632  }
633  comp->filename = filename;
634 
635 error:
636  return ((xsltElemPreCompPtr) comp);
637 }
#define error(str)
Definition: mkdosfs.c:1605
const xmlChar * name
Definition: tree.h:492
#define XSLT_NAMESPACE
Definition: xslt.h:46
const char * filename
Definition: ioapi.h:135
const xmlChar * filename
#define XSLT_XT_NAMESPACE
Definition: extra.h:41
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
const xmlChar * xsltEvalStaticAttrValueTemplate(xsltStylesheetPtr style, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns, int *found)
Definition: templates.c:430
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
unsigned char xmlChar
Definition: xmlstring.h:28
static xsltStylePreCompPtr xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type)
Definition: preproc.c:201
xmlNs * ns
Definition: tree.h:501
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
Arabic default style
Definition: afstyles.h:93
const xmlChar * href
Definition: tree.h:392

Referenced by xsltRegisterAllExtras(), and xsltStylePreCompute().

◆ xsltFreeStylePreComps()

XSLTPUBFUN void XSLTCALL xsltFreeStylePreComps ( xsltStylesheetPtr  style)

xsltFreeStylePreComps: @style: an XSLT transformation context

Free up the memory allocated by all precomputed blocks

Definition at line 1935 of file preproc.c.

1935  {
1936  xsltElemPreCompPtr cur, next;
1937 
1938  if (style == NULL)
1939  return;
1940 
1941  cur = style->preComps;
1942  while (cur != NULL) {
1943  next = cur->next;
1944  if (cur->type == XSLT_FUNC_EXTENSION)
1945  cur->free(cur);
1946  else
1948  cur = next;
1949  }
1950 }
xsltStyleType type
static void xsltFreeStylePreComp(xsltStylePreCompPtr comp)
Definition: preproc.c:357
smooth NULL
Definition: ftsmooth.c:416
xsltElemPreCompDeallocator free
static unsigned __int64 next
Definition: rand_nt.c:6
Arabic default style
Definition: afstyles.h:93
xsltElemPreCompPtr next

Referenced by xsltFreeStylesheet().

◆ xsltStylePreCompute()

XSLTPUBFUN void XSLTCALL xsltStylePreCompute ( xsltStylesheetPtr  style,
xmlNodePtr  inst 
)

xsltStylePreCompute: @style: the XSLT stylesheet @inst: the instruction in the stylesheet

Precompute an XSLT stylesheet element

Definition at line 2175 of file preproc.c.

2175  {
2176  /*
2177  * URGENT TODO: Normally inst->psvi Should never be reserved here,
2178  * BUT: since if we include the same stylesheet from
2179  * multiple imports, then the stylesheet will be parsed
2180  * again. We simply must not try to compute the stylesheet again.
2181  * TODO: Get to the point where we don't need to query the
2182  * namespace- and local-name of the node, but can evaluate this
2183  * using cctxt->style->inode->category;
2184  */
2185  if ((inst == NULL) || (inst->type != XML_ELEMENT_NODE) ||
2186  (inst->psvi != NULL))
2187  return;
2188 
2189  if (IS_XSLT_ELEM(inst)) {
2190  xsltStylePreCompPtr cur;
2191 
2192  if (IS_XSLT_NAME(inst, "apply-templates")) {
2195  } else if (IS_XSLT_NAME(inst, "with-param")) {
2196  xsltCheckParentElement(style, inst, BAD_CAST "apply-templates",
2197  BAD_CAST "call-template");
2198  xsltWithParamComp(style, inst);
2199  } else if (IS_XSLT_NAME(inst, "value-of")) {
2201  xsltValueOfComp(style, inst);
2202  } else if (IS_XSLT_NAME(inst, "copy")) {
2204  xsltCopyComp(style, inst);
2205  } else if (IS_XSLT_NAME(inst, "copy-of")) {
2207  xsltCopyOfComp(style, inst);
2208  } else if (IS_XSLT_NAME(inst, "if")) {
2210  xsltIfComp(style, inst);
2211  } else if (IS_XSLT_NAME(inst, "when")) {
2212  xsltCheckParentElement(style, inst, BAD_CAST "choose", NULL);
2213  xsltWhenComp(style, inst);
2214  } else if (IS_XSLT_NAME(inst, "choose")) {
2216  xsltChooseComp(style, inst);
2217  } else if (IS_XSLT_NAME(inst, "for-each")) {
2219  xsltForEachComp(style, inst);
2220  } else if (IS_XSLT_NAME(inst, "apply-imports")) {
2222  xsltApplyImportsComp(style, inst);
2223  } else if (IS_XSLT_NAME(inst, "attribute")) {
2224  xmlNodePtr parent = inst->parent;
2225 
2226  if ((parent == NULL) ||
2227  (parent->type != XML_ELEMENT_NODE) || (parent->ns == NULL) ||
2228  ((parent->ns != inst->ns) &&
2229  (!xmlStrEqual(parent->ns->href, inst->ns->href))) ||
2230  (!xmlStrEqual(parent->name, BAD_CAST "attribute-set"))) {
2232  }
2233  xsltAttributeComp(style, inst);
2234  } else if (IS_XSLT_NAME(inst, "element")) {
2236  xsltElementComp(style, inst);
2237  } else if (IS_XSLT_NAME(inst, "text")) {
2239  xsltTextComp(style, inst);
2240  } else if (IS_XSLT_NAME(inst, "sort")) {
2241  xsltCheckParentElement(style, inst, BAD_CAST "apply-templates",
2242  BAD_CAST "for-each");
2243  xsltSortComp(style, inst);
2244  } else if (IS_XSLT_NAME(inst, "comment")) {
2246  xsltCommentComp(style, inst);
2247  } else if (IS_XSLT_NAME(inst, "number")) {
2249  xsltNumberComp(style, inst);
2250  } else if (IS_XSLT_NAME(inst, "processing-instruction")) {
2253  } else if (IS_XSLT_NAME(inst, "call-template")) {
2255  xsltCallTemplateComp(style, inst);
2256  } else if (IS_XSLT_NAME(inst, "param")) {
2257  if (xsltCheckTopLevelElement(style, inst, 0) == 0)
2259  xsltParamComp(style, inst);
2260  } else if (IS_XSLT_NAME(inst, "variable")) {
2261  if (xsltCheckTopLevelElement(style, inst, 0) == 0)
2263  xsltVariableComp(style, inst);
2264  } else if (IS_XSLT_NAME(inst, "otherwise")) {
2265  xsltCheckParentElement(style, inst, BAD_CAST "choose", NULL);
2267  return;
2268  } else if (IS_XSLT_NAME(inst, "template")) {
2269  xsltCheckTopLevelElement(style, inst, 1);
2270  return;
2271  } else if (IS_XSLT_NAME(inst, "output")) {
2272  xsltCheckTopLevelElement(style, inst, 1);
2273  return;
2274  } else if (IS_XSLT_NAME(inst, "preserve-space")) {
2275  xsltCheckTopLevelElement(style, inst, 1);
2276  return;
2277  } else if (IS_XSLT_NAME(inst, "strip-space")) {
2278  xsltCheckTopLevelElement(style, inst, 1);
2279  return;
2280  } else if ((IS_XSLT_NAME(inst, "stylesheet")) ||
2281  (IS_XSLT_NAME(inst, "transform"))) {
2282  xmlNodePtr parent = inst->parent;
2283 
2284  if ((parent == NULL) || (parent->type != XML_DOCUMENT_NODE)) {
2285  xsltTransformError(NULL, style, inst,
2286  "element %s only allowed only as root element\n",
2287  inst->name);
2288  style->errors++;
2289  }
2290  return;
2291  } else if (IS_XSLT_NAME(inst, "key")) {
2292  xsltCheckTopLevelElement(style, inst, 1);
2293  return;
2294  } else if (IS_XSLT_NAME(inst, "message")) {
2296  return;
2297  } else if (IS_XSLT_NAME(inst, "attribute-set")) {
2298  xsltCheckTopLevelElement(style, inst, 1);
2299  return;
2300  } else if (IS_XSLT_NAME(inst, "namespace-alias")) {
2301  xsltCheckTopLevelElement(style, inst, 1);
2302  return;
2303  } else if (IS_XSLT_NAME(inst, "include")) {
2304  xsltCheckTopLevelElement(style, inst, 1);
2305  return;
2306  } else if (IS_XSLT_NAME(inst, "import")) {
2307  xsltCheckTopLevelElement(style, inst, 1);
2308  return;
2309  } else if (IS_XSLT_NAME(inst, "decimal-format")) {
2310  xsltCheckTopLevelElement(style, inst, 1);
2311  return;
2312  } else if (IS_XSLT_NAME(inst, "fallback")) {
2314  return;
2315  } else if (IS_XSLT_NAME(inst, "document")) {
2317  inst->psvi = (void *) xsltDocumentComp(style, inst,
2319  } else if ((style == NULL) || (style->forwards_compatible == 0)) {
2320  xsltTransformError(NULL, style, inst,
2321  "xsltStylePreCompute: unknown xsl:%s\n", inst->name);
2322  if (style != NULL) style->warnings++;
2323  }
2324 
2325  cur = (xsltStylePreCompPtr) inst->psvi;
2326  /*
2327  * A ns-list is build for every XSLT item in the
2328  * node-tree. This is needed for XPath expressions.
2329  */
2330  if (cur != NULL) {
2331  int i = 0;
2332 
2333  cur->nsList = xmlGetNsList(inst->doc, inst);
2334  if (cur->nsList != NULL) {
2335  while (cur->nsList[i] != NULL)
2336  i++;
2337  }
2338  cur->nsNr = i;
2339  }
2340  } else {
2341  inst->psvi =
2342  (void *) xsltPreComputeExtModuleElement(style, inst);
2343 
2344  /*
2345  * Unknown element, maybe registered at the context
2346  * level. Mark it for later recognition.
2347  */
2348  if (inst->psvi == NULL)
2349  inst->psvi = (void *) xsltExtMarker;
2350  }
2351 }
void * psvi
Definition: tree.h:505
static void xsltProcessingInstructionComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1111
static void xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1792
static void xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:969
const xmlChar * name
Definition: tree.h:492
static void xsltForEachComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1744
static void xsltTextComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:803
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
void xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:3335
struct _xmlDoc * doc
Definition: tree.h:498
static void xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1191
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 void xsltCommentComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1081
static void xsltIfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1652
static void xsltApplyTemplatesComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1569
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
struct _xmlNode * parent
Definition: tree.h:495
static void xsltCallTemplateComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1530
r parent
Definition: btrfs.c:2869
if(!(yy_init))
Definition: macro.lex.yy.c:714
xsltElemPreCompPtr xsltPreComputeExtModuleElement(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: extensions.c:1558
static void xsltCheckInstructionElement(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:86
Definition: tree.h:489
static void xsltCheckParentElement(xsltStylesheetPtr style, xmlNodePtr inst, const xmlChar *allow1, const xmlChar *allow2)
Definition: preproc.c:141
xsltElemPreCompPtr xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function ATTRIBUTE_UNUSED)
Definition: preproc.c:508
xmlElementType type
Definition: tree.h:491
xsltStylePreComp * xsltStylePreCompPtr
static void xsltWhenComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1698
static int xsltCheckTopLevelElement(xsltStylesheetPtr style, xmlNodePtr inst, int err)
Definition: preproc.c:48
static void xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: preproc.c:1376
static void xsltApplyImportsComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1500
static void xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1318
static void xsltCopyComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:760
static void xsltChooseComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1621
xmlNs * ns
Definition: tree.h:501
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
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 xsltCopyOfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1145
static void xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:849
static void xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:653
static void xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1871
const xmlChar * xsltExtMarker
Definition: preproc.c:24

Referenced by xsltParseGlobalParam(), xsltParseGlobalVariable(), xsltParseStylesheetAttributeSet(), and xsltParseTemplateContent().

Variable Documentation

◆ xsltExtMarker

const xmlChar* xsltExtMarker

Definition at line 24 of file preproc.c.

Referenced by xsltApplySequenceConstructor(), and xsltStylePreCompute().