ReactOS 0.4.16-dev-2208-g6350669
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

XSLTPUBVAR 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 528 of file preproc.c.

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

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 1951 of file preproc.c.

1951 {
1953
1954 if (style == NULL)
1955 return;
1956
1957 cur = style->preComps;
1958 while (cur != NULL) {
1959 next = cur->next;
1960 if (cur->type == XSLT_FUNC_EXTENSION)
1961 cur->free(cur);
1962 else
1964 cur = next;
1965 }
1966}
static void xsltFreeStylePreComp(xsltStylePreCompPtr comp)
Definition: preproc.c:381
FxCollectionEntry * cur
static unsigned __int64 next
Definition: rand_nt.c:6
@ XSLT_FUNC_EXTENSION

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 2191 of file preproc.c.

2191 {
2192 /*
2193 * URGENT TODO: Normally inst->psvi Should never be reserved here,
2194 * BUT: since if we include the same stylesheet from
2195 * multiple imports, then the stylesheet will be parsed
2196 * again. We simply must not try to compute the stylesheet again.
2197 * TODO: Get to the point where we don't need to query the
2198 * namespace- and local-name of the node, but can evaluate this
2199 * using cctxt->style->inode->category;
2200 */
2201 if ((inst == NULL) || (inst->type != XML_ELEMENT_NODE) ||
2202 (inst->psvi != NULL))
2203 return;
2204
2205 if (IS_XSLT_ELEM(inst)) {
2207
2208 if (IS_XSLT_NAME(inst, "apply-templates")) {
2211 } else if (IS_XSLT_NAME(inst, "with-param")) {
2212 xsltCheckParentElement(style, inst, BAD_CAST "apply-templates",
2213 BAD_CAST "call-template");
2214 xsltWithParamComp(style, inst);
2215 } else if (IS_XSLT_NAME(inst, "value-of")) {
2217 xsltValueOfComp(style, inst);
2218 } else if (IS_XSLT_NAME(inst, "copy")) {
2220 xsltCopyComp(style, inst);
2221 } else if (IS_XSLT_NAME(inst, "copy-of")) {
2223 xsltCopyOfComp(style, inst);
2224 } else if (IS_XSLT_NAME(inst, "if")) {
2226 xsltIfComp(style, inst);
2227 } else if (IS_XSLT_NAME(inst, "when")) {
2228 xsltCheckParentElement(style, inst, BAD_CAST "choose", NULL);
2229 xsltWhenComp(style, inst);
2230 } else if (IS_XSLT_NAME(inst, "choose")) {
2232 xsltChooseComp(style, inst);
2233 } else if (IS_XSLT_NAME(inst, "for-each")) {
2235 xsltForEachComp(style, inst);
2236 } else if (IS_XSLT_NAME(inst, "apply-imports")) {
2239 } else if (IS_XSLT_NAME(inst, "attribute")) {
2240 xmlNodePtr parent = inst->parent;
2241
2242 if ((parent == NULL) ||
2243 (parent->type != XML_ELEMENT_NODE) || (parent->ns == NULL) ||
2244 ((parent->ns != inst->ns) &&
2245 (!xmlStrEqual(parent->ns->href, inst->ns->href))) ||
2246 (!xmlStrEqual(parent->name, BAD_CAST "attribute-set"))) {
2248 }
2249 xsltAttributeComp(style, inst);
2250 } else if (IS_XSLT_NAME(inst, "element")) {
2252 xsltElementComp(style, inst);
2253 } else if (IS_XSLT_NAME(inst, "text")) {
2255 xsltTextComp(style, inst);
2256 } else if (IS_XSLT_NAME(inst, "sort")) {
2257 xsltCheckParentElement(style, inst, BAD_CAST "apply-templates",
2258 BAD_CAST "for-each");
2259 xsltSortComp(style, inst);
2260 } else if (IS_XSLT_NAME(inst, "comment")) {
2262 xsltCommentComp(style, inst);
2263 } else if (IS_XSLT_NAME(inst, "number")) {
2265 xsltNumberComp(style, inst);
2266 } else if (IS_XSLT_NAME(inst, "processing-instruction")) {
2269 } else if (IS_XSLT_NAME(inst, "call-template")) {
2272 } else if (IS_XSLT_NAME(inst, "param")) {
2273 if (xsltCheckTopLevelElement(style, inst, 0) == 0)
2275 xsltParamComp(style, inst);
2276 } else if (IS_XSLT_NAME(inst, "variable")) {
2277 if (xsltCheckTopLevelElement(style, inst, 0) == 0)
2279 xsltVariableComp(style, inst);
2280 } else if (IS_XSLT_NAME(inst, "otherwise")) {
2281 xsltCheckParentElement(style, inst, BAD_CAST "choose", NULL);
2283 return;
2284 } else if (IS_XSLT_NAME(inst, "template")) {
2286 return;
2287 } else if (IS_XSLT_NAME(inst, "output")) {
2289 return;
2290 } else if (IS_XSLT_NAME(inst, "preserve-space")) {
2292 return;
2293 } else if (IS_XSLT_NAME(inst, "strip-space")) {
2295 return;
2296 } else if ((IS_XSLT_NAME(inst, "stylesheet")) ||
2297 (IS_XSLT_NAME(inst, "transform"))) {
2298 xmlNodePtr parent = inst->parent;
2299
2300 if ((parent == NULL) || (parent->type != XML_DOCUMENT_NODE)) {
2302 "element %s only allowed only as root element\n",
2303 inst->name);
2304 style->errors++;
2305 }
2306 return;
2307 } else if (IS_XSLT_NAME(inst, "key")) {
2309 return;
2310 } else if (IS_XSLT_NAME(inst, "message")) {
2312 return;
2313 } else if (IS_XSLT_NAME(inst, "attribute-set")) {
2315 return;
2316 } else if (IS_XSLT_NAME(inst, "namespace-alias")) {
2318 return;
2319 } else if (IS_XSLT_NAME(inst, "include")) {
2321 return;
2322 } else if (IS_XSLT_NAME(inst, "import")) {
2324 return;
2325 } else if (IS_XSLT_NAME(inst, "decimal-format")) {
2327 return;
2328 } else if (IS_XSLT_NAME(inst, "fallback")) {
2330 return;
2331 } else if (IS_XSLT_NAME(inst, "document")) {
2333 inst->psvi = (void *) xsltDocumentComp(style, inst,
2335 } else if ((style == NULL) || (style->forwards_compatible == 0)) {
2337 "xsltStylePreCompute: unknown xsl:%s\n", inst->name);
2338 if (style != NULL) style->warnings++;
2339 }
2340
2341 cur = (xsltStylePreCompPtr) inst->psvi;
2342 /*
2343 * A ns-list is build for every XSLT item in the
2344 * node-tree. This is needed for XPath expressions.
2345 */
2346 if (cur != NULL) {
2347 int i = 0;
2348
2349 cur->nsList = xmlGetNsList(inst->doc, inst);
2350 if (cur->nsList != NULL) {
2351 while (cur->nsList[i] != NULL)
2352 i++;
2353 }
2354 cur->nsNr = i;
2355 }
2356 } else {
2357 inst->psvi =
2358 (void *) xsltPreComputeExtModuleElement(style, inst);
2359
2360 /*
2361 * Unknown element, maybe registered at the context
2362 * level. Mark it for later recognition.
2363 */
2364 if (inst->psvi == NULL)
2365 inst->psvi = (void *) xsltExtMarker;
2366 }
2367}
xsltElemPreCompPtr xsltPreComputeExtModuleElement(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: extensions.c:1583
static void xsltProcessingInstructionComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1125
static void xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:983
static void xsltChooseComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1637
static void xsltCallTemplateComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1546
static void xsltCopyOfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1159
static void xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1205
static void xsltCommentComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1095
const xmlChar * xsltExtMarker
Definition: preproc.c:48
xsltElemPreCompPtr xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function ATTRIBUTE_UNUSED)
Definition: preproc.c:528
static void xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1332
static void xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:673
static int xsltCheckTopLevelElement(xsltStylesheetPtr style, xmlNodePtr inst, int err)
Definition: preproc.c:72
static void xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:863
static void xsltApplyImportsComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1516
static void xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1887
static void xsltTextComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:817
static void xsltIfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1668
static void xsltCheckParentElement(xsltStylesheetPtr style, xmlNodePtr inst, const xmlChar *allow1, const xmlChar *allow2)
Definition: preproc.c:165
static void xsltCheckInstructionElement(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:110
static void xsltCopyComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:774
static void xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: preproc.c:1390
static void xsltApplyTemplatesComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1585
static void xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1808
static void xsltForEachComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1760
static void xsltWhenComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1714
void xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:3363
r parent
Definition: btrfs.c:3010
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
if(dx< 0)
Definition: linetemp.h:194
#define BAD_CAST
Definition: xmlstring.h:35
xsltStylePreComp * xsltStylePreCompPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:60
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:51

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

Variable Documentation

◆ xsltExtMarker

XSLTPUBVAR const xmlChar* xsltExtMarker

Definition at line 25 of file preproc.h.