ReactOS 0.4.16-dev-2207-geb15453
templates.h File Reference
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include "xsltexports.h"
#include "xsltInternals.h"
Include dependency graph for templates.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

XSLTPUBFUN int XSLTCALL xsltEvalXPathPredicate (xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp, xmlNsPtr *nsList, int nsNr)
 
XSLTPUBFUN xmlChar *XSLTCALL xsltEvalTemplateString (xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst)
 
XSLTPUBFUN xmlChar *XSLTCALL xsltEvalAttrValueTemplate (xsltTransformContextPtr ctxt, xmlNodePtr node, const xmlChar *name, const xmlChar *ns)
 
XSLTPUBFUN const xmlChar *XSLTCALL xsltEvalStaticAttrValueTemplate (xsltStylesheetPtr style, xmlNodePtr node, const xmlChar *name, const xmlChar *ns, int *found)
 
XSLTPUBFUN xmlChar *XSLTCALL xsltEvalXPathString (xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp)
 
XSLTPUBFUN xmlChar *XSLTCALL xsltEvalXPathStringNs (xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp, int nsNr, xmlNsPtr *nsList)
 
XSLTPUBFUN xmlNodePtr *XSLTCALL xsltTemplateProcess (xsltTransformContextPtr ctxt, xmlNodePtr node)
 
XSLTPUBFUN xmlAttrPtr XSLTCALL xsltAttrListTemplateProcess (xsltTransformContextPtr ctxt, xmlNodePtr target, xmlAttrPtr cur)
 
XSLTPUBFUN xmlAttrPtr XSLTCALL xsltAttrTemplateProcess (xsltTransformContextPtr ctxt, xmlNodePtr target, xmlAttrPtr attr)
 
XSLTPUBFUN xmlChar *XSLTCALL xsltAttrTemplateValueProcess (xsltTransformContextPtr ctxt, const xmlChar *attr)
 
XSLTPUBFUN xmlChar *XSLTCALL xsltAttrTemplateValueProcessNode (xsltTransformContextPtr ctxt, const xmlChar *str, xmlNodePtr node)
 

Function Documentation

◆ xsltAttrListTemplateProcess()

XSLTPUBFUN xmlAttrPtr XSLTCALL xsltAttrListTemplateProcess ( xsltTransformContextPtr  ctxt,
xmlNodePtr  target,
xmlAttrPtr  attrs 
)

xsltAttrListTemplateProcess: @ctxt: the XSLT transformation context @target: the element where the attributes will be grafted @attrs: the first attribute

Processes all attributes of a Literal Result Element. Attribute references are applied via xsl:use-attribute-set attributes. Copies all non XSLT-attributes over to the @target element and evaluates Attribute Value Templates.

Called by xsltApplySequenceConstructor() (transform.c).

Returns a new list of attribute nodes, or NULL in case of error. (Don't assign the result to @target->properties; if the result is NULL, you'll get memory leaks, since the attributes will be disattached.)

Definition at line 653 of file templates.c.

