2 * preproc.c: Preprocessing of style operations
5 * http://www.w3.org/TR/1999/REC-xslt-19991116
7 * Michael Kay "XSLT Programmer's Reference" pp 637-643
8 * Writing Multiple Output Files
10 * XSLT-1.1 Working Draft
11 * http://www.w3.org/TR/xslt11#multiple-output
13 * See Copyright for the status of this software.
20 #ifdef WITH_XSLT_DEBUG
21 #define WITH_XSLT_DEBUG_PREPROC
24 const xmlChar
*xsltExtMarker
= (const xmlChar
*) "Extension Element";
26 /************************************************************************
30 ************************************************************************/
32 #ifdef XSLT_REFACTORED
34 * Grammar checks are now performed in xslt.c.
38 * xsltCheckTopLevelElement:
39 * @style: the XSLT stylesheet
40 * @inst: the XSLT instruction
41 * @err: raise an error or not
43 * Check that the instruction is instanciated as a top level element.
45 * Returns -1 in case of error, 0 if failed and 1 in case of success
48 xsltCheckTopLevelElement(xsltStylesheetPtr style
, xmlNodePtr inst
, int err
) {
50 if ((style
== NULL
) || (inst
== NULL
) || (inst
->ns
== NULL
))
53 parent
= inst
->parent
;
56 xsltTransformError(NULL
, style
, inst
,
57 "internal problem: element has no parent\n");
62 if ((parent
->ns
== NULL
) || (parent
->type
!= XML_ELEMENT_NODE
) ||
63 ((parent
->ns
!= inst
->ns
) &&
64 (!xmlStrEqual(parent
->ns
->href
, inst
->ns
->href
))) ||
65 ((!xmlStrEqual(parent
->name
, BAD_CAST
"stylesheet")) &&
66 (!xmlStrEqual(parent
->name
, BAD_CAST
"transform")))) {
68 xsltTransformError(NULL
, style
, inst
,
69 "element %s only allowed as child of stylesheet\n",
79 * xsltCheckInstructionElement:
80 * @style: the XSLT stylesheet
81 * @inst: the XSLT instruction
83 * Check that the instruction is instanciated as an instruction element.
86 xsltCheckInstructionElement(xsltStylesheetPtr style
, xmlNodePtr inst
) {
90 if ((style
== NULL
) || (inst
== NULL
) || (inst
->ns
== NULL
) ||
91 (style
->literal_result
))
94 has_ext
= (style
->extInfos
!= NULL
);
96 parent
= inst
->parent
;
98 xsltTransformError(NULL
, style
, inst
,
99 "internal problem: element has no parent\n");
103 while ((parent
!= NULL
) && (parent
->type
!= XML_DOCUMENT_NODE
)) {
104 if (((parent
->ns
== inst
->ns
) ||
105 ((parent
->ns
!= NULL
) &&
106 (xmlStrEqual(parent
->ns
->href
, inst
->ns
->href
)))) &&
107 ((xmlStrEqual(parent
->name
, BAD_CAST
"template")) ||
108 (xmlStrEqual(parent
->name
, BAD_CAST
"param")) ||
109 (xmlStrEqual(parent
->name
, BAD_CAST
"attribute")) ||
110 (xmlStrEqual(parent
->name
, BAD_CAST
"variable")))) {
115 * if we are within an extension element all bets are off
116 * about the semantic there e.g. xsl:param within func:function
118 if ((has_ext
) && (parent
->ns
!= NULL
) &&
119 (xmlHashLookup(style
->extInfos
, parent
->ns
->href
) != NULL
))
122 parent
= parent
->parent
;
124 xsltTransformError(NULL
, style
, inst
,
125 "element %s only allowed within a template, variable or param\n",
131 * xsltCheckParentElement:
132 * @style: the XSLT stylesheet
133 * @inst: the XSLT instruction
134 * @allow1: allowed parent1
135 * @allow2: allowed parent2
137 * Check that the instruction is instanciated as the childre of one of the
141 xsltCheckParentElement(xsltStylesheetPtr style
, xmlNodePtr inst
,
142 const xmlChar
*allow1
, const xmlChar
*allow2
) {
145 if ((style
== NULL
) || (inst
== NULL
) || (inst
->ns
== NULL
) ||
146 (style
->literal_result
))
149 parent
= inst
->parent
;
150 if (parent
== NULL
) {
151 xsltTransformError(NULL
, style
, inst
,
152 "internal problem: element has no parent\n");
156 if (((parent
->ns
== inst
->ns
) ||
157 ((parent
->ns
!= NULL
) &&
158 (xmlStrEqual(parent
->ns
->href
, inst
->ns
->href
)))) &&
159 ((xmlStrEqual(parent
->name
, allow1
)) ||
160 (xmlStrEqual(parent
->name
, allow2
)))) {
164 if (style
->extInfos
!= NULL
) {
165 while ((parent
!= NULL
) && (parent
->type
!= XML_DOCUMENT_NODE
)) {
167 * if we are within an extension element all bets are off
168 * about the semantic there e.g. xsl:param within func:function
170 if ((parent
->ns
!= NULL
) &&
171 (xmlHashLookup(style
->extInfos
, parent
->ns
->href
) != NULL
))
174 parent
= parent
->parent
;
177 xsltTransformError(NULL
, style
, inst
,
178 "element %s is not allowed within that context\n",
184 /************************************************************************
186 * handling of precomputed data *
188 ************************************************************************/
191 * xsltNewStylePreComp:
192 * @style: the XSLT stylesheet
193 * @type: the construct type
195 * Create a new XSLT Style precomputed block
197 * Returns the newly allocated specialized structure
198 * or NULL in case of error
200 static xsltStylePreCompPtr
201 xsltNewStylePreComp(xsltStylesheetPtr style
, xsltStyleType type
) {
202 xsltStylePreCompPtr cur
;
203 #ifdef XSLT_REFACTORED
210 #ifdef XSLT_REFACTORED
212 * URGENT TODO: Use specialized factory functions in order
213 * to avoid this ugliness.
217 size
= sizeof(xsltStyleItemCopy
); break;
219 size
= sizeof(xsltStyleItemSort
); break;
221 size
= sizeof(xsltStyleItemText
); break;
222 case XSLT_FUNC_ELEMENT
:
223 size
= sizeof(xsltStyleItemElement
); break;
224 case XSLT_FUNC_ATTRIBUTE
:
225 size
= sizeof(xsltStyleItemAttribute
); break;
226 case XSLT_FUNC_COMMENT
:
227 size
= sizeof(xsltStyleItemComment
); break;
229 size
= sizeof(xsltStyleItemPI
); break;
230 case XSLT_FUNC_COPYOF
:
231 size
= sizeof(xsltStyleItemCopyOf
); break;
232 case XSLT_FUNC_VALUEOF
:
233 size
= sizeof(xsltStyleItemValueOf
); break;;
234 case XSLT_FUNC_NUMBER
:
235 size
= sizeof(xsltStyleItemNumber
); break;
236 case XSLT_FUNC_APPLYIMPORTS
:
237 size
= sizeof(xsltStyleItemApplyImports
); break;
238 case XSLT_FUNC_CALLTEMPLATE
:
239 size
= sizeof(xsltStyleItemCallTemplate
); break;
240 case XSLT_FUNC_APPLYTEMPLATES
:
241 size
= sizeof(xsltStyleItemApplyTemplates
); break;
242 case XSLT_FUNC_CHOOSE
:
243 size
= sizeof(xsltStyleItemChoose
); break;
245 size
= sizeof(xsltStyleItemIf
); break;
246 case XSLT_FUNC_FOREACH
:
247 size
= sizeof(xsltStyleItemForEach
); break;
248 case XSLT_FUNC_DOCUMENT
:
249 size
= sizeof(xsltStyleItemDocument
); break;
250 case XSLT_FUNC_WITHPARAM
:
251 size
= sizeof(xsltStyleItemWithParam
); break;
252 case XSLT_FUNC_PARAM
:
253 size
= sizeof(xsltStyleItemParam
); break;
254 case XSLT_FUNC_VARIABLE
:
255 size
= sizeof(xsltStyleItemVariable
); break;
257 size
= sizeof(xsltStyleItemWhen
); break;
258 case XSLT_FUNC_OTHERWISE
:
259 size
= sizeof(xsltStyleItemOtherwise
); break;
261 xsltTransformError(NULL
, style
, NULL
,
262 "xsltNewStylePreComp : invalid type %d\n", type
);
267 * Create the structure.
269 cur
= (xsltStylePreCompPtr
) xmlMalloc(size
);
271 xsltTransformError(NULL
, style
, NULL
,
272 "xsltNewStylePreComp : malloc failed\n");
276 memset(cur
, 0, size
);
278 #else /* XSLT_REFACTORED */
282 cur
= (xsltStylePreCompPtr
) xmlMalloc(sizeof(xsltStylePreComp
));
284 xsltTransformError(NULL
, style
, NULL
,
285 "xsltNewStylePreComp : malloc failed\n");
289 memset(cur
, 0, sizeof(xsltStylePreComp
));
290 #endif /* XSLT_REFACTORED */
293 * URGENT TODO: Better to move this to spezialized factory functions.
298 cur
->func
= (xsltTransformFunction
) xsltCopy
;break;
300 cur
->func
= (xsltTransformFunction
) xsltSort
;break;
302 cur
->func
= (xsltTransformFunction
) xsltText
;break;
303 case XSLT_FUNC_ELEMENT
:
304 cur
->func
= (xsltTransformFunction
) xsltElement
;break;
305 case XSLT_FUNC_ATTRIBUTE
:
306 cur
->func
= (xsltTransformFunction
) xsltAttribute
;break;
307 case XSLT_FUNC_COMMENT
:
308 cur
->func
= (xsltTransformFunction
) xsltComment
;break;
310 cur
->func
= (xsltTransformFunction
) xsltProcessingInstruction
;
312 case XSLT_FUNC_COPYOF
:
313 cur
->func
= (xsltTransformFunction
) xsltCopyOf
;break;
314 case XSLT_FUNC_VALUEOF
:
315 cur
->func
= (xsltTransformFunction
) xsltValueOf
;break;
316 case XSLT_FUNC_NUMBER
:
317 cur
->func
= (xsltTransformFunction
) xsltNumber
;break;
318 case XSLT_FUNC_APPLYIMPORTS
:
319 cur
->func
= (xsltTransformFunction
) xsltApplyImports
;break;
320 case XSLT_FUNC_CALLTEMPLATE
:
321 cur
->func
= (xsltTransformFunction
) xsltCallTemplate
;break;
322 case XSLT_FUNC_APPLYTEMPLATES
:
323 cur
->func
= (xsltTransformFunction
) xsltApplyTemplates
;break;
324 case XSLT_FUNC_CHOOSE
:
325 cur
->func
= (xsltTransformFunction
) xsltChoose
;break;
327 cur
->func
= (xsltTransformFunction
) xsltIf
;break;
328 case XSLT_FUNC_FOREACH
:
329 cur
->func
= (xsltTransformFunction
) xsltForEach
;break;
330 case XSLT_FUNC_DOCUMENT
:
331 cur
->func
= (xsltTransformFunction
) xsltDocumentElem
;break;
332 case XSLT_FUNC_WITHPARAM
:
333 case XSLT_FUNC_PARAM
:
334 case XSLT_FUNC_VARIABLE
:
338 if (cur
->func
== NULL
) {
339 xsltTransformError(NULL
, style
, NULL
,
340 "xsltNewStylePreComp : no function for type %d\n", type
);
344 cur
->next
= style
->preComps
;
345 style
->preComps
= (xsltElemPreCompPtr
) cur
;
351 * xsltFreeStylePreComp:
352 * @comp: an XSLT Style precomputed block
354 * Free up the memory allocated by @comp
357 xsltFreeStylePreComp(xsltStylePreCompPtr comp
) {
360 #ifdef XSLT_REFACTORED
362 * URGENT TODO: Implement destructors.
364 switch (comp
->type
) {
365 case XSLT_FUNC_LITERAL_RESULT_ELEMENT
:
369 case XSLT_FUNC_SORT
: {
370 xsltStyleItemSortPtr item
= (xsltStyleItemSortPtr
) comp
;
371 if (item
->locale
!= (xsltLocale
)0)
372 xsltFreeLocale(item
->locale
);
373 if (item
->comp
!= NULL
)
374 xmlXPathFreeCompExpr(item
->comp
);
379 case XSLT_FUNC_ELEMENT
:
381 case XSLT_FUNC_ATTRIBUTE
:
383 case XSLT_FUNC_COMMENT
:
387 case XSLT_FUNC_COPYOF
: {
388 xsltStyleItemCopyOfPtr item
= (xsltStyleItemCopyOfPtr
) comp
;
389 if (item
->comp
!= NULL
)
390 xmlXPathFreeCompExpr(item
->comp
);
393 case XSLT_FUNC_VALUEOF
: {
394 xsltStyleItemValueOfPtr item
= (xsltStyleItemValueOfPtr
) comp
;
395 if (item
->comp
!= NULL
)
396 xmlXPathFreeCompExpr(item
->comp
);
399 case XSLT_FUNC_NUMBER
: {
400 xsltStyleItemNumberPtr item
= (xsltStyleItemNumberPtr
) comp
;
401 if (item
->numdata
.countPat
!= NULL
)
402 xsltFreeCompMatchList(item
->numdata
.countPat
);
403 if (item
->numdata
.fromPat
!= NULL
)
404 xsltFreeCompMatchList(item
->numdata
.fromPat
);
407 case XSLT_FUNC_APPLYIMPORTS
:
409 case XSLT_FUNC_CALLTEMPLATE
:
411 case XSLT_FUNC_APPLYTEMPLATES
: {
412 xsltStyleItemApplyTemplatesPtr item
=
413 (xsltStyleItemApplyTemplatesPtr
) comp
;
414 if (item
->comp
!= NULL
)
415 xmlXPathFreeCompExpr(item
->comp
);
418 case XSLT_FUNC_CHOOSE
:
421 xsltStyleItemIfPtr item
= (xsltStyleItemIfPtr
) comp
;
422 if (item
->comp
!= NULL
)
423 xmlXPathFreeCompExpr(item
->comp
);
426 case XSLT_FUNC_FOREACH
: {
427 xsltStyleItemForEachPtr item
=
428 (xsltStyleItemForEachPtr
) comp
;
429 if (item
->comp
!= NULL
)
430 xmlXPathFreeCompExpr(item
->comp
);
433 case XSLT_FUNC_DOCUMENT
:
435 case XSLT_FUNC_WITHPARAM
: {
436 xsltStyleItemWithParamPtr item
=
437 (xsltStyleItemWithParamPtr
) comp
;
438 if (item
->comp
!= NULL
)
439 xmlXPathFreeCompExpr(item
->comp
);
442 case XSLT_FUNC_PARAM
: {
443 xsltStyleItemParamPtr item
=
444 (xsltStyleItemParamPtr
) comp
;
445 if (item
->comp
!= NULL
)
446 xmlXPathFreeCompExpr(item
->comp
);
449 case XSLT_FUNC_VARIABLE
: {
450 xsltStyleItemVariablePtr item
=
451 (xsltStyleItemVariablePtr
) comp
;
452 if (item
->comp
!= NULL
)
453 xmlXPathFreeCompExpr(item
->comp
);
456 case XSLT_FUNC_WHEN
: {
457 xsltStyleItemWhenPtr item
=
458 (xsltStyleItemWhenPtr
) comp
;
459 if (item
->comp
!= NULL
)
460 xmlXPathFreeCompExpr(item
->comp
);
463 case XSLT_FUNC_OTHERWISE
:
464 case XSLT_FUNC_FALLBACK
:
465 case XSLT_FUNC_MESSAGE
:
466 case XSLT_FUNC_INCLUDE
:
467 case XSLT_FUNC_ATTRSET
:
471 /* TODO: Raise error. */
475 if (comp
->locale
!= (xsltLocale
)0)
476 xsltFreeLocale(comp
->locale
);
477 if (comp
->comp
!= NULL
)
478 xmlXPathFreeCompExpr(comp
->comp
);
479 if (comp
->numdata
.countPat
!= NULL
)
480 xsltFreeCompMatchList(comp
->numdata
.countPat
);
481 if (comp
->numdata
.fromPat
!= NULL
)
482 xsltFreeCompMatchList(comp
->numdata
.fromPat
);
483 if (comp
->nsList
!= NULL
)
484 xmlFree(comp
->nsList
);
491 /************************************************************************
493 * XSLT-1.1 extensions *
495 ************************************************************************/
499 * @style: the XSLT stylesheet
500 * @inst: the instruction in the stylesheet
503 * Pre process an XSLT-1.1 document element
505 * Returns a precompiled data structure for the element
508 xsltDocumentComp(xsltStylesheetPtr style
, xmlNodePtr inst
,
509 xsltTransformFunction function ATTRIBUTE_UNUSED
) {
510 #ifdef XSLT_REFACTORED
511 xsltStyleItemDocumentPtr comp
;
513 xsltStylePreCompPtr comp
;
515 const xmlChar
*filename
= NULL
;
518 * As of 2006-03-30, this function is currently defined in Libxslt
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
526 * (in libexslt/common.c)
527 * "document" in EXSLT_COMMON_NAMESPACE
529 #ifdef XSLT_REFACTORED
530 comp
= (xsltStyleItemDocumentPtr
)
531 xsltNewStylePreComp(style
, XSLT_FUNC_DOCUMENT
);
533 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_DOCUMENT
);
541 if (xmlStrEqual(inst
->name
, (const xmlChar
*) "output")) {
542 #ifdef WITH_XSLT_DEBUG_EXTRA
543 xsltGenericDebug(xsltGenericDebugContext
,
544 "Found saxon:output extension\n");
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)
552 * TODO: Do we need not to check the namespace here?
554 filename
= xsltEvalStaticAttrValueTemplate(style
, inst
,
555 (const xmlChar
*)"file",
556 NULL
, &comp
->has_filename
);
557 } else if (xmlStrEqual(inst
->name
, (const xmlChar
*) "write")) {
558 #ifdef WITH_XSLT_DEBUG_EXTRA
559 xsltGenericDebug(xsltGenericDebugContext
,
560 "Found xalan:write extension\n");
562 /* the filename need to be interpreted */
564 * TODO: Is "filename need to be interpreted" meant to be a todo?
565 * Where will be the filename of xalan:write be processed?
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.
571 } else if (xmlStrEqual(inst
->name
, (const xmlChar
*) "document")) {
572 if (inst
->ns
!= NULL
) {
573 if (xmlStrEqual(inst
->ns
->href
, XSLT_NAMESPACE
)) {
575 * Mark the instruction as being of
576 * XSLT version 1.1 (abandoned).
579 #ifdef WITH_XSLT_DEBUG_EXTRA
580 xsltGenericDebug(xsltGenericDebugContext
,
581 "Found xslt11:document construct\n");
584 if (xmlStrEqual(inst
->ns
->href
,
585 (const xmlChar
*)"http://exslt.org/common")) {
587 #ifdef WITH_XSLT_DEBUG_EXTRA
588 xsltGenericDebug(xsltGenericDebugContext
,
589 "Found exslt:document extension\n");
591 } else if (xmlStrEqual(inst
->ns
->href
, XSLT_XT_NAMESPACE
)) {
592 /* James Clark's XT. */
593 #ifdef WITH_XSLT_DEBUG_EXTRA
594 xsltGenericDebug(xsltGenericDebugContext
,
595 "Found xt:document extension\n");
601 * The element "document" is used in conjunction with the
602 * following namespaces:
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
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.
613 * All other attributes are identical to the attributes
616 * 2) EXSLT_COMMON_NAMESPACE (http://exslt.org/common)
618 * href = { uri-reference }
619 * TODO: is @href is an AVT?
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?
625 * In all cases @href is in no namespace.
627 filename
= xsltEvalStaticAttrValueTemplate(style
, inst
,
628 (const xmlChar
*)"href", NULL
, &comp
->has_filename
);
630 if (!comp
->has_filename
) {
633 comp
->filename
= filename
;
636 return ((xsltElemPreCompPtr
) comp
);
639 /************************************************************************
641 * Most of the XSLT-1.0 transformations *
643 ************************************************************************/
647 * @style: the XSLT stylesheet
648 * @inst: the xslt sort node
650 * Process the xslt sort node on the source node
653 xsltSortComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
654 #ifdef XSLT_REFACTORED
655 xsltStyleItemSortPtr comp
;
657 xsltStylePreCompPtr comp
;
659 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
662 #ifdef XSLT_REFACTORED
663 comp
= (xsltStyleItemSortPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_SORT
);
665 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_SORT
);
673 comp
->stype
= xsltEvalStaticAttrValueTemplate(style
, inst
,
674 (const xmlChar
*)"data-type",
675 NULL
, &comp
->has_stype
);
676 if (comp
->stype
!= NULL
) {
677 if (xmlStrEqual(comp
->stype
, (const xmlChar
*) "text"))
679 else if (xmlStrEqual(comp
->stype
, (const xmlChar
*) "number"))
682 xsltTransformError(NULL
, style
, inst
,
683 "xsltSortComp: no support for data-type = %s\n", comp
->stype
);
684 comp
->number
= 0; /* use default */
685 if (style
!= NULL
) style
->warnings
++;
688 comp
->order
= xsltEvalStaticAttrValueTemplate(style
, inst
,
689 (const xmlChar
*)"order",
690 NULL
, &comp
->has_order
);
691 if (comp
->order
!= NULL
) {
692 if (xmlStrEqual(comp
->order
, (const xmlChar
*) "ascending"))
693 comp
->descending
= 0;
694 else if (xmlStrEqual(comp
->order
, (const xmlChar
*) "descending"))
695 comp
->descending
= 1;
697 xsltTransformError(NULL
, style
, inst
,
698 "xsltSortComp: invalid value %s for order\n", comp
->order
);
699 comp
->descending
= 0; /* use default */
700 if (style
!= NULL
) style
->warnings
++;
703 comp
->case_order
= xsltEvalStaticAttrValueTemplate(style
, inst
,
704 (const xmlChar
*)"case-order",
705 NULL
, &comp
->has_use
);
706 if (comp
->case_order
!= NULL
) {
707 if (xmlStrEqual(comp
->case_order
, (const xmlChar
*) "upper-first"))
708 comp
->lower_first
= 0;
709 else if (xmlStrEqual(comp
->case_order
, (const xmlChar
*) "lower-first"))
710 comp
->lower_first
= 1;
712 xsltTransformError(NULL
, style
, inst
,
713 "xsltSortComp: invalid value %s for order\n", comp
->order
);
714 comp
->lower_first
= 0; /* use default */
715 if (style
!= NULL
) style
->warnings
++;
719 comp
->lang
= xsltEvalStaticAttrValueTemplate(style
, inst
,
720 (const xmlChar
*)"lang",
721 NULL
, &comp
->has_lang
);
722 if (comp
->lang
!= NULL
) {
723 comp
->locale
= xsltNewLocale(comp
->lang
);
726 comp
->locale
= (xsltLocale
)0;
729 comp
->select
= xsltGetCNsProp(style
, inst
,(const xmlChar
*)"select", XSLT_NAMESPACE
);
730 if (comp
->select
== NULL
) {
732 * The default value of the select attribute is ., which will
733 * cause the string-value of the current node to be used as
736 comp
->select
= xmlDictLookup(style
->dict
, BAD_CAST
".", 1);
738 comp
->comp
= xsltXPathCompile(style
, comp
->select
);
739 if (comp
->comp
== NULL
) {
740 xsltTransformError(NULL
, style
, inst
,
741 "xsltSortComp: could not compile select expression '%s'\n",
743 if (style
!= NULL
) style
->errors
++;
745 if (inst
->children
!= NULL
) {
746 xsltTransformError(NULL
, style
, inst
,
747 "xsl:sort : is not empty\n");
748 if (style
!= NULL
) style
->errors
++;
754 * @style: the XSLT stylesheet
755 * @inst: the xslt copy node
757 * Process the xslt copy node on the source node
760 xsltCopyComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
761 #ifdef XSLT_REFACTORED
762 xsltStyleItemCopyPtr comp
;
764 xsltStylePreCompPtr comp
;
767 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
769 #ifdef XSLT_REFACTORED
770 comp
= (xsltStyleItemCopyPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_COPY
);
772 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_COPY
);
781 comp
->use
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"use-attribute-sets",
783 if (comp
->use
== NULL
)
789 #ifdef XSLT_REFACTORED
790 /* Enable if ever needed for xsl:text. */
794 * @style: an XSLT compiled stylesheet
795 * @inst: the xslt text node
797 * TODO: This function is obsolete, since xsl:text won't
798 * be compiled, but removed from the tree.
800 * Process the xslt text node on the source node
803 xsltTextComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
804 #ifdef XSLT_REFACTORED
805 xsltStyleItemTextPtr comp
;
807 xsltStylePreCompPtr comp
;
811 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
814 #ifdef XSLT_REFACTORED
815 comp
= (xsltStyleItemTextPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_TEXT
);
817 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_TEXT
);
825 prop
= xsltGetCNsProp(style
, inst
,
826 (const xmlChar
*)"disable-output-escaping",
829 if (xmlStrEqual(prop
, (const xmlChar
*)"yes")) {
831 } else if (!xmlStrEqual(prop
,
832 (const xmlChar
*)"no")){
833 xsltTransformError(NULL
, style
, inst
,
834 "xsl:text: disable-output-escaping allows only yes or no\n");
835 if (style
!= NULL
) style
->warnings
++;
839 #endif /* else of XSLT_REFACTORED */
843 * @style: an XSLT compiled stylesheet
844 * @inst: the xslt element node
846 * Process the xslt element node on the source node
849 xsltElementComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
850 #ifdef XSLT_REFACTORED
851 xsltStyleItemElementPtr comp
;
853 xsltStylePreCompPtr comp
;
859 * namespace = { uri-reference }
860 * use-attribute-sets = qnames>
861 * <!-- Content: template -->
864 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
867 #ifdef XSLT_REFACTORED
868 comp
= (xsltStyleItemElementPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_ELEMENT
);
870 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_ELEMENT
);
882 * TODO: Precompile the AVT. See bug #344894.
884 comp
->name
= xsltEvalStaticAttrValueTemplate(style
, inst
,
885 (const xmlChar
*)"name", NULL
, &comp
->has_name
);
886 if (! comp
->has_name
) {
887 xsltTransformError(NULL
, style
, inst
,
888 "xsl:element: The attribute 'name' is missing.\n");
893 * Attribute "namespace".
896 * TODO: Precompile the AVT. See bug #344894.
898 comp
->ns
= xsltEvalStaticAttrValueTemplate(style
, inst
,
899 (const xmlChar
*)"namespace", NULL
, &comp
->has_ns
);
901 if (comp
->name
!= NULL
) {
902 if (xmlValidateQName(comp
->name
, 0)) {
903 xsltTransformError(NULL
, style
, inst
,
904 "xsl:element: The value '%s' of the attribute 'name' is "
905 "not a valid QName.\n", comp
->name
);
908 const xmlChar
*prefix
= NULL
, *name
;
910 name
= xsltSplitQName(style
->dict
, comp
->name
, &prefix
);
911 if (comp
->has_ns
== 0) {
916 * "If the namespace attribute is not present, then the QName is
917 * expanded into an expanded-name using the namespace declarations
918 * in effect for the xsl:element element, including any default
919 * namespace declaration.
921 ns
= xmlSearchNs(inst
->doc
, inst
, prefix
);
923 comp
->ns
= xmlDictLookup(style
->dict
, ns
->href
, -1);
925 #ifdef XSLT_REFACTORED
926 comp
->nsPrefix
= prefix
;
929 } else if (prefix
!= NULL
) {
930 xsltTransformError(NULL
, style
, inst
,
931 "xsl:element: The prefixed QName '%s' "
932 "has no namespace binding in scope in the "
933 "stylesheet; this is an error, since the namespace was "
934 "not specified by the instruction itself.\n", comp
->name
);
938 if ((prefix
!= NULL
) &&
939 (!xmlStrncasecmp(prefix
, (xmlChar
*)"xml", 3)))
942 * Mark is to be skipped.
949 * Attribute "use-attribute-sets",
951 comp
->use
= xsltEvalStaticAttrValueTemplate(style
, inst
,
952 (const xmlChar
*)"use-attribute-sets",
953 NULL
, &comp
->has_use
);
961 * @style: an XSLT compiled stylesheet
962 * @inst: the xslt attribute node
964 * Process the xslt attribute node on the source node
967 xsltAttributeComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
968 #ifdef XSLT_REFACTORED
969 xsltStyleItemAttributePtr comp
;
971 xsltStylePreCompPtr comp
;
977 * namespace = { uri-reference }>
978 * <!-- Content: template -->
981 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
984 #ifdef XSLT_REFACTORED
985 comp
= (xsltStyleItemAttributePtr
) xsltNewStylePreComp(style
,
986 XSLT_FUNC_ATTRIBUTE
);
988 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_ATTRIBUTE
);
1000 * TODO: Precompile the AVT. See bug #344894.
1002 comp
->name
= xsltEvalStaticAttrValueTemplate(style
, inst
,
1003 (const xmlChar
*)"name",
1004 NULL
, &comp
->has_name
);
1005 if (! comp
->has_name
) {
1006 xsltTransformError(NULL
, style
, inst
,
1007 "XSLT-attribute: The attribute 'name' is missing.\n");
1012 * Attribute "namespace".
1015 * TODO: Precompile the AVT. See bug #344894.
1017 comp
->ns
= xsltEvalStaticAttrValueTemplate(style
, inst
,
1018 (const xmlChar
*)"namespace",
1019 NULL
, &comp
->has_ns
);
1021 if (comp
->name
!= NULL
) {
1022 if (xmlValidateQName(comp
->name
, 0)) {
1023 xsltTransformError(NULL
, style
, inst
,
1024 "xsl:attribute: The value '%s' of the attribute 'name' is "
1025 "not a valid QName.\n", comp
->name
);
1027 } else if (xmlStrEqual(comp
->name
, BAD_CAST
"xmlns")) {
1028 xsltTransformError(NULL
, style
, inst
,
1029 "xsl:attribute: The attribute name 'xmlns' is not allowed.\n");
1032 const xmlChar
*prefix
= NULL
, *name
;
1034 name
= xsltSplitQName(style
->dict
, comp
->name
, &prefix
);
1035 if (prefix
!= NULL
) {
1036 if (comp
->has_ns
== 0) {
1041 * "If the namespace attribute is not present, then the
1042 * QName is expanded into an expanded-name using the
1043 * namespace declarations in effect for the xsl:element
1044 * element, including any default namespace declaration.
1046 ns
= xmlSearchNs(inst
->doc
, inst
, prefix
);
1048 comp
->ns
= xmlDictLookup(style
->dict
, ns
->href
, -1);
1050 #ifdef XSLT_REFACTORED
1051 comp
->nsPrefix
= prefix
;
1055 xsltTransformError(NULL
, style
, inst
,
1056 "xsl:attribute: The prefixed QName '%s' "
1057 "has no namespace binding in scope in the "
1058 "stylesheet; this is an error, since the "
1059 "namespace was not specified by the instruction "
1060 "itself.\n", comp
->name
);
1071 * @style: an XSLT compiled stylesheet
1072 * @inst: the xslt comment node
1074 * Process the xslt comment node on the source node
1077 xsltCommentComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1078 #ifdef XSLT_REFACTORED
1079 xsltStyleItemCommentPtr comp
;
1081 xsltStylePreCompPtr comp
;
1084 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1087 #ifdef XSLT_REFACTORED
1088 comp
= (xsltStyleItemCommentPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_COMMENT
);
1090 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_COMMENT
);
1100 * xsltProcessingInstructionComp:
1101 * @style: an XSLT compiled stylesheet
1102 * @inst: the xslt processing-instruction node
1104 * Process the xslt processing-instruction node on the source node
1107 xsltProcessingInstructionComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1108 #ifdef XSLT_REFACTORED
1109 xsltStyleItemPIPtr comp
;
1111 xsltStylePreCompPtr comp
;
1114 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1117 #ifdef XSLT_REFACTORED
1118 comp
= (xsltStyleItemPIPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_PI
);
1120 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_PI
);
1128 comp
->name
= xsltEvalStaticAttrValueTemplate(style
, inst
,
1129 (const xmlChar
*)"name",
1130 XSLT_NAMESPACE
, &comp
->has_name
);
1135 * @style: an XSLT compiled stylesheet
1136 * @inst: the xslt copy-of node
1138 * Process the xslt copy-of node on the source node
1141 xsltCopyOfComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1142 #ifdef XSLT_REFACTORED
1143 xsltStyleItemCopyOfPtr comp
;
1145 xsltStylePreCompPtr comp
;
1148 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1151 #ifdef XSLT_REFACTORED
1152 comp
= (xsltStyleItemCopyOfPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_COPYOF
);
1154 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_COPYOF
);
1162 comp
->select
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"select",
1164 if (comp
->select
== NULL
) {
1165 xsltTransformError(NULL
, style
, inst
,
1166 "xsl:copy-of : select is missing\n");
1167 if (style
!= NULL
) style
->errors
++;
1170 comp
->comp
= xsltXPathCompile(style
, comp
->select
);
1171 if (comp
->comp
== NULL
) {
1172 xsltTransformError(NULL
, style
, inst
,
1173 "xsl:copy-of : could not compile select expression '%s'\n",
1175 if (style
!= NULL
) style
->errors
++;
1181 * @style: an XSLT compiled stylesheet
1182 * @inst: the xslt value-of node
1184 * Process the xslt value-of node on the source node
1187 xsltValueOfComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1188 #ifdef XSLT_REFACTORED
1189 xsltStyleItemValueOfPtr comp
;
1191 xsltStylePreCompPtr comp
;
1193 const xmlChar
*prop
;
1195 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1198 #ifdef XSLT_REFACTORED
1199 comp
= (xsltStyleItemValueOfPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_VALUEOF
);
1201 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_VALUEOF
);
1209 prop
= xsltGetCNsProp(style
, inst
,
1210 (const xmlChar
*)"disable-output-escaping",
1213 if (xmlStrEqual(prop
, (const xmlChar
*)"yes")) {
1215 } else if (!xmlStrEqual(prop
,
1216 (const xmlChar
*)"no")){
1217 xsltTransformError(NULL
, style
, inst
,
1218 "xsl:value-of : disable-output-escaping allows only yes or no\n");
1219 if (style
!= NULL
) style
->warnings
++;
1222 comp
->select
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"select",
1224 if (comp
->select
== NULL
) {
1225 xsltTransformError(NULL
, style
, inst
,
1226 "xsl:value-of : select is missing\n");
1227 if (style
!= NULL
) style
->errors
++;
1230 comp
->comp
= xsltXPathCompile(style
, comp
->select
);
1231 if (comp
->comp
== NULL
) {
1232 xsltTransformError(NULL
, style
, inst
,
1233 "xsl:value-of : could not compile select expression '%s'\n",
1235 if (style
!= NULL
) style
->errors
++;
1240 xsltGetQNameProperty(xsltStylesheetPtr style
, xmlNodePtr inst
,
1241 const xmlChar
*propName
,
1243 int *hasProp
, const xmlChar
**nsName
,
1244 const xmlChar
** localName
)
1246 const xmlChar
*prop
;
1255 prop
= xsltGetCNsProp(style
, inst
, propName
, XSLT_NAMESPACE
);
1258 xsltTransformError(NULL
, style
, inst
,
1259 "The attribute '%s' is missing.\n", propName
);
1266 if (xmlValidateQName(prop
, 0)) {
1267 xsltTransformError(NULL
, style
, inst
,
1268 "The value '%s' of the attribute "
1269 "'%s' is not a valid QName.\n", prop
, propName
);
1274 * @prop will be in the string dict afterwards, @URI not.
1276 URI
= xsltGetQNameURI2(style
, inst
, &prop
);
1285 * Fixes bug #308441: Put the ns-name in the dict
1286 * in order to pointer compare names during XPath's
1290 *nsName
= xmlDictLookup(style
->dict
, URI
, -1);
1291 /* comp->has_ns = 1; */
1300 * xsltWithParamComp:
1301 * @style: an XSLT compiled stylesheet
1302 * @inst: the xslt with-param node
1304 * Process the xslt with-param node on the source node
1305 * Allowed parents: xsl:call-template, xsl:apply-templates.
1308 * select = expression>
1309 * <!-- Content: template -->
1313 xsltWithParamComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1314 #ifdef XSLT_REFACTORED
1315 xsltStyleItemWithParamPtr comp
;
1317 xsltStylePreCompPtr comp
;
1320 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1323 #ifdef XSLT_REFACTORED
1324 comp
= (xsltStyleItemWithParamPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_WITHPARAM
);
1326 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_WITHPARAM
);
1337 xsltGetQNameProperty(style
, inst
, BAD_CAST
"name",
1338 1, &(comp
->has_name
), &(comp
->ns
), &(comp
->name
));
1342 * Attribute "select".
1344 comp
->select
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"select",
1346 if (comp
->select
!= NULL
) {
1347 comp
->comp
= xsltXPathCompile(style
, comp
->select
);
1348 if (comp
->comp
== NULL
) {
1349 xsltTransformError(NULL
, style
, inst
,
1350 "XSLT-with-param: Failed to compile select "
1351 "expression '%s'\n", comp
->select
);
1354 if (inst
->children
!= NULL
) {
1355 xsltTransformError(NULL
, style
, inst
,
1356 "XSLT-with-param: The content should be empty since "
1357 "the attribute select is present.\n");
1365 * @style: an XSLT compiled stylesheet
1366 * @cur: the xslt number node
1368 * Process the xslt number node on the source node
1371 xsltNumberComp(xsltStylesheetPtr style
, xmlNodePtr cur
) {
1372 #ifdef XSLT_REFACTORED
1373 xsltStyleItemNumberPtr comp
;
1375 xsltStylePreCompPtr comp
;
1377 const xmlChar
*prop
;
1379 if ((style
== NULL
) || (cur
== NULL
) || (cur
->type
!= XML_ELEMENT_NODE
))
1382 #ifdef XSLT_REFACTORED
1383 comp
= (xsltStyleItemNumberPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_NUMBER
);
1385 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_NUMBER
);
1392 if ((style
== NULL
) || (cur
== NULL
))
1395 comp
->numdata
.doc
= cur
->doc
;
1396 comp
->numdata
.node
= cur
;
1397 comp
->numdata
.value
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"value",
1400 prop
= xsltEvalStaticAttrValueTemplate(style
, cur
,
1401 (const xmlChar
*)"format",
1402 XSLT_NAMESPACE
, &comp
->numdata
.has_format
);
1403 if (comp
->numdata
.has_format
== 0) {
1404 comp
->numdata
.format
= xmlDictLookup(style
->dict
, BAD_CAST
"" , 0);
1406 comp
->numdata
.format
= prop
;
1409 comp
->numdata
.count
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"count",
1411 comp
->numdata
.from
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"from",
1414 prop
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"count", XSLT_NAMESPACE
);
1416 comp
->numdata
.countPat
= xsltCompilePattern(prop
, cur
->doc
, cur
, style
,
1420 prop
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"from", XSLT_NAMESPACE
);
1422 comp
->numdata
.fromPat
= xsltCompilePattern(prop
, cur
->doc
, cur
, style
,
1426 prop
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"level", XSLT_NAMESPACE
);
1428 if (xmlStrEqual(prop
, BAD_CAST("single")) ||
1429 xmlStrEqual(prop
, BAD_CAST("multiple")) ||
1430 xmlStrEqual(prop
, BAD_CAST("any"))) {
1431 comp
->numdata
.level
= prop
;
1433 xsltTransformError(NULL
, style
, cur
,
1434 "xsl:number : invalid value %s for level\n", prop
);
1435 if (style
!= NULL
) style
->warnings
++;
1439 prop
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"lang", XSLT_NAMESPACE
);
1441 xsltTransformError(NULL
, style
, cur
,
1442 "xsl:number : lang attribute not implemented\n");
1443 XSLT_TODO
; /* xsl:number lang attribute */
1446 prop
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"letter-value", XSLT_NAMESPACE
);
1448 if (xmlStrEqual(prop
, BAD_CAST("alphabetic"))) {
1449 xsltTransformError(NULL
, style
, cur
,
1450 "xsl:number : letter-value 'alphabetic' not implemented\n");
1451 if (style
!= NULL
) style
->warnings
++;
1452 XSLT_TODO
; /* xsl:number letter-value attribute alphabetic */
1453 } else if (xmlStrEqual(prop
, BAD_CAST("traditional"))) {
1454 xsltTransformError(NULL
, style
, cur
,
1455 "xsl:number : letter-value 'traditional' not implemented\n");
1456 if (style
!= NULL
) style
->warnings
++;
1457 XSLT_TODO
; /* xsl:number letter-value attribute traditional */
1459 xsltTransformError(NULL
, style
, cur
,
1460 "xsl:number : invalid value %s for letter-value\n", prop
);
1461 if (style
!= NULL
) style
->warnings
++;
1465 prop
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"grouping-separator",
1468 comp
->numdata
.groupingCharacterLen
= xmlStrlen(prop
);
1469 comp
->numdata
.groupingCharacter
=
1470 xsltGetUTF8Char(prop
, &(comp
->numdata
.groupingCharacterLen
));
1473 prop
= xsltGetCNsProp(style
, cur
, (const xmlChar
*)"grouping-size", XSLT_NAMESPACE
);
1475 sscanf((char *)prop
, "%d", &comp
->numdata
.digitsPerGroup
);
1477 comp
->numdata
.groupingCharacter
= 0;
1480 /* Set default values */
1481 if (comp
->numdata
.value
== NULL
) {
1482 if (comp
->numdata
.level
== NULL
) {
1483 comp
->numdata
.level
= xmlDictLookup(style
->dict
,
1484 BAD_CAST
"single", 6);
1491 * xsltApplyImportsComp:
1492 * @style: an XSLT compiled stylesheet
1493 * @inst: the xslt apply-imports node
1495 * Process the xslt apply-imports node on the source node
1498 xsltApplyImportsComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1499 #ifdef XSLT_REFACTORED
1500 xsltStyleItemApplyImportsPtr comp
;
1502 xsltStylePreCompPtr comp
;
1505 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1508 #ifdef XSLT_REFACTORED
1509 comp
= (xsltStyleItemApplyImportsPtr
) xsltNewStylePreComp(style
, XSLT_FUNC_APPLYIMPORTS
);
1511 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_APPLYIMPORTS
);
1521 * xsltCallTemplateComp:
1522 * @style: an XSLT compiled stylesheet
1523 * @inst: the xslt call-template node
1525 * Process the xslt call-template node on the source node
1528 xsltCallTemplateComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1529 #ifdef XSLT_REFACTORED
1530 xsltStyleItemCallTemplatePtr comp
;
1532 xsltStylePreCompPtr comp
;
1535 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1538 #ifdef XSLT_REFACTORED
1539 comp
= (xsltStyleItemCallTemplatePtr
)
1540 xsltNewStylePreComp(style
, XSLT_FUNC_CALLTEMPLATE
);
1542 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_CALLTEMPLATE
);
1553 xsltGetQNameProperty(style
, inst
, BAD_CAST
"name",
1554 1, &(comp
->has_name
), &(comp
->ns
), &(comp
->name
));
1560 * xsltApplyTemplatesComp:
1561 * @style: an XSLT compiled stylesheet
1562 * @inst: the apply-templates node
1564 * Process the apply-templates node on the source node
1567 xsltApplyTemplatesComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1568 #ifdef XSLT_REFACTORED
1569 xsltStyleItemApplyTemplatesPtr comp
;
1571 xsltStylePreCompPtr comp
;
1574 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1577 #ifdef XSLT_REFACTORED
1578 comp
= (xsltStyleItemApplyTemplatesPtr
)
1579 xsltNewStylePreComp(style
, XSLT_FUNC_APPLYTEMPLATES
);
1581 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_APPLYTEMPLATES
);
1592 xsltGetQNameProperty(style
, inst
, BAD_CAST
"mode",
1593 0, NULL
, &(comp
->modeURI
), &(comp
->mode
));
1595 * Attribute "select".
1597 comp
->select
= xsltGetCNsProp(style
, inst
, BAD_CAST
"select",
1599 if (comp
->select
!= NULL
) {
1600 comp
->comp
= xsltXPathCompile(style
, comp
->select
);
1601 if (comp
->comp
== NULL
) {
1602 xsltTransformError(NULL
, style
, inst
,
1603 "XSLT-apply-templates: could not compile select "
1604 "expression '%s'\n", comp
->select
);
1608 /* TODO: handle (or skip) the xsl:sort and xsl:with-param */
1613 * @style: an XSLT compiled stylesheet
1614 * @inst: the xslt choose node
1616 * Process the xslt choose node on the source node
1619 xsltChooseComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1620 #ifdef XSLT_REFACTORED
1621 xsltStyleItemChoosePtr comp
;
1623 xsltStylePreCompPtr comp
;
1626 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1629 #ifdef XSLT_REFACTORED
1630 comp
= (xsltStyleItemChoosePtr
)
1631 xsltNewStylePreComp(style
, XSLT_FUNC_CHOOSE
);
1633 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_CHOOSE
);
1644 * @style: an XSLT compiled stylesheet
1645 * @inst: the xslt if node
1647 * Process the xslt if node on the source node
1650 xsltIfComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1651 #ifdef XSLT_REFACTORED
1652 xsltStyleItemIfPtr comp
;
1654 xsltStylePreCompPtr comp
;
1657 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1660 #ifdef XSLT_REFACTORED
1661 comp
= (xsltStyleItemIfPtr
)
1662 xsltNewStylePreComp(style
, XSLT_FUNC_IF
);
1664 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_IF
);
1672 comp
->test
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"test", XSLT_NAMESPACE
);
1673 if (comp
->test
== NULL
) {
1674 xsltTransformError(NULL
, style
, inst
,
1675 "xsl:if : test is not defined\n");
1676 if (style
!= NULL
) style
->errors
++;
1679 comp
->comp
= xsltXPathCompile(style
, comp
->test
);
1680 if (comp
->comp
== NULL
) {
1681 xsltTransformError(NULL
, style
, inst
,
1682 "xsl:if : could not compile test expression '%s'\n",
1684 if (style
!= NULL
) style
->errors
++;
1690 * @style: an XSLT compiled stylesheet
1691 * @inst: the xslt if node
1693 * Process the xslt if node on the source node
1696 xsltWhenComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1697 #ifdef XSLT_REFACTORED
1698 xsltStyleItemWhenPtr comp
;
1700 xsltStylePreCompPtr comp
;
1703 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1706 #ifdef XSLT_REFACTORED
1707 comp
= (xsltStyleItemWhenPtr
)
1708 xsltNewStylePreComp(style
, XSLT_FUNC_WHEN
);
1710 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_WHEN
);
1718 comp
->test
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"test", XSLT_NAMESPACE
);
1719 if (comp
->test
== NULL
) {
1720 xsltTransformError(NULL
, style
, inst
,
1721 "xsl:when : test is not defined\n");
1722 if (style
!= NULL
) style
->errors
++;
1725 comp
->comp
= xsltXPathCompile(style
, comp
->test
);
1726 if (comp
->comp
== NULL
) {
1727 xsltTransformError(NULL
, style
, inst
,
1728 "xsl:when : could not compile test expression '%s'\n",
1730 if (style
!= NULL
) style
->errors
++;
1736 * @style: an XSLT compiled stylesheet
1737 * @inst: the xslt for-each node
1739 * Process the xslt for-each node on the source node
1742 xsltForEachComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1743 #ifdef XSLT_REFACTORED
1744 xsltStyleItemForEachPtr comp
;
1746 xsltStylePreCompPtr comp
;
1749 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1752 #ifdef XSLT_REFACTORED
1753 comp
= (xsltStyleItemForEachPtr
)
1754 xsltNewStylePreComp(style
, XSLT_FUNC_FOREACH
);
1756 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_FOREACH
);
1764 comp
->select
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"select",
1766 if (comp
->select
== NULL
) {
1767 xsltTransformError(NULL
, style
, inst
,
1768 "xsl:for-each : select is missing\n");
1769 if (style
!= NULL
) style
->errors
++;
1771 comp
->comp
= xsltXPathCompile(style
, comp
->select
);
1772 if (comp
->comp
== NULL
) {
1773 xsltTransformError(NULL
, style
, inst
,
1774 "xsl:for-each : could not compile select expression '%s'\n",
1776 if (style
!= NULL
) style
->errors
++;
1779 /* TODO: handle and skip the xsl:sort */
1784 * @style: an XSLT compiled stylesheet
1785 * @inst: the xslt variable node
1787 * Process the xslt variable node on the source node
1790 xsltVariableComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1791 #ifdef XSLT_REFACTORED
1792 xsltStyleItemVariablePtr comp
;
1794 xsltStylePreCompPtr comp
;
1797 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1800 #ifdef XSLT_REFACTORED
1801 comp
= (xsltStyleItemVariablePtr
)
1802 xsltNewStylePreComp(style
, XSLT_FUNC_VARIABLE
);
1804 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_VARIABLE
);
1813 * The full template resolution can be done statically
1819 xsltGetQNameProperty(style
, inst
, BAD_CAST
"name",
1820 1, &(comp
->has_name
), &(comp
->ns
), &(comp
->name
));
1824 * Attribute "select".
1826 comp
->select
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"select",
1828 if (comp
->select
!= NULL
) {
1829 #ifndef XSLT_REFACTORED
1832 comp
->comp
= xsltXPathCompile(style
, comp
->select
);
1833 if (comp
->comp
== NULL
) {
1834 xsltTransformError(NULL
, style
, inst
,
1835 "XSLT-variable: Failed to compile the XPath expression '%s'.\n",
1839 #ifdef XSLT_REFACTORED
1840 if (inst
->children
!= NULL
) {
1841 xsltTransformError(NULL
, style
, inst
,
1842 "XSLT-variable: There must be no child nodes, since the "
1843 "attribute 'select' was specified.\n");
1847 for (cur
= inst
->children
; cur
!= NULL
; cur
= cur
->next
) {
1848 if (cur
->type
!= XML_COMMENT_NODE
&&
1849 (cur
->type
!= XML_TEXT_NODE
|| !xsltIsBlank(cur
->content
)))
1851 xsltTransformError(NULL
, style
, inst
,
1852 "XSLT-variable: There must be no child nodes, since the "
1853 "attribute 'select' was specified.\n");
1863 * @style: an XSLT compiled stylesheet
1864 * @inst: the xslt param node
1866 * Process the xslt param node on the source node
1869 xsltParamComp(xsltStylesheetPtr style
, xmlNodePtr inst
) {
1870 #ifdef XSLT_REFACTORED
1871 xsltStyleItemParamPtr comp
;
1873 xsltStylePreCompPtr comp
;
1876 if ((style
== NULL
) || (inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
))
1879 #ifdef XSLT_REFACTORED
1880 comp
= (xsltStyleItemParamPtr
)
1881 xsltNewStylePreComp(style
, XSLT_FUNC_PARAM
);
1883 comp
= xsltNewStylePreComp(style
, XSLT_FUNC_PARAM
);
1894 xsltGetQNameProperty(style
, inst
, BAD_CAST
"name",
1895 1, &(comp
->has_name
), &(comp
->ns
), &(comp
->name
));
1899 * Attribute "select".
1901 comp
->select
= xsltGetCNsProp(style
, inst
, (const xmlChar
*)"select",
1903 if (comp
->select
!= NULL
) {
1904 comp
->comp
= xsltXPathCompile(style
, comp
->select
);
1905 if (comp
->comp
== NULL
) {
1906 xsltTransformError(NULL
, style
, inst
,
1907 "XSLT-param: could not compile select expression '%s'.\n",
1911 if (inst
->children
!= NULL
) {
1912 xsltTransformError(NULL
, style
, inst
,
1913 "XSLT-param: The content should be empty since the "
1914 "attribute 'select' is present.\n");
1920 /************************************************************************
1922 * Generic interface *
1924 ************************************************************************/
1927 * xsltFreeStylePreComps:
1928 * @style: an XSLT transformation context
1930 * Free up the memory allocated by all precomputed blocks
1933 xsltFreeStylePreComps(xsltStylesheetPtr style
) {
1934 xsltElemPreCompPtr cur
, next
;
1939 cur
= style
->preComps
;
1940 while (cur
!= NULL
) {
1942 if (cur
->type
== XSLT_FUNC_EXTENSION
)
1945 xsltFreeStylePreComp((xsltStylePreCompPtr
) cur
);
1950 #ifdef XSLT_REFACTORED
1953 * xsltStylePreCompute:
1954 * @style: the XSLT stylesheet
1955 * @node: the element in the XSLT namespace
1957 * Precompute an XSLT element.
1958 * This expects the type of the element to be already
1959 * set in style->compCtxt->inode->type;
1962 xsltStylePreCompute(xsltStylesheetPtr style
, xmlNodePtr node
) {
1964 * The xsltXSLTElemMarker marker was set beforehand by
1965 * the parsing mechanism for all elements in the XSLT namespace.
1967 if (style
== NULL
) {
1968 if ((node
!= NULL
) && (node
->type
== XML_ELEMENT_NODE
))
1974 if (! IS_XSLT_ELEM_FAST(node
))
1978 if (XSLT_CCTXT(style
)->inode
->type
!= 0) {
1979 switch (XSLT_CCTXT(style
)->inode
->type
) {
1980 case XSLT_FUNC_APPLYTEMPLATES
:
1981 xsltApplyTemplatesComp(style
, node
);
1983 case XSLT_FUNC_WITHPARAM
:
1984 xsltWithParamComp(style
, node
);
1986 case XSLT_FUNC_VALUEOF
:
1987 xsltValueOfComp(style
, node
);
1989 case XSLT_FUNC_COPY
:
1990 xsltCopyComp(style
, node
);
1992 case XSLT_FUNC_COPYOF
:
1993 xsltCopyOfComp(style
, node
);
1996 xsltIfComp(style
, node
);
1998 case XSLT_FUNC_CHOOSE
:
1999 xsltChooseComp(style
, node
);
2001 case XSLT_FUNC_WHEN
:
2002 xsltWhenComp(style
, node
);
2004 case XSLT_FUNC_OTHERWISE
:
2007 case XSLT_FUNC_FOREACH
:
2008 xsltForEachComp(style
, node
);
2010 case XSLT_FUNC_APPLYIMPORTS
:
2011 xsltApplyImportsComp(style
, node
);
2013 case XSLT_FUNC_ATTRIBUTE
:
2014 xsltAttributeComp(style
, node
);
2016 case XSLT_FUNC_ELEMENT
:
2017 xsltElementComp(style
, node
);
2019 case XSLT_FUNC_SORT
:
2020 xsltSortComp(style
, node
);
2022 case XSLT_FUNC_COMMENT
:
2023 xsltCommentComp(style
, node
);
2025 case XSLT_FUNC_NUMBER
:
2026 xsltNumberComp(style
, node
);
2029 xsltProcessingInstructionComp(style
, node
);
2031 case XSLT_FUNC_CALLTEMPLATE
:
2032 xsltCallTemplateComp(style
, node
);
2034 case XSLT_FUNC_PARAM
:
2035 xsltParamComp(style
, node
);
2037 case XSLT_FUNC_VARIABLE
:
2038 xsltVariableComp(style
, node
);
2040 case XSLT_FUNC_FALLBACK
:
2043 case XSLT_FUNC_DOCUMENT
:
2045 node
->psvi
= (void *) xsltDocumentComp(style
, node
,
2046 (xsltTransformFunction
) xsltDocumentElem
);
2048 case XSLT_FUNC_MESSAGE
:
2053 * NOTE that xsl:text, xsl:template, xsl:stylesheet,
2054 * xsl:transform, xsl:import, xsl:include are not expected
2055 * to be handed over to this function.
2057 xsltTransformError(NULL
, style
, node
,
2058 "Internal error: (xsltStylePreCompute) cannot handle "
2059 "the XSLT element '%s'.\n", node
->name
);
2065 * Fallback to string comparison.
2067 if (IS_XSLT_NAME(node
, "apply-templates")) {
2068 xsltApplyTemplatesComp(style
, node
);
2069 } else if (IS_XSLT_NAME(node
, "with-param")) {
2070 xsltWithParamComp(style
, node
);
2071 } else if (IS_XSLT_NAME(node
, "value-of")) {
2072 xsltValueOfComp(style
, node
);
2073 } else if (IS_XSLT_NAME(node
, "copy")) {
2074 xsltCopyComp(style
, node
);
2075 } else if (IS_XSLT_NAME(node
, "copy-of")) {
2076 xsltCopyOfComp(style
, node
);
2077 } else if (IS_XSLT_NAME(node
, "if")) {
2078 xsltIfComp(style
, node
);
2079 } else if (IS_XSLT_NAME(node
, "choose")) {
2080 xsltChooseComp(style
, node
);
2081 } else if (IS_XSLT_NAME(node
, "when")) {
2082 xsltWhenComp(style
, node
);
2083 } else if (IS_XSLT_NAME(node
, "otherwise")) {
2086 } else if (IS_XSLT_NAME(node
, "for-each")) {
2087 xsltForEachComp(style
, node
);
2088 } else if (IS_XSLT_NAME(node
, "apply-imports")) {
2089 xsltApplyImportsComp(style
, node
);
2090 } else if (IS_XSLT_NAME(node
, "attribute")) {
2091 xsltAttributeComp(style
, node
);
2092 } else if (IS_XSLT_NAME(node
, "element")) {
2093 xsltElementComp(style
, node
);
2094 } else if (IS_XSLT_NAME(node
, "sort")) {
2095 xsltSortComp(style
, node
);
2096 } else if (IS_XSLT_NAME(node
, "comment")) {
2097 xsltCommentComp(style
, node
);
2098 } else if (IS_XSLT_NAME(node
, "number")) {
2099 xsltNumberComp(style
, node
);
2100 } else if (IS_XSLT_NAME(node
, "processing-instruction")) {
2101 xsltProcessingInstructionComp(style
, node
);
2102 } else if (IS_XSLT_NAME(node
, "call-template")) {
2103 xsltCallTemplateComp(style
, node
);
2104 } else if (IS_XSLT_NAME(node
, "param")) {
2105 xsltParamComp(style
, node
);
2106 } else if (IS_XSLT_NAME(node
, "variable")) {
2107 xsltVariableComp(style
, node
);
2108 } else if (IS_XSLT_NAME(node
, "fallback")) {
2111 } else if (IS_XSLT_NAME(node
, "document")) {
2113 node
->psvi
= (void *) xsltDocumentComp(style
, node
,
2114 (xsltTransformFunction
) xsltDocumentElem
);
2115 } else if (IS_XSLT_NAME(node
, "output")) {
2118 } else if (IS_XSLT_NAME(node
, "preserve-space")) {
2121 } else if (IS_XSLT_NAME(node
, "strip-space")) {
2124 } else if (IS_XSLT_NAME(node
, "key")) {
2127 } else if (IS_XSLT_NAME(node
, "message")) {
2129 } else if (IS_XSLT_NAME(node
, "attribute-set")) {
2132 } else if (IS_XSLT_NAME(node
, "namespace-alias")) {
2135 } else if (IS_XSLT_NAME(node
, "decimal-format")) {
2138 } else if (IS_XSLT_NAME(node
, "include")) {
2142 * NOTE that xsl:text, xsl:template, xsl:stylesheet,
2143 * xsl:transform, xsl:import, xsl:include are not expected
2144 * to be handed over to this function.
2146 xsltTransformError(NULL
, style
, node
,
2147 "Internal error: (xsltStylePreCompute) cannot handle "
2148 "the XSLT element '%s'.\n", node
->name
);
2154 * Assign the current list of in-scope namespaces to the
2155 * item. This is needed for XPath expressions.
2157 if (node
->psvi
!= NULL
) {
2158 ((xsltStylePreCompPtr
) node
->psvi
)->inScopeNs
=
2159 XSLT_CCTXT(style
)->inode
->inScopeNs
;
2166 * xsltStylePreCompute:
2167 * @style: the XSLT stylesheet
2168 * @inst: the instruction in the stylesheet
2170 * Precompute an XSLT stylesheet element
2173 xsltStylePreCompute(xsltStylesheetPtr style
, xmlNodePtr inst
) {
2175 * URGENT TODO: Normally inst->psvi Should never be reserved here,
2176 * BUT: since if we include the same stylesheet from
2177 * multiple imports, then the stylesheet will be parsed
2178 * again. We simply must not try to compute the stylesheet again.
2179 * TODO: Get to the point where we don't need to query the
2180 * namespace- and local-name of the node, but can evaluate this
2181 * using cctxt->style->inode->category;
2183 if ((inst
== NULL
) || (inst
->type
!= XML_ELEMENT_NODE
) ||
2184 (inst
->psvi
!= NULL
))
2187 if (IS_XSLT_ELEM(inst
)) {
2188 xsltStylePreCompPtr cur
;
2190 if (IS_XSLT_NAME(inst
, "apply-templates")) {
2191 xsltCheckInstructionElement(style
, inst
);
2192 xsltApplyTemplatesComp(style
, inst
);
2193 } else if (IS_XSLT_NAME(inst
, "with-param")) {
2194 xsltCheckParentElement(style
, inst
, BAD_CAST
"apply-templates",
2195 BAD_CAST
"call-template");
2196 xsltWithParamComp(style
, inst
);
2197 } else if (IS_XSLT_NAME(inst
, "value-of")) {
2198 xsltCheckInstructionElement(style
, inst
);
2199 xsltValueOfComp(style
, inst
);
2200 } else if (IS_XSLT_NAME(inst
, "copy")) {
2201 xsltCheckInstructionElement(style
, inst
);
2202 xsltCopyComp(style
, inst
);
2203 } else if (IS_XSLT_NAME(inst
, "copy-of")) {
2204 xsltCheckInstructionElement(style
, inst
);
2205 xsltCopyOfComp(style
, inst
);
2206 } else if (IS_XSLT_NAME(inst
, "if")) {
2207 xsltCheckInstructionElement(style
, inst
);
2208 xsltIfComp(style
, inst
);
2209 } else if (IS_XSLT_NAME(inst
, "when")) {
2210 xsltCheckParentElement(style
, inst
, BAD_CAST
"choose", NULL
);
2211 xsltWhenComp(style
, inst
);
2212 } else if (IS_XSLT_NAME(inst
, "choose")) {
2213 xsltCheckInstructionElement(style
, inst
);
2214 xsltChooseComp(style
, inst
);
2215 } else if (IS_XSLT_NAME(inst
, "for-each")) {
2216 xsltCheckInstructionElement(style
, inst
);
2217 xsltForEachComp(style
, inst
);
2218 } else if (IS_XSLT_NAME(inst
, "apply-imports")) {
2219 xsltCheckInstructionElement(style
, inst
);
2220 xsltApplyImportsComp(style
, inst
);
2221 } else if (IS_XSLT_NAME(inst
, "attribute")) {
2222 xmlNodePtr parent
= inst
->parent
;
2224 if ((parent
== NULL
) || (parent
->ns
== NULL
) ||
2225 ((parent
->ns
!= inst
->ns
) &&
2226 (!xmlStrEqual(parent
->ns
->href
, inst
->ns
->href
))) ||
2227 (!xmlStrEqual(parent
->name
, BAD_CAST
"attribute-set"))) {
2228 xsltCheckInstructionElement(style
, inst
);
2230 xsltAttributeComp(style
, inst
);
2231 } else if (IS_XSLT_NAME(inst
, "element")) {
2232 xsltCheckInstructionElement(style
, inst
);
2233 xsltElementComp(style
, inst
);
2234 } else if (IS_XSLT_NAME(inst
, "text")) {
2235 xsltCheckInstructionElement(style
, inst
);
2236 xsltTextComp(style
, inst
);
2237 } else if (IS_XSLT_NAME(inst
, "sort")) {
2238 xsltCheckParentElement(style
, inst
, BAD_CAST
"apply-templates",
2239 BAD_CAST
"for-each");
2240 xsltSortComp(style
, inst
);
2241 } else if (IS_XSLT_NAME(inst
, "comment")) {
2242 xsltCheckInstructionElement(style
, inst
);
2243 xsltCommentComp(style
, inst
);
2244 } else if (IS_XSLT_NAME(inst
, "number")) {
2245 xsltCheckInstructionElement(style
, inst
);
2246 xsltNumberComp(style
, inst
);
2247 } else if (IS_XSLT_NAME(inst
, "processing-instruction")) {
2248 xsltCheckInstructionElement(style
, inst
);
2249 xsltProcessingInstructionComp(style
, inst
);
2250 } else if (IS_XSLT_NAME(inst
, "call-template")) {
2251 xsltCheckInstructionElement(style
, inst
);
2252 xsltCallTemplateComp(style
, inst
);
2253 } else if (IS_XSLT_NAME(inst
, "param")) {
2254 if (xsltCheckTopLevelElement(style
, inst
, 0) == 0)
2255 xsltCheckInstructionElement(style
, inst
);
2256 xsltParamComp(style
, inst
);
2257 } else if (IS_XSLT_NAME(inst
, "variable")) {
2258 if (xsltCheckTopLevelElement(style
, inst
, 0) == 0)
2259 xsltCheckInstructionElement(style
, inst
);
2260 xsltVariableComp(style
, inst
);
2261 } else if (IS_XSLT_NAME(inst
, "otherwise")) {
2262 xsltCheckParentElement(style
, inst
, BAD_CAST
"choose", NULL
);
2263 xsltCheckInstructionElement(style
, inst
);
2265 } else if (IS_XSLT_NAME(inst
, "template")) {
2266 xsltCheckTopLevelElement(style
, inst
, 1);
2268 } else if (IS_XSLT_NAME(inst
, "output")) {
2269 xsltCheckTopLevelElement(style
, inst
, 1);
2271 } else if (IS_XSLT_NAME(inst
, "preserve-space")) {
2272 xsltCheckTopLevelElement(style
, inst
, 1);
2274 } else if (IS_XSLT_NAME(inst
, "strip-space")) {
2275 xsltCheckTopLevelElement(style
, inst
, 1);
2277 } else if ((IS_XSLT_NAME(inst
, "stylesheet")) ||
2278 (IS_XSLT_NAME(inst
, "transform"))) {
2279 xmlNodePtr parent
= inst
->parent
;
2281 if ((parent
== NULL
) || (parent
->type
!= XML_DOCUMENT_NODE
)) {
2282 xsltTransformError(NULL
, style
, inst
,
2283 "element %s only allowed only as root element\n",
2288 } else if (IS_XSLT_NAME(inst
, "key")) {
2289 xsltCheckTopLevelElement(style
, inst
, 1);
2291 } else if (IS_XSLT_NAME(inst
, "message")) {
2292 xsltCheckInstructionElement(style
, inst
);
2294 } else if (IS_XSLT_NAME(inst
, "attribute-set")) {
2295 xsltCheckTopLevelElement(style
, inst
, 1);
2297 } else if (IS_XSLT_NAME(inst
, "namespace-alias")) {
2298 xsltCheckTopLevelElement(style
, inst
, 1);
2300 } else if (IS_XSLT_NAME(inst
, "include")) {
2301 xsltCheckTopLevelElement(style
, inst
, 1);
2303 } else if (IS_XSLT_NAME(inst
, "import")) {
2304 xsltCheckTopLevelElement(style
, inst
, 1);
2306 } else if (IS_XSLT_NAME(inst
, "decimal-format")) {
2307 xsltCheckTopLevelElement(style
, inst
, 1);
2309 } else if (IS_XSLT_NAME(inst
, "fallback")) {
2310 xsltCheckInstructionElement(style
, inst
);
2312 } else if (IS_XSLT_NAME(inst
, "document")) {
2313 xsltCheckInstructionElement(style
, inst
);
2314 inst
->psvi
= (void *) xsltDocumentComp(style
, inst
,
2315 (xsltTransformFunction
) xsltDocumentElem
);
2317 xsltTransformError(NULL
, style
, inst
,
2318 "xsltStylePreCompute: unknown xsl:%s\n", inst
->name
);
2319 if (style
!= NULL
) style
->warnings
++;
2322 cur
= (xsltStylePreCompPtr
) inst
->psvi
;
2324 * A ns-list is build for every XSLT item in the
2325 * node-tree. This is needed for XPath expressions.
2330 cur
->nsList
= xmlGetNsList(inst
->doc
, inst
);
2331 if (cur
->nsList
!= NULL
) {
2332 while (cur
->nsList
[i
] != NULL
)
2339 (void *) xsltPreComputeExtModuleElement(style
, inst
);
2342 * Unknown element, maybe registered at the context
2343 * level. Mark it for later recognition.
2345 if (inst
->psvi
== NULL
)
2346 inst
->psvi
= (void *) xsltExtMarker
;
2349 #endif /* XSLT_REFACTORED */