ReactOS 0.4.16-dev-258-g81860b4
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 508 of file preproc.c.

509 {
510#ifdef XSLT_REFACTORED
511 xsltStyleItemDocumentPtr comp;
512#else
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
635error:
636 return ((xsltElemPreCompPtr) comp);
637}
Arabic default style
Definition: afstyles.h:94
#define NULL
Definition: types.h:112
static xsltStylePreCompPtr xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type)
Definition: preproc.c:201
#define XSLT_XT_NAMESPACE
Definition: extra.h:41
const char * filename
Definition: ioapi.h:137
#define error(str)
Definition: mkdosfs.c:1605
const xmlChar * name
Definition: tree.h:492
xmlNs * ns
Definition: tree.h:501
const xmlChar * href
Definition: tree.h:392
const xmlChar * xsltEvalStaticAttrValueTemplate(xsltStylesheetPtr style, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns, int *found)
Definition: templates.c:438
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160
unsigned char xmlChar
Definition: xmlstring.h:28
@ XSLT_FUNC_DOCUMENT
#define XSLT_NAMESPACE
Definition: xslt.h:46
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
void * xsltGenericDebugContext
Definition: xsltutils.c:549

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

1937 {
1939
1940 if (style == NULL)
1941 return;
1942
1943 cur = style->preComps;
1944 while (cur != NULL) {
1945 next = cur->next;
1946 if (cur->type == XSLT_FUNC_EXTENSION)
1947 cur->free(cur);
1948 else
1950 cur = next;
1951 }
1952}
static void xsltFreeStylePreComp(xsltStylePreCompPtr comp)
Definition: preproc.c:357
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 2177 of file preproc.c.