655{
656 xmlAttrPtr attr, copy, last = NULL;
657 xmlNodePtr oldInsert, text;
658 xmlNsPtr origNs = NULL, copyNs = NULL;
659 const xmlChar *value;
660 xmlChar *valueAVT;
661 int hasAttr = 0;
662
663 if ((ctxt == NULL) || (target == NULL) || (attrs == NULL) ||
664 (target->type != XML_ELEMENT_NODE))
665 return(NULL);
666
667 oldInsert = ctxt->insert;
668 ctxt->insert = target;
669
670 /*
671 * Apply attribute-sets.
672 */
673 attr = attrs;
674 do {
675#ifdef XSLT_REFACTORED
676 if ((attr->psvi == xsltXSLTAttrMarker) &&
677 xmlStrEqual(attr->name, (const xmlChar *)"use-attribute-sets"))
678 {
679 xsltApplyAttributeSet(ctxt, ctxt->node, (xmlNodePtr) attr, NULL);
680 }
681#else
682 if ((attr->ns != NULL) &&
683 xmlStrEqual(attr->name, (const xmlChar *)"use-attribute-sets") &&
684 xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
685 {
686 xsltApplyAttributeSet(ctxt, ctxt->node, (xmlNodePtr) attr, NULL);
687 }
688#endif
689 attr = attr->next;
690 } while (attr != NULL);
691
692 if (target->properties != NULL) {
693 hasAttr = 1;
694 }
695
696 /*
697 * Instantiate LRE-attributes.
698 */
699 attr = attrs;
700 do {
701 /*
702 * Skip XSLT attributes.
703 */
704#ifdef XSLT_REFACTORED
705 if (attr->psvi == xsltXSLTAttrMarker) {
706 goto next_attribute;
707 }
708#else
709 if ((attr->ns != NULL) &&
710 xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
711 {
712 goto next_attribute;
713 }
714#endif
715 /*
716 * Get the value.
717 */
718 if (attr->children != NULL) {
719 if ((attr->children->type != XML_TEXT_NODE) ||
720 (attr->children->next != NULL))
721 {
722 xsltTransformError(ctxt, NULL, attr->parent,
723 "Internal error: The children of an attribute node of a "
724 "literal result element are not in the expected form.\n");
725 goto error;
726 }
727 value = attr->children->content;
728 if (value == NULL)
729 value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
730 } else
731 value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
732
733 /*
734 * Get the namespace. Avoid lookups of same namespaces.
735 */
736 if (attr->ns != origNs) {
737 origNs = attr->ns;
738 if (attr->ns != NULL) {
739#ifdef XSLT_REFACTORED
740 copyNs = xsltGetSpecialNamespace(ctxt, attr->parent,
741 attr->ns->href, attr->ns->prefix, target);
742#else
743 copyNs = xsltGetNamespace(ctxt, attr->parent,
744 attr->ns, target);
745#endif
746 if (copyNs == NULL)
747 goto error;
748 } else
749 copyNs = NULL;
750 }
751 /*
752 * Create a new attribute.
753 */
754 if (hasAttr) {
755 copy = xmlSetNsProp(target, copyNs, attr->name, NULL);
756 } else {
757 /*
758 * Avoid checking for duplicate attributes if there aren't
759 * any attribute sets.
760 */
761 copy = xmlNewDocProp(target->doc, attr->name, NULL);
762
763 if (copy != NULL) {
764 copy->ns = copyNs;
765
766 /*
767 * Attach it to the target element.
768 */
769 copy->parent = target;
770 if (last == NULL) {
771 target->properties = copy;
772 last = copy;
773 } else {
774 last->next = copy;
775 copy->prev = last;
776 last = copy;
777 }
778 }
779 }
780 if (copy == NULL) {
781 if (attr->ns) {
782 xsltTransformError(ctxt, NULL, attr->parent,
783 "Internal error: Failed to create attribute '{%s}%s'.\n",
784 attr->ns->href, attr->name);
785 } else {
786 xsltTransformError(ctxt, NULL, attr->parent,
787 "Internal error: Failed to create attribute '%s'.\n",
788 attr->name);
789 }
790 goto error;
791 }
792
793 /*
794 * Set the value.
795 */
796 text = xmlNewText(NULL);
797 if (text != NULL) {
798 copy->last = copy->children = text;
799 text->parent = (xmlNodePtr) copy;
800 text->doc = copy->doc;
801
802 if (attr->psvi != NULL) {
803 /*
804 * Evaluate the Attribute Value Template.
805 */
806 valueAVT = xsltEvalAVT(ctxt, attr->psvi, attr->parent);
807 if (valueAVT == NULL) {
808 /*
809 * TODO: Damn, we need an easy mechanism to report
810 * qualified names!
811 */
812 if (attr->ns) {
813 xsltTransformError(ctxt, NULL, attr->parent,
814 "Internal error: Failed to evaluate the AVT "
815 "of attribute '{%s}%s'.\n",
816 attr->ns->href, attr->name);
817 } else {
818 xsltTransformError(ctxt, NULL, attr->parent,
819 "Internal error: Failed to evaluate the AVT "
820 "of attribute '%s'.\n",
821 attr->name);
822 }
823 text->content = xmlStrdup(BAD_CAST "");
824 goto error;
825 } else {
826 text->content = valueAVT;
827 }
828 } else if ((ctxt->internalized) &&
829 (target->doc != NULL) &&
830 (target->doc->dict == ctxt->dict) &&
831 xmlDictOwns(ctxt->dict, value))
832 {
833 text->content = (xmlChar *) value;
834 } else {
835 text->content = xmlStrdup(value);
836 }
837 if ((copy != NULL) && (text != NULL) &&
838 (xmlIsID(copy->doc, copy->parent, copy)))
839 xmlAddID(NULL, copy->doc, text->content, copy);
840 }
841
843 attr = attr->next;
844 } while (attr != NULL);
845
846 ctxt->insert = oldInsert;
847 return(target->properties);
848
849error:
850 ctxt->insert = oldInsert;
851 return(NULL);
852}
xmlChar * xsltEvalAVT(xsltTransformContextPtr ctxt, void *avt, xmlNodePtr node)
Definition: attrvt.c:377
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define NULL
Definition: types.h:112
void xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, const xmlChar *attrSets)
Definition: attributes.c:1118
const WCHAR * text
Definition: package.c:1794
#define error(str)
Definition: mkdosfs.c:1605
static UINT UINT last
Definition: font.c:45
#define next_attribute(a)
Definition: reader.c:252
xmlNsPtr xsltGetSpecialNamespace(xsltTransformContextPtr ctxt, xmlNodePtr invocNode, const xmlChar *nsName, const xmlChar *nsPrefix, xmlNodePtr target)
Definition: namespaces.c:319
xmlNsPtr xsltGetNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur, xmlNsPtr ns, xmlNodePtr out)
Definition: namespaces.c:616
int xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:376
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
Definition: cookie.c:202
WCHAR * name
Definition: cookie.c:203
Definition: tools.h:99
Definition: pdh_main.c:96
XMLPUBFUN xmlIDPtr xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr)
Definition: valid.c:2517
XMLPUBFUN int xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
Definition: valid.c:2619
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69
#define XSLT_NAMESPACE
Definition: xslt.h:46
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762

Referenced by xsltApplySequenceConstructor().

◆ xsltAttrTemplateProcess()

XSLTPUBFUN xmlAttrPtr XSLTCALL xsltAttrTemplateProcess ( xsltTransformContextPtr  ctxt,
xmlNodePtr  target,
xmlAttrPtr  attr 
)

xsltAttrTemplateProcess: @ctxt: the XSLT transformation context @target: the element where the attribute will be grafted @attr: the attribute node of a literal result element

Process one attribute of a Literal Result Element (in the stylesheet). Evaluates Attribute Value Templates and copies the attribute over to the result element. This does not process attribute sets (xsl:use-attribute-set).

Returns the generated attribute node.

Definition at line 497 of file templates.c.

499{
500 const xmlChar *value;
501 xmlAttrPtr ret;
502
503 if ((ctxt == NULL) || (attr == NULL) || (target == NULL) ||
504 (target->type != XML_ELEMENT_NODE))
505 return(NULL);
506
507 if (attr->type != XML_ATTRIBUTE_NODE)
508 return(NULL);
509
510 /*
511 * Skip all XSLT attributes.
512 */
513#ifdef XSLT_REFACTORED
514 if (attr->psvi == xsltXSLTAttrMarker)
515 return(NULL);
516#else
517 if ((attr->ns != NULL) && xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
518 return(NULL);
519#endif
520 /*
521 * Get the value.
522 */
523 if (attr->children != NULL) {
524 if ((attr->children->type != XML_TEXT_NODE) ||
525 (attr->children->next != NULL))
526 {
527 xsltTransformError(ctxt, NULL, attr->parent,
528 "Internal error: The children of an attribute node of a "
529 "literal result element are not in the expected form.\n");
530 return(NULL);
531 }
532 value = attr->children->content;
533 if (value == NULL)
534 value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
535 } else
536 value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
537 /*
538 * Overwrite duplicates.
539 */
540 ret = target->properties;
541 while (ret != NULL) {
542 if (((attr->ns != NULL) == (ret->ns != NULL)) &&
543 xmlStrEqual(ret->name, attr->name) &&
544 ((attr->ns == NULL) || xmlStrEqual(ret->ns->href, attr->ns->href)))
545 {
546 break;
547 }
548 ret = ret->next;
549 }
550 if (ret != NULL) {
551 /* free the existing value */
552 xmlFreeNodeList(ret->children);
553 ret->children = ret->last = NULL;
554 /*
555 * Adjust ns-prefix if needed.
556 */
557 if ((ret->ns != NULL) &&
558 (! xmlStrEqual(ret->ns->prefix, attr->ns->prefix)))
559 {
560 ret->ns = xsltGetNamespace(ctxt, attr->parent, attr->ns, target);
561 }
562 } else {
563 /* create a new attribute */
564 if (attr->ns != NULL)
565 ret = xmlNewNsProp(target,
566 xsltGetNamespace(ctxt, attr->parent, attr->ns, target),
567 attr->name, NULL);
568 else
569 ret = xmlNewNsProp(target, NULL, attr->name, NULL);
570 }
571 /*
572 * Set the value.
573 */
574 if (ret != NULL) {
575 xmlNodePtr text;
576
577 text = xmlNewText(NULL);
578 if (text != NULL) {
579 ret->last = ret->children = text;
580 text->parent = (xmlNodePtr) ret;
581 text->doc = ret->doc;
582
583 if (attr->psvi != NULL) {
584 /*
585 * Evaluate the Attribute Value Template.
586 */
587 xmlChar *val;
588 val = xsltEvalAVT(ctxt, attr->psvi, attr->parent);
589 if (val == NULL) {
590 /*
591 * TODO: Damn, we need an easy mechanism to report
592 * qualified names!
593 */
594 if (attr->ns) {
595 xsltTransformError(ctxt, NULL, attr->parent,
596 "Internal error: Failed to evaluate the AVT "
597 "of attribute '{%s}%s'.\n",
598 attr->ns->href, attr->name);
599 } else {
600 xsltTransformError(ctxt, NULL, attr->parent,
601 "Internal error: Failed to evaluate the AVT "
602 "of attribute '%s'.\n",
603 attr->name);
604 }
605 text->content = xmlStrdup(BAD_CAST "");
606 } else {
607 text->content = val;
608 }
609 } else if ((ctxt->internalized) && (target != NULL) &&
610 (target->doc != NULL) &&
611 (target->doc->dict == ctxt->dict) &&
612 xmlDictOwns(ctxt->dict, value)) {
613 text->content = (xmlChar *) value;
614 } else {
615 text->content = xmlStrdup(value);
616 }
617 }
618 } else {
619 if (attr->ns) {
620 xsltTransformError(ctxt, NULL, attr->parent,
621 "Internal error: Failed to create attribute '{%s}%s'.\n",
622 attr->ns->href, attr->name);
623 } else {
624 xsltTransformError(ctxt, NULL, attr->parent,
625 "Internal error: Failed to create attribute '%s'.\n",
626 attr->name);
627 }
628 }
629 return(ret);
630}
return ret
Definition: mutex.c:146
GLuint GLfloat * val
Definition: glext.h:7180

◆ xsltAttrTemplateValueProcess()

XSLTPUBFUN xmlChar *XSLTCALL xsltAttrTemplateValueProcess ( xsltTransformContextPtr  ctxt,
const xmlChar str 
)

xsltAttrTemplateValueProcess: @ctxt: the XSLT transformation context @str: the attribute template node value

Process the given node and return the new string value.

Returns the computed string value or NULL, must be deallocated by the caller.

Definition at line 390 of file templates.c.

390 {
392}
const WCHAR * str
xmlChar * xsltAttrTemplateValueProcessNode(xsltTransformContextPtr ctxt, const xmlChar *str, xmlNodePtr inst)
Definition: templates.c:278

◆ xsltAttrTemplateValueProcessNode()

XSLTPUBFUN xmlChar *XSLTCALL xsltAttrTemplateValueProcessNode ( xsltTransformContextPtr  ctxt,
const xmlChar str,
xmlNodePtr  inst 
)

xsltAttrTemplateValueProcessNode: @ctxt: the XSLT transformation context @str: the attribute template node value @inst: the instruction (or LRE) in the stylesheet holding the attribute with an AVT

Process the given string, allowing to pass a namespace mapping context and return the new string value.

Called by:

QUESTION: Why is this function public? It is not used outside of templates.c.

Returns the computed string value or NULL, must be deallocated by the caller.

Definition at line 278 of file templates.c.

280{
281 xmlChar *ret = NULL;
282 const xmlChar *cur;
283 xmlChar *expr, *val;
284 xmlNsPtr *nsList = NULL;
285 int nsNr = 0;
286
287 if (str == NULL) return(NULL);
288 if (*str == 0)
289 return(xmlStrndup((xmlChar *)"", 0));
290
291 cur = str;
292 while (*cur != 0) {
293 if (*cur == '{') {
294 if (*(cur+1) == '{') { /* escaped '{' */
295 cur++;
296 ret = xmlStrncat(ret, str, cur - str);
297 cur++;
298 str = cur;
299 continue;
300 }
301 ret = xmlStrncat(ret, str, cur - str);
302 str = cur;
303 cur++;
304 while ((*cur != 0) && (*cur != '}')) {
305 /* Need to check for literal (bug539741) */
306 if ((*cur == '\'') || (*cur == '"')) {
307 char delim = *(cur++);
308 while ((*cur != 0) && (*cur != delim))
309 cur++;
310 if (*cur != 0)
311 cur++; /* skip the ending delimiter */
312 } else
313 cur++;
314 }
315 if (*cur == 0) {
316 xsltTransformError(ctxt, NULL, inst,
317 "xsltAttrTemplateValueProcessNode: unmatched '{'\n");
318 ret = xmlStrncat(ret, str, cur - str);
319 goto exit;
320 }
321 str++;
322 expr = xmlStrndup(str, cur - str);
323 if (expr == NULL)
324 goto exit;
325 else if (*expr == '{') {
326 ret = xmlStrcat(ret, expr);
327 xmlFree(expr);
328 } else {
329 xmlXPathCompExprPtr comp;
330 /*
331 * TODO: keep precompiled form around
332 */
333 if ((nsList == NULL) && (inst != NULL)) {
334 int i = 0;
335
336 nsList = xmlGetNsList(inst->doc, inst);
337 if (nsList != NULL) {
338 while (nsList[i] != NULL)
339 i++;
340 nsNr = i;
341 }
342 }
343 comp = xmlXPathCtxtCompile(ctxt->xpathCtxt, expr);
344 val = xsltEvalXPathStringNs(ctxt, comp, nsNr, nsList);
345 xmlXPathFreeCompExpr(comp);
346 xmlFree(expr);
347 if (val != NULL) {
348 ret = xmlStrcat(ret, val);
349 xmlFree(val);
350 }
351 }
352 cur++;
353 str = cur;
354 } else if (*cur == '}') {
355 cur++;
356 if (*cur == '}') { /* escaped '}' */
357 ret = xmlStrncat(ret, str, cur - str);
358 cur++;
359 str = cur;
360 continue;
361 } else {
362 xsltTransformError(ctxt, NULL, inst,
363 "xsltAttrTemplateValueProcessNode: unmatched '}'\n");
364 }
365 } else
366 cur++;
367 }
368 if (cur != str) {
369 ret = xmlStrncat(ret, str, cur - str);
370 }
371
372exit:
373 if (nsList != NULL)
374 xmlFree(nsList);
375
376 return(ret);
377}
FxCollectionEntry * cur
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define exit(n)
Definition: config.h:202
xmlFreeFunc xmlFree
Definition: globals.c:184
xmlXPathContextPtr xpathCtxt
Definition: query.h:86
xmlChar * xsltEvalXPathStringNs(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp, int nsNr, xmlNsPtr *nsList)
Definition: templates.c:123
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:45
XMLPUBFUN xmlChar * xmlStrncat(xmlChar *cur, const xmlChar *add, int len)
Definition: xmlstring.c:448
XMLPUBFUN xmlChar * xmlStrcat(xmlChar *cur, const xmlChar *add)
Definition: xmlstring.c:524

Referenced by xsltAttrTemplateValueProcess(), and xsltEvalAttrValueTemplate().

◆ xsltEvalAttrValueTemplate()

XSLTPUBFUN xmlChar *XSLTCALL xsltEvalAttrValueTemplate ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
const xmlChar name,
const xmlChar ns 
)