2177 {
2178 /*
2179 * URGENT TODO: Normally inst->psvi Should never be reserved here,
2180 * BUT: since if we include the same stylesheet from
2181 * multiple imports, then the stylesheet will be parsed
2182 * again. We simply must not try to compute the stylesheet again.
2183 * TODO: Get to the point where we don't need to query the
2184 * namespace- and local-name of the node, but can evaluate this
2185 * using cctxt->style->inode->category;
2186 */
2187 if ((inst == NULL) || (inst->type != XML_ELEMENT_NODE) ||
2188 (inst->psvi != NULL))
2189 return;
2190
2191 if (IS_XSLT_ELEM(inst)) {
2193
2194 if (IS_XSLT_NAME(inst, "apply-templates")) {
2197 } else if (IS_XSLT_NAME(inst, "with-param")) {
2198 xsltCheckParentElement(style, inst, BAD_CAST "apply-templates",
2199 BAD_CAST "call-template");
2200 xsltWithParamComp(style, inst);
2201 } else if (IS_XSLT_NAME(inst, "value-of")) {
2203 xsltValueOfComp(style, inst);
2204 } else if (IS_XSLT_NAME(inst, "copy")) {
2206 xsltCopyComp(style, inst);
2207 } else if (IS_XSLT_NAME(inst, "copy-of")) {
2209 xsltCopyOfComp(style, inst);
2210 } else if (IS_XSLT_NAME(inst, "if")) {
2212 xsltIfComp(style, inst);
2213 } else if (IS_XSLT_NAME(inst, "when")) {
2214 xsltCheckParentElement(style, inst, BAD_CAST "choose", NULL);
2215 xsltWhenComp(style, inst);
2216 } else if (IS_XSLT_NAME(inst, "choose")) {
2218 xsltChooseComp(style, inst);
2219 } else if (IS_XSLT_NAME(inst, "for-each")) {
2221 xsltForEachComp(style, inst);
2222 } else if (IS_XSLT_NAME(inst, "apply-imports")) {
2225 } else if (IS_XSLT_NAME(inst, "attribute")) {
2226 xmlNodePtr parent = inst->parent;
2227
2228 if ((parent == NULL) ||
2229 (parent->type != XML_ELEMENT_NODE) || (parent->ns == NULL) ||
2230 ((parent->ns != inst->ns) &&
2231 (!xmlStrEqual(parent->ns->href, inst->ns->href))) ||
2232 (!xmlStrEqual(parent->name, BAD_CAST "attribute-set"))) {
2234 }
2235 xsltAttributeComp(style, inst);
2236 } else if (IS_XSLT_NAME(inst, "element")) {
2238 xsltElementComp(style, inst);
2239 } else if (IS_XSLT_NAME(inst, "text")) {
2241 xsltTextComp(style, inst);
2242 } else if (IS_XSLT_NAME(inst, "sort")) {
2243 xsltCheckParentElement(style, inst, BAD_CAST "apply-templates",
2244 BAD_CAST "for-each");
2245 xsltSortComp(style, inst);
2246 } else if (IS_XSLT_NAME(inst, "comment")) {
2248 xsltCommentComp(style, inst);
2249 } else if (IS_XSLT_NAME(inst, "number")) {
2251 xsltNumberComp(style, inst);
2252 } else if (IS_XSLT_NAME(inst, "processing-instruction")) {
2255 } else if (IS_XSLT_NAME(inst, "call-template")) {
2258 } else if (IS_XSLT_NAME(inst, "param")) {
2259 if (xsltCheckTopLevelElement(style, inst, 0) == 0)
2261 xsltParamComp(style, inst);
2262 } else if (IS_XSLT_NAME(inst, "variable")) {
2263 if (xsltCheckTopLevelElement(style, inst, 0) == 0)
2265 xsltVariableComp(style, inst);
2266 } else if (IS_XSLT_NAME(inst, "otherwise")) {
2267 xsltCheckParentElement(style, inst, BAD_CAST "choose", NULL);
2269 return;
2270 } else if (IS_XSLT_NAME(inst, "template")) {
2272 return;
2273 } else if (IS_XSLT_NAME(inst, "output")) {
2275 return;
2276 } else if (IS_XSLT_NAME(inst, "preserve-space")) {
2278 return;
2279 } else if (IS_XSLT_NAME(inst, "strip-space")) {
2281 return;
2282 } else if ((IS_XSLT_NAME(inst, "stylesheet")) ||
2283 (IS_XSLT_NAME(inst, "transform"))) {
2284 xmlNodePtr parent = inst->parent;
2285
2286 if ((parent == NULL) || (parent->type != XML_DOCUMENT_NODE)) {
2288 "element %s only allowed only as root element\n",
2289 inst->name);
2290 style->errors++;
2291 }
2292 return;
2293 } else if (IS_XSLT_NAME(inst, "key")) {
2295 return;
2296 } else if (IS_XSLT_NAME(inst, "message")) {
2298 return;
2299 } else if (IS_XSLT_NAME(inst, "attribute-set")) {
2301 return;
2302 } else if (IS_XSLT_NAME(inst, "namespace-alias")) {
2304 return;
2305 } else if (IS_XSLT_NAME(inst, "include")) {
2307 return;
2308 } else if (IS_XSLT_NAME(inst, "import")) {
2310 return;
2311 } else if (IS_XSLT_NAME(inst, "decimal-format")) {
2313 return;
2314 } else if (IS_XSLT_NAME(inst, "fallback")) {
2316 return;
2317 } else if (IS_XSLT_NAME(inst, "document")) {
2319 inst->psvi = (void *) xsltDocumentComp(style, inst,
2321 } else if ((style == NULL) || (style->forwards_compatible == 0)) {
2323 "xsltStylePreCompute: unknown xsl:%s\n", inst->name);
2324 if (style != NULL) style->warnings++;
2325 }
2326
2327 cur = (xsltStylePreCompPtr) inst->psvi;
2328 /*
2329 * A ns-list is build for every XSLT item in the
2330 * node-tree. This is needed for XPath expressions.
2331 */
2332 if (cur != NULL) {
2333 int i = 0;
2334
2335 cur->nsList = xmlGetNsList(inst->doc, inst);
2336 if (cur->nsList != NULL) {
2337 while (cur->nsList[i] != NULL)
2338 i++;
2339 }
2340 cur->nsNr = i;
2341 }
2342 } else {
2343 inst->psvi =
2344 (void *) xsltPreComputeExtModuleElement(style, inst);
2345
2346 /*
2347 * Unknown element, maybe registered at the context
2348 * level. Mark it for later recognition.
2349 */
2350 if (inst->psvi == NULL)
2351 inst->psvi = (void *) xsltExtMarker;
2352 }
2353}
xsltElemPreCompPtr xsltPreComputeExtModuleElement(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: extensions.c:1558
static void xsltProcessingInstructionComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1111
static void xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:969
static void xsltChooseComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1623
static void xsltCallTemplateComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1532
static void xsltCopyOfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1145
static void xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1191
static void xsltCommentComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1081
const xmlChar * xsltExtMarker
Definition: preproc.c:24
xsltElemPreCompPtr xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function ATTRIBUTE_UNUSED)
Definition: preproc.c:508
static void xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1318
static void xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:653
static int xsltCheckTopLevelElement(xsltStylesheetPtr style, xmlNodePtr inst, int err)
Definition: preproc.c:48
static void xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:849
static void xsltApplyImportsComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1502
static void xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1873
static void xsltTextComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:803
static void xsltIfComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1654
static void xsltCheckParentElement(xsltStylesheetPtr style, xmlNodePtr inst, const xmlChar *allow1, const xmlChar *allow2)
Definition: preproc.c:141
static void xsltCheckInstructionElement(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:86
static void xsltCopyComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:760
static void xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: preproc.c:1376
static void xsltApplyTemplatesComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1571
static void xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1794
static void xsltForEachComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1746
static void xsltWhenComp(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:1700
void xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: transform.c:3323
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
@ XML_DOCUMENT_NODE
Definition: tree.h:168
@ XML_ELEMENT_NODE
Definition: tree.h:160
Definition: tree.h:489
void * psvi
Definition: tree.h:505
struct _xmlDoc * doc
Definition: tree.h:498
xmlElementType type
Definition: tree.h:491
struct _xmlNode * parent
Definition: tree.h:495
#define BAD_CAST
Definition: xmlstring.h:35
xsltStylePreComp * xsltStylePreCompPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#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.