Definition at line 410 of file templates.c.

412{
413 xmlChar *ret;
414 xmlChar *expr;
415
416 if ((ctxt == NULL) || (inst == NULL) || (name == NULL) ||
417 (inst->type != XML_ELEMENT_NODE))
418 return(NULL);
419
420 expr = xsltGetNsProp(inst, name, ns);
421 if (expr == NULL)
422 return(NULL);
423
424 /*
425 * TODO: though now {} is detected ahead, it would still be good to
426 * optimize both functions to keep the splitted value if the
427 * attribute content and the XPath precompiled expressions around
428 */
429
431#ifdef WITH_XSLT_DEBUG_TEMPLATES
433 "xsltEvalAttrValueTemplate: %s returns %s\n", expr, ret));
434#endif
435 if (expr != NULL)
436 xmlFree(expr);
437 return(ret);
438}
Definition: name.c:39
Definition: mxnamespace.c:38
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633
xmlChar * xsltGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace)
Definition: xsltutils.c:166
@ XSLT_TRACE_TEMPLATES
Definition: xsltutils.h:122
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:132

Referenced by xsltAttribute(), xsltDefaultSortFunction(), xsltDocumentElem(), xsltElement(), xsltNumberFormat(), and xsltProcessingInstruction().

◆ xsltEvalStaticAttrValueTemplate()

XSLTPUBFUN const xmlChar *XSLTCALL xsltEvalStaticAttrValueTemplate ( xsltStylesheetPtr  style,
xmlNodePtr  node,
const xmlChar name,
const xmlChar ns,
int found 
)

Definition at line 456 of file templates.c.

457 {
458 const xmlChar *ret;
459 xmlChar *expr;
460
461 if ((style == NULL) || (inst == NULL) || (name == NULL) ||
462 (inst->type != XML_ELEMENT_NODE))
463 return(NULL);
464
465 expr = xsltGetNsProp(inst, name, ns);
466 if (expr == NULL) {
467 *found = 0;
468 return(NULL);
469 }
470 *found = 1;
471
472 ret = xmlStrchr(expr, '{');
473 if (ret != NULL) {
474 xmlFree(expr);
475 return(NULL);
476 }
477 ret = xmlDictLookup(style->dict, expr, -1);
478 xmlFree(expr);
479 return(ret);
480}
Arabic default style
Definition: afstyles.h:94
XMLPUBFUN const xmlChar * xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:327

Referenced by xsltAttributeComp(), xsltDocumentComp(), xsltElementComp(), xsltNumberComp(), xsltProcessingInstructionComp(), and xsltSortComp().

◆ xsltEvalTemplateString()

XSLTPUBFUN xmlChar *XSLTCALL xsltEvalTemplateString ( xsltTransformContextPtr  ctxt,
xmlNodePtr  contextNode,
xmlNodePtr  inst 
)

xsltEvalTemplateString: @ctxt: the XSLT transformation context @contextNode: the current node in the source tree @inst: the XSLT instruction (xsl:comment, xsl:processing-instruction)

Processes the sequence constructor of the given instruction on @contextNode and converts the resulting tree to a string. This is needed by e.g. xsl:comment and xsl:processing-instruction.

Returns the computed string value or NULL; it's up to the caller to free the result.

Definition at line 207 of file templates.c.

210{
211 xmlNodePtr oldInsert, insert = NULL;
212 xmlChar *ret;
213 const xmlChar *oldLastText;
214 int oldLastTextSize, oldLastTextUse;
215
216 if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL) ||
217 (inst->type != XML_ELEMENT_NODE))
218 return(NULL);
219
220 if (inst->children == NULL)
221 return(NULL);
222
223 /*
224 * This creates a temporary element-node to add the resulting
225 * text content to.
226 * OPTIMIZE TODO: Keep such an element-node in the transformation
227 * context to avoid creating it every time.
228 */
229 insert = xmlNewDocNode(ctxt->output, NULL,
230 (const xmlChar *)"fake", NULL);
231 if (insert == NULL) {
232 xsltTransformError(ctxt, NULL, inst,
233 "Failed to create temporary node\n");
234 return(NULL);
235 }
236 oldInsert = ctxt->insert;
237 ctxt->insert = insert;
238 oldLastText = ctxt->lasttext;
239 oldLastTextSize = ctxt->lasttsize;
240 oldLastTextUse = ctxt->lasttuse;
241 /*
242 * OPTIMIZE TODO: if inst->children consists only of text-nodes.
243 */
244 xsltApplyOneTemplate(ctxt, contextNode, inst->children, NULL, NULL);
245
246 ctxt->insert = oldInsert;
247 ctxt->lasttext = oldLastText;
248 ctxt->lasttsize = oldLastTextSize;
249 ctxt->lasttuse = oldLastTextUse;
250
251 ret = xmlNodeGetContent(insert);
252 if (insert != NULL)
253 xmlFreeNode(insert);
254 return(ret);
255}
void xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ ATTRIBUTE_UNUSED, xsltStackElemPtr params)
Definition: transform.c:3313
const xmlChar * lasttext

Referenced by xsltAttribute(), xsltComment(), xsltMessage(), and xsltProcessingInstruction().

◆ xsltEvalXPathPredicate()

XSLTPUBFUN int XSLTCALL xsltEvalXPathPredicate ( xsltTransformContextPtr  ctxt,
xmlXPathCompExprPtr  comp,
xmlNsPtr *  nsList,
int  nsNr 
)

xsltEvalXPathPredicate: @ctxt: the XSLT transformation context @comp: the XPath compiled expression @nsList: the namespaces in scope @nsNr: the number of namespaces in scope

Process the expression using XPath and evaluate the result as an XPath predicate

Returns 1 is the predicate was true, 0 otherwise

Definition at line 57 of file templates.c.

58 {
59 int ret;
60 xmlXPathObjectPtr res;
61 int oldNsNr;
62 xmlNsPtr *oldNamespaces;
63 xmlNodePtr oldInst;
64 int oldProximityPosition, oldContextSize;
65
66 if ((ctxt == NULL) || (ctxt->inst == NULL)) {
68 "xsltEvalXPathPredicate: No context or instruction\n");
69 return(0);
70 }
71
72 oldContextSize = ctxt->xpathCtxt->contextSize;
73 oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
74 oldNsNr = ctxt->xpathCtxt->nsNr;
75 oldNamespaces = ctxt->xpathCtxt->namespaces;
76 oldInst = ctxt->inst;
77
78 ctxt->xpathCtxt->node = ctxt->node;
79 ctxt->xpathCtxt->namespaces = nsList;
80 ctxt->xpathCtxt->nsNr = nsNr;
81
82 res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
83
84 if (res != NULL) {
85 ret = xmlXPathEvalPredicate(ctxt->xpathCtxt, res);
86 xmlXPathFreeObject(res);
87#ifdef WITH_XSLT_DEBUG_TEMPLATES
89 "xsltEvalXPathPredicate: returns %d\n", ret));
90#endif
91 } else {
92#ifdef WITH_XSLT_DEBUG_TEMPLATES
94 "xsltEvalXPathPredicate: failed\n"));
95#endif
97 ret = 0;
98 }
99 ctxt->xpathCtxt->nsNr = oldNsNr;
100
101 ctxt->xpathCtxt->namespaces = oldNamespaces;
102 ctxt->inst = oldInst;
103 ctxt->xpathCtxt->contextSize = oldContextSize;
104 ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
105
106 return(ret);
107}
GLuint res
Definition: glext.h:9613
xsltTransformState state
@ XSLT_STATE_STOPPED

Referenced by xsltTestPredicateMatch().

◆ xsltEvalXPathString()

XSLTPUBFUN xmlChar *XSLTCALL xsltEvalXPathString ( xsltTransformContextPtr  ctxt,
xmlXPathCompExprPtr  comp 
)

xsltEvalXPathString: @ctxt: the XSLT transformation context @comp: the compiled XPath expression

Process the expression using XPath and get a string

Returns the computed string value or NULL, must be deallocated by the caller.

Definition at line 189 of file templates.c.

189 {
190 return(xsltEvalXPathStringNs(ctxt, comp, 0, NULL));
191}

Referenced by xsltDocumentElem().

◆ xsltEvalXPathStringNs()

XSLTPUBFUN xmlChar *XSLTCALL xsltEvalXPathStringNs ( xsltTransformContextPtr  ctxt,
xmlXPathCompExprPtr  comp,
int  nsNr,
xmlNsPtr *  nsList 
)

xsltEvalXPathStringNs: @ctxt: the XSLT transformation context @comp: the compiled XPath expression @nsNr: the number of namespaces in the list @nsList: the list of in-scope namespaces to use

Process the expression using XPath, allowing to pass a namespace mapping context and get a string

Returns the computed string value or NULL, must be deallocated by the caller.

Definition at line 123 of file templates.c.

124 {
125 xmlChar *ret = NULL;
126 xmlXPathObjectPtr res;
127 xmlNodePtr oldInst;
128 xmlNodePtr oldNode;
129 int oldPos, oldSize;
130 int oldNsNr;
131 xmlNsPtr *oldNamespaces;
132
133 if ((ctxt == NULL) || (ctxt->inst == NULL)) {
135 "xsltEvalXPathStringNs: No context or instruction\n");
136 return(0);
137 }
138
139 oldInst = ctxt->inst;
140 oldNode = ctxt->node;
141 oldPos = ctxt->xpathCtxt->proximityPosition;
142 oldSize = ctxt->xpathCtxt->contextSize;
143 oldNsNr = ctxt->xpathCtxt->nsNr;
144 oldNamespaces = ctxt->xpathCtxt->namespaces;
145
146 ctxt->xpathCtxt->node = ctxt->node;
147 /* TODO: do we need to propagate the namespaces here ? */
148 ctxt->xpathCtxt->namespaces = nsList;
149 ctxt->xpathCtxt->nsNr = nsNr;
150 res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
151 if (res != NULL) {
152 if (res->type != XPATH_STRING)
153 res = xmlXPathConvertString(res);
154 if ((res != NULL) && (res->type == XPATH_STRING)) {
155 ret = res->stringval;
156 res->stringval = NULL;
157 } else {
159 "xpath : string() function didn't return a String\n");
160 }
161 xmlXPathFreeObject(res);
162 } else {
164 }
165#ifdef WITH_XSLT_DEBUG_TEMPLATES
167 "xsltEvalXPathString: returns %s\n", ret));
168#endif
169 ctxt->inst = oldInst;
170 ctxt->node = oldNode;
171 ctxt->xpathCtxt->contextSize = oldSize;
172 ctxt->xpathCtxt->proximityPosition = oldPos;
173 ctxt->xpathCtxt->nsNr = oldNsNr;
174 ctxt->xpathCtxt->namespaces = oldNamespaces;
175 return(ret);
176}

Referenced by xsltAttrTemplateValueProcessNode(), xsltEvalAVT(), and xsltEvalXPathString().

◆ xsltTemplateProcess()

XSLTPUBFUN xmlNodePtr *XSLTCALL xsltTemplateProcess ( xsltTransformContextPtr ctxt  ATTRIBUTE_UNUSED,
xmlNodePtr  node 
)

xsltTemplateProcess: @ctxt: the XSLT transformation context @node: the attribute template node

Obsolete. Don't use it.

Returns NULL.

Definition at line 865 of file templates.c.

865 {
866 if (node == NULL)
867 return(NULL);
868
869 return(0);
870}
Definition: dlist.c:348