ReactOS 0.4.16-dev-2208-g6350669
xsltInternals.h File Reference
#include <libxml/tree.h>
#include <libxml/hash.h>
#include <libxml/xpath.h>
#include <libxml/xmlerror.h>
#include <libxml/dict.h>
#include <libxml/xmlstring.h>
#include <libxslt/xslt.h>
#include "xsltexports.h"
#include "numbersInternals.h"
Include dependency graph for xsltInternals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _xsltRuntimeExtra
 
struct  _xsltTemplate
 
struct  _xsltDecimalFormat
 
struct  _xsltDocument
 
struct  _xsltKeyDef
 
struct  _xsltKeyTable
 
struct  _xsltElemPreComp
 
struct  _xsltStylePreComp
 
struct  _xsltStackElem
 
struct  _xsltStylesheet
 
struct  _xsltTransformCache
 
struct  _xsltTransformContext
 

Macros

#define XSLT_IS_TEXT_NODE(n)
 
#define XSLT_MARK_RES_TREE_FRAG(n)    (n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");
 
#define XSLT_IS_RES_TREE_FRAG(n)
 
#define XSLT_REFACTORED_KEYCOMP
 
#define XSLT_FAST_IF
 
#define XSLT_REFACTORED_VARS
 
#define XSLT_MAX_SORT   15
 
#define XSLT_PAT_NO_PRIORITY   -12345789
 
#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr)   (ctxt)->extras[(nr)].info
 
#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr)   (ctxt)->extras[(nr)].deallocate
 
#define XSLT_RUNTIME_EXTRA(ctxt, nr, typ)   (ctxt)->extras[(nr)].val.typ
 
#define CHECK_STOPPED   if (ctxt->state == XSLT_STATE_STOPPED) return;
 
#define CHECK_STOPPEDE   if (ctxt->state == XSLT_STATE_STOPPED) goto error;
 
#define CHECK_STOPPED0   if (ctxt->state == XSLT_STATE_STOPPED) return(0);
 
#define XML_CAST_FPTR(fptr)   fptr
 

Typedefs

typedef struct _xsltRuntimeExtra xsltRuntimeExtra
 
typedef xsltRuntimeExtraxsltRuntimeExtraPtr
 
typedef struct _xsltTemplate xsltTemplate
 
typedef xsltTemplatexsltTemplatePtr
 
typedef struct _xsltDecimalFormat xsltDecimalFormat
 
typedef xsltDecimalFormatxsltDecimalFormatPtr
 
typedef struct _xsltDocument xsltDocument
 
typedef xsltDocumentxsltDocumentPtr
 
typedef struct _xsltKeyDef xsltKeyDef
 
typedef xsltKeyDefxsltKeyDefPtr
 
typedef struct _xsltKeyTable xsltKeyTable
 
typedef xsltKeyTablexsltKeyTablePtr
 
typedef struct _xsltStylesheet xsltStylesheet
 
typedef xsltStylesheetxsltStylesheetPtr
 
typedef struct _xsltTransformContext xsltTransformContext
 
typedef xsltTransformContextxsltTransformContextPtr
 
typedef struct _xsltElemPreComp xsltElemPreComp
 
typedef xsltElemPreCompxsltElemPreCompPtr
 
typedef void(* xsltTransformFunction) (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)
 
typedef void(* xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
 
typedef void(* xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp)
 
typedef struct _xsltStylePreComp xsltStylePreComp
 
typedef xsltStylePreCompxsltStylePreCompPtr
 
typedef struct _xsltStackElem xsltStackElem
 
typedef xsltStackElemxsltStackElemPtr
 
typedef struct _xsltTransformCache xsltTransformCache
 
typedef xsltTransformCachexsltTransformCachePtr
 
typedef void *(* xsltNewLocaleFunc) (const xmlChar *lang, int lowerFirst)
 
typedef void(* xsltFreeLocaleFunc) (void *locale)
 
typedef xmlChar *(* xsltGenSortKeyFunc) (void *locale, const xmlChar *lang)
 

Enumerations

enum  xsltStyleType {
  XSLT_FUNC_COPY =1 , XSLT_FUNC_SORT , XSLT_FUNC_TEXT , XSLT_FUNC_ELEMENT ,
  XSLT_FUNC_ATTRIBUTE , XSLT_FUNC_COMMENT , XSLT_FUNC_PI , XSLT_FUNC_COPYOF ,
  XSLT_FUNC_VALUEOF , XSLT_FUNC_NUMBER , XSLT_FUNC_APPLYIMPORTS , XSLT_FUNC_CALLTEMPLATE ,
  XSLT_FUNC_APPLYTEMPLATES , XSLT_FUNC_CHOOSE , XSLT_FUNC_IF , XSLT_FUNC_FOREACH ,
  XSLT_FUNC_DOCUMENT , XSLT_FUNC_WITHPARAM , XSLT_FUNC_PARAM , XSLT_FUNC_VARIABLE ,
  XSLT_FUNC_WHEN , XSLT_FUNC_EXTENSION
}
 
enum  xsltOutputType { XSLT_OUTPUT_XML = 0 , XSLT_OUTPUT_HTML , XSLT_OUTPUT_TEXT }
 
enum  xsltTransformState { XSLT_STATE_OK = 0 , XSLT_STATE_ERROR , XSLT_STATE_STOPPED }
 

Functions

XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltNewStylesheet (void)
 
XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetFile (const xmlChar *filename)
 
XSLTPUBFUN void XSLTCALL xsltFreeStylesheet (xsltStylesheetPtr style)
 
XSLTPUBFUN int XSLTCALL xsltIsBlank (xmlChar *str)
 
XSLTPUBFUN void XSLTCALL xsltFreeStackElemList (xsltStackElemPtr elem)
 
XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL xsltDecimalFormatGetByName (xsltStylesheetPtr style, xmlChar *name)
 
XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL xsltDecimalFormatGetByQName (xsltStylesheetPtr style, const xmlChar *nsUri, const xmlChar *name)
 
XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetProcess (xsltStylesheetPtr ret, xmlDocPtr doc)
 
XSLTPUBFUN void XSLTCALL xsltParseStylesheetOutput (xsltStylesheetPtr style, xmlNodePtr cur)
 
XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetDoc (xmlDocPtr doc)
 
XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetImportedDoc (xmlDocPtr doc, xsltStylesheetPtr style)
 
XSLTPUBFUN int XSLTCALL xsltParseStylesheetUser (xsltStylesheetPtr style, xmlDocPtr doc)
 
XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltLoadStylesheetPI (xmlDocPtr doc)
 
XSLTPUBFUN void XSLTCALL xsltNumberFormat (xsltTransformContextPtr ctxt, xsltNumberDataPtr data, xmlNodePtr node)
 
XSLTPUBFUN xmlXPathError XSLTCALL xsltFormatNumberConversion (xsltDecimalFormatPtr self, xmlChar *format, double number, xmlChar **result)
 
XSLTPUBFUN void XSLTCALL xsltParseTemplateContent (xsltStylesheetPtr style, xmlNodePtr templ)
 
XSLTPUBFUN int XSLTCALL xsltAllocateExtra (xsltStylesheetPtr style)
 
XSLTPUBFUN int XSLTCALL xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt)
 
XSLTPUBFUN xmlDocPtr XSLTCALL xsltCreateRVT (xsltTransformContextPtr ctxt)
 
XSLTPUBFUN int XSLTCALL xsltRegisterTmpRVT (xsltTransformContextPtr ctxt, xmlDocPtr RVT)
 
XSLTPUBFUN int XSLTCALL xsltRegisterLocalRVT (xsltTransformContextPtr ctxt, xmlDocPtr RVT)
 
XSLTPUBFUN int XSLTCALL xsltRegisterPersistRVT (xsltTransformContextPtr ctxt, xmlDocPtr RVT)
 
XSLTPUBFUN int XSLTCALL xsltExtensionInstructionResultRegister (xsltTransformContextPtr ctxt, xmlXPathObjectPtr obj)
 
XSLTPUBFUN int XSLTCALL xsltExtensionInstructionResultFinalize (xsltTransformContextPtr ctxt)
 
XSLTPUBFUN int XSLTCALL xsltFlagRVTs (xsltTransformContextPtr ctxt, xmlXPathObjectPtr obj, int val)
 
XSLTPUBFUN void XSLTCALL xsltFreeRVTs (xsltTransformContextPtr ctxt)
 
XSLTPUBFUN void XSLTCALL xsltReleaseRVT (xsltTransformContextPtr ctxt, xmlDocPtr RVT)
 
XSLTPUBFUN void XSLTCALL xsltCompileAttr (xsltStylesheetPtr style, xmlAttrPtr attr)
 
XSLTPUBFUN xmlChar *XSLTCALL xsltEvalAVT (xsltTransformContextPtr ctxt, void *avt, xmlNodePtr node)
 
XSLTPUBFUN void XSLTCALL xsltFreeAVTList (void *avt)
 
XSLTPUBFUN void XSLTCALL xsltUninit (void)
 
XSLTPUBFUN int XSLTCALL xsltInitCtxtKey (xsltTransformContextPtr ctxt, xsltDocumentPtr doc, xsltKeyDefPtr keyd)
 
XSLTPUBFUN int XSLTCALL xsltInitAllDocKeys (xsltTransformContextPtr ctxt)
 

Macro Definition Documentation

◆ CHECK_STOPPED

#define CHECK_STOPPED   if (ctxt->state == XSLT_STATE_STOPPED) return;

CHECK_STOPPED:

Macro to check if the XSLT processing should be stopped. Will return from the function.

Definition at line 1810 of file xsltInternals.h.

◆ CHECK_STOPPED0

#define CHECK_STOPPED0   if (ctxt->state == XSLT_STATE_STOPPED) return(0);

CHECK_STOPPED0:

Macro to check if the XSLT processing should be stopped. Will return from the function with a 0 value.

Definition at line 1826 of file xsltInternals.h.

◆ CHECK_STOPPEDE

#define CHECK_STOPPEDE   if (ctxt->state == XSLT_STATE_STOPPED) goto error;

CHECK_STOPPEDE:

Macro to check if the XSLT processing should be stopped. Will goto the error: label.

Definition at line 1818 of file xsltInternals.h.

◆ XML_CAST_FPTR

#define XML_CAST_FPTR (   fptr)    fptr

XML_CAST_FPTR: @fptr: pointer to a function

Macro to do a casting from an object pointer to a function pointer without encountering a warning from gcc

define XML_CAST_FPTR(fptr) (*(void **)(&fptr)) This macro violated ISO C aliasing rules (gcc4 on s390 broke) so it is disabled now

Definition at line 1848 of file xsltInternals.h.

◆ XSLT_FAST_IF

#define XSLT_FAST_IF

XSLT_FAST_IF:

Internal define to enable usage of xmlXPathCompiledEvalToBoolean() for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">

Definition at line 73 of file xsltInternals.h.

◆ XSLT_IS_RES_TREE_FRAG

#define XSLT_IS_RES_TREE_FRAG (   n)
Value:
((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \
((n)->name != NULL) && ((n)->name[0] == ' '))
#define NULL
Definition: types.h:112
GLdouble n
Definition: glext.h:7729

XSLT_IS_RES_TREE_FRAG:

internal macro to test tree fragments

Definition at line 55 of file xsltInternals.h.

◆ XSLT_IS_TEXT_NODE

#define XSLT_IS_TEXT_NODE (   n)
Value:
((n != NULL) && \
(((n)->type == XML_TEXT_NODE) || \
((n)->type == XML_CDATA_SECTION_NODE)))
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

XSLT_IS_TEXT_NODE:

check if the argument is a text node

Definition at line 37 of file xsltInternals.h.

◆ XSLT_MARK_RES_TREE_FRAG

#define XSLT_MARK_RES_TREE_FRAG (   n)     (n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");

XSLT_MARK_RES_TREE_FRAG:

internal macro to set up tree fragments

Definition at line 47 of file xsltInternals.h.

◆ XSLT_MAX_SORT

#define XSLT_MAX_SORT   15

XSLT_REFACTORED_PARSING:

Internal define to enable the refactored parts of Libxslt related to parsing. XSLT_MAX_SORT:

Max number of specified xsl:sort on an element.

Definition at line 208 of file xsltInternals.h.

◆ XSLT_PAT_NO_PRIORITY

#define XSLT_PAT_NO_PRIORITY   -12345789

XSLT_PAT_NO_PRIORITY:

Specific value for pattern without priority expressed.

Definition at line 215 of file xsltInternals.h.

◆ XSLT_REFACTORED_KEYCOMP

#define XSLT_REFACTORED_KEYCOMP

XSLT_REFACTORED_KEYCOMP:

Internal define to enable on-demand xsl:key computation. That's the only mode now but the define is kept for compatibility

Definition at line 65 of file xsltInternals.h.

◆ XSLT_REFACTORED_VARS

#define XSLT_REFACTORED_VARS

XSLT_REFACTORED:

Internal define to enable the refactored parts of Libxslt. XSLT_REFACTORED_VARS:

Internal define to enable the refactored variable part of libxslt

Definition at line 88 of file xsltInternals.h.

◆ XSLT_RUNTIME_EXTRA

#define XSLT_RUNTIME_EXTRA (   ctxt,
  nr,
  typ 
)    (ctxt)->extras[(nr)].val.typ

XSLT_RUNTIME_EXTRA: @ctxt: the transformation context @nr: the index

Macro used to define extra information stored in the context

Definition at line 256 of file xsltInternals.h.

◆ XSLT_RUNTIME_EXTRA_FREE

#define XSLT_RUNTIME_EXTRA_FREE (   ctxt,
  nr 
)    (ctxt)->extras[(nr)].deallocate

XSLT_RUNTIME_EXTRA_FREE: @ctxt: the transformation context @nr: the index

Macro used to free extra information stored in the context

Definition at line 248 of file xsltInternals.h.

◆ XSLT_RUNTIME_EXTRA_LST

#define XSLT_RUNTIME_EXTRA_LST (   ctxt,
  nr 
)    (ctxt)->extras[(nr)].info

XSLT_RUNTIME_EXTRA_LST: @ctxt: the transformation context @nr: the index

Macro used to access extra information stored in the context

Definition at line 240 of file xsltInternals.h.

Typedef Documentation

◆ xsltDecimalFormat

xsltDecimalFormat:

Data structure of decimal-format.

Definition at line 303 of file xsltInternals.h.

◆ xsltDecimalFormatPtr

Definition at line 304 of file xsltInternals.h.

◆ xsltDocument

xsltDocument:

Data structure associated to a parsed document.

Definition at line 329 of file xsltInternals.h.

◆ xsltDocumentPtr

Definition at line 330 of file xsltInternals.h.

◆ xsltElemPreComp

xsltElemPreComp:

The in-memory structure corresponding to element precomputed data, designed to be extended by extension implementors.

Definition at line 393 of file xsltInternals.h.

◆ xsltElemPreCompDeallocator

typedef void(* xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp)

xsltElemPreCompDeallocator: @comp: the xsltElemPreComp to free up

Deallocates an xsltElemPreComp structure.

Definition at line 463 of file xsltInternals.h.

◆ xsltElemPreCompPtr

Definition at line 394 of file xsltInternals.h.

◆ xsltFreeLocaleFunc

typedef void(* xsltFreeLocaleFunc) (void *locale)

Definition at line 1668 of file xsltInternals.h.

◆ xsltGenSortKeyFunc

typedef xmlChar *(* xsltGenSortKeyFunc) (void *locale, const xmlChar *lang)

Definition at line 1670 of file xsltInternals.h.

◆ xsltKeyDef

xsltKeyDef:

Representation of an xsl:key.

Definition at line 346 of file xsltInternals.h.

◆ xsltKeyDefPtr

Definition at line 347 of file xsltInternals.h.

◆ xsltKeyTable

xsltKeyTable:

Holds the computed keys for key definitions of the same QName. Is owned by an xsltDocument.

Definition at line 367 of file xsltInternals.h.

◆ xsltKeyTablePtr

Definition at line 368 of file xsltInternals.h.

◆ xsltNewLocaleFunc

typedef void *(* xsltNewLocaleFunc) (const xmlChar *lang, int lowerFirst)

Definition at line 1666 of file xsltInternals.h.

◆ xsltRuntimeExtra

xsltRuntimeExtra:

Extra information added to the transformation context.

Definition at line 222 of file xsltInternals.h.

◆ xsltRuntimeExtraPtr

Definition at line 223 of file xsltInternals.h.

◆ xsltSortFunc

typedef void(* xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)

xsltSortFunc: @ctxt: a transformation context @sorts: the node-set to sort @nbsorts: the number of sorts

Signature of the function to use during sorting

Definition at line 419 of file xsltInternals.h.

◆ xsltStackElem

Definition at line 1418 of file xsltInternals.h.

◆ xsltStackElemPtr

Definition at line 1419 of file xsltInternals.h.

◆ xsltStylePreComp

xsltStylePreComp:

The abstract basic structure for items of the XSLT processor. This includes: 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.) 2) compiled forms of literal result elements 3) compiled forms of extension elements

Definition at line 494 of file xsltInternals.h.

◆ xsltStylePreCompPtr

Definition at line 495 of file xsltInternals.h.

◆ xsltStylesheet

Definition at line 381 of file xsltInternals.h.

◆ xsltStylesheetPtr

Definition at line 382 of file xsltInternals.h.

◆ xsltTemplate

xsltTemplate:

The in-memory structure corresponding to an XSLT Template.

Definition at line 263 of file xsltInternals.h.

◆ xsltTemplatePtr

Definition at line 264 of file xsltInternals.h.

◆ xsltTransformCache

Definition at line 1642 of file xsltInternals.h.

◆ xsltTransformCachePtr

Definition at line 1643 of file xsltInternals.h.

◆ xsltTransformContext

◆ xsltTransformContextPtr

Definition at line 385 of file xsltInternals.h.

◆ xsltTransformFunction

typedef void(* xsltTransformFunction) (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)

xsltTransformFunction: @ctxt: the XSLT transformation context @node: the input node @inst: the stylesheet node @comp: the compiled information from the stylesheet

Signature of the function associated to elements part of the stylesheet language like xsl:if or xsl:apply-templates.

Definition at line 406 of file xsltInternals.h.

Enumeration Type Documentation

◆ xsltOutputType

Enumerator
XSLT_OUTPUT_XML 
XSLT_OUTPUT_HTML 
XSLT_OUTPUT_TEXT 

Definition at line 1660 of file xsltInternals.h.

1660 {
1661 XSLT_OUTPUT_XML = 0,
xsltOutputType
@ XSLT_OUTPUT_XML
@ XSLT_OUTPUT_HTML
@ XSLT_OUTPUT_TEXT

◆ xsltStyleType

Enumerator
XSLT_FUNC_COPY 
XSLT_FUNC_SORT 
XSLT_FUNC_TEXT 
XSLT_FUNC_ELEMENT 
XSLT_FUNC_ATTRIBUTE 
XSLT_FUNC_COMMENT 
XSLT_FUNC_PI 
XSLT_FUNC_COPYOF 
XSLT_FUNC_VALUEOF 
XSLT_FUNC_NUMBER 
XSLT_FUNC_APPLYIMPORTS 
XSLT_FUNC_CALLTEMPLATE 
XSLT_FUNC_APPLYTEMPLATES 
XSLT_FUNC_CHOOSE 
XSLT_FUNC_IF 
XSLT_FUNC_FOREACH 
XSLT_FUNC_DOCUMENT 
XSLT_FUNC_WITHPARAM 
XSLT_FUNC_PARAM 
XSLT_FUNC_VARIABLE 
XSLT_FUNC_WHEN 
XSLT_FUNC_EXTENSION 

Definition at line 422 of file xsltInternals.h.

422 {
445#ifdef XSLT_REFACTORED
446 ,
447 XSLT_FUNC_OTHERWISE,
448 XSLT_FUNC_FALLBACK,
449 XSLT_FUNC_MESSAGE,
450 XSLT_FUNC_INCLUDE,
451 XSLT_FUNC_ATTRSET,
452 XSLT_FUNC_LITERAL_RESULT_ELEMENT,
453 XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
454#endif
xsltStyleType
@ XSLT_FUNC_WHEN
@ XSLT_FUNC_CALLTEMPLATE
@ XSLT_FUNC_ELEMENT
@ XSLT_FUNC_APPLYIMPORTS
@ XSLT_FUNC_DOCUMENT
@ XSLT_FUNC_CHOOSE
@ XSLT_FUNC_VARIABLE
@ XSLT_FUNC_WITHPARAM
@ XSLT_FUNC_APPLYTEMPLATES
@ XSLT_FUNC_TEXT
@ XSLT_FUNC_ATTRIBUTE
@ XSLT_FUNC_COPYOF
@ XSLT_FUNC_FOREACH
@ XSLT_FUNC_PI
@ XSLT_FUNC_VALUEOF
@ XSLT_FUNC_NUMBER
@ XSLT_FUNC_SORT
@ XSLT_FUNC_COMMENT
@ XSLT_FUNC_EXTENSION
@ XSLT_FUNC_IF
@ XSLT_FUNC_COPY
@ XSLT_FUNC_PARAM

◆ xsltTransformState

Enumerator
XSLT_STATE_OK 
XSLT_STATE_ERROR 
XSLT_STATE_STOPPED 

Definition at line 1673 of file xsltInternals.h.

1673 {
1674 XSLT_STATE_OK = 0,
xsltTransformState
@ XSLT_STATE_ERROR
@ XSLT_STATE_STOPPED
@ XSLT_STATE_OK

Function Documentation

◆ xsltAllocateExtra()

XSLTPUBFUN int XSLTCALL xsltAllocateExtra ( xsltStylesheetPtr  style)

xsltAllocateExtra: @style: an XSLT stylesheet

Allocate an extra runtime information slot statically while compiling the stylesheet and return its number

Returns the number of the slot

Definition at line 824 of file xslt.c.

825{
826 return(style->extrasNr++);
827}
Arabic default style
Definition: afstyles.h:94

Referenced by xsltCompMatchAdd().

◆ xsltAllocateExtraCtxt()

XSLTPUBFUN int XSLTCALL xsltAllocateExtraCtxt ( xsltTransformContextPtr  ctxt)

xsltAllocateExtraCtxt: @ctxt: an XSLT transformation context

Allocate an extra runtime information slot at run-time and return its number This make sure there is a slot ready in the transformation context

Returns the number of the slot

Definition at line 840 of file xslt.c.

841{
842 if (ctxt->extrasNr >= ctxt->extrasMax) {
843 int i;
844 if (ctxt->extrasNr == 0) {
845 ctxt->extrasMax = 20;
847 xmlMalloc(ctxt->extrasMax * sizeof(xsltRuntimeExtra));
848 if (ctxt->extras == NULL) {
850 "xsltAllocateExtraCtxt: out of memory\n");
851 return(0);
852 }
853 for (i = 0;i < ctxt->extrasMax;i++) {
854 ctxt->extras[i].info = NULL;
855 ctxt->extras[i].deallocate = NULL;
856 ctxt->extras[i].val.ptr = NULL;
857 }
858
859 } else {
861
862 ctxt->extrasMax += 100;
864 ctxt->extrasMax * sizeof(xsltRuntimeExtra));
865 if (tmp == NULL) {
867 "xsltAllocateExtraCtxt: out of memory\n");
868 return(0);
869 }
870 ctxt->extras = tmp;
871 for (i = ctxt->extrasNr;i < ctxt->extrasMax;i++) {
872 ctxt->extras[i].info = NULL;
873 ctxt->extras[i].deallocate = NULL;
874 ctxt->extras[i].val.ptr = NULL;
875 }
876 }
877 }
878 return(ctxt->extrasNr++);
879}
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
xmlReallocFunc xmlRealloc
Definition: globals.c:214
xmlMallocFunc xmlMalloc
Definition: globals.c:193
xmlFreeFunc deallocate
union _xsltRuntimeExtra::@3691 val
xsltRuntimeExtraPtr extras
xsltRuntimeExtra * xsltRuntimeExtraPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762

Referenced by xsltCompMatchAdd().

◆ xsltCompileAttr()

XSLTPUBFUN void XSLTCALL xsltCompileAttr ( xsltStylesheetPtr  style,
xmlAttrPtr  attr 
)

xsltCompileAttr: @style: a XSLT process context @attr: the attribute coming from the stylesheet.

Precompile an attribute in a stylesheet, basically it checks if it is an attribute value template, and if yes, establish some structures needed to process it at transformation time.

Definition at line 177 of file attrvt.c.

177 {
178 const xmlChar *str;
179 const xmlChar *cur;
180 xmlChar *ret = NULL;
181 xmlChar *expr = NULL;
182 xmlXPathCompExprPtr comp = NULL;
183 xsltAttrVTPtr avt, tmp;
184 int i = 0, lastavt = 0;
185
186 if ((style == NULL) || (attr == NULL) || (attr->children == NULL))
187 return;
188 if ((attr->children->type != XML_TEXT_NODE) ||
189 (attr->children->next != NULL)) {
191 "Attribute '%s': The content is expected to be a single text "
192 "node when compiling an AVT.\n", attr->name);
193 style->errors++;
194 return;
195 }
196 str = attr->children->content;
197 if ((xmlStrchr(str, '{') == NULL) &&
198 (xmlStrchr(str, '}') == NULL)) return;
199
200#ifdef WITH_XSLT_DEBUG_AVT
202 "Found AVT %s: %s\n", attr->name, str);
203#endif
204 if (attr->psvi != NULL) {
205#ifdef WITH_XSLT_DEBUG_AVT
207 "AVT %s: already compiled\n", attr->name);
208#endif
209 return;
210 }
211 /*
212 * Create a new AVT object.
213 */
214 avt = xsltNewAttrVT(style);
215 if (avt == NULL)
216 return;
217 attr->psvi = avt;
218
219 avt->nsList = xmlGetNsList(attr->doc, attr->parent);
220 if (avt->nsList != NULL) {
221 while (avt->nsList[i] != NULL)
222 i++;
223 }
224 avt->nsNr = i;
225
226 cur = str;
227 while (*cur != 0) {
228 if (*cur == '{') {
229 if (*(cur+1) == '{') { /* escaped '{' */
230 cur++;
231 ret = xmlStrncat(ret, str, cur - str);
232 cur++;
233 str = cur;
234 continue;
235 }
236 if (*(cur+1) == '}') { /* skip empty AVT */
237 ret = xmlStrncat(ret, str, cur - str);
238 cur += 2;
239 str = cur;
240 continue;
241 }
242 if ((ret != NULL) || (cur - str > 0)) {
243 ret = xmlStrncat(ret, str, cur - str);
244 str = cur;
245 if (avt->nb_seg == 0)
246 avt->strstart = 1;
247 if ((tmp = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL)
248 goto error;
249 avt = tmp;
250 ret = NULL;
251 lastavt = 0;
252 }
253
254 cur++;
255 while ((*cur != 0) && (*cur != '}')) {
256 /* Need to check for literal (bug539741) */
257 if ((*cur == '\'') || (*cur == '"')) {
258 char delim = *(cur++);
259 while ((*cur != 0) && (*cur != delim))
260 cur++;
261 if (*cur != 0)
262 cur++; /* skip the ending delimiter */
263 } else
264 cur++;
265 }
266 if (*cur == 0) {
268 "Attribute '%s': The AVT has an unmatched '{'.\n",
269 attr->name);
270 style->errors++;
271 goto error;
272 }
273 str++;
274 expr = xmlStrndup(str, cur - str);
275 if (expr == NULL) {
276 /*
277 * TODO: What needs to be done here?
278 */
280 goto error;
281 } else {
282 comp = xsltXPathCompile(style, expr);
283 if (comp == NULL) {
285 "Attribute '%s': Failed to compile the expression "
286 "'%s' in the AVT.\n", attr->name, expr);
287 style->errors++;
288 goto error;
289 }
290 if (avt->nb_seg == 0)
291 avt->strstart = 0;
292 if (lastavt == 1) {
293 if ((tmp = xsltSetAttrVTsegment(avt, NULL)) == NULL) {
295 "out of memory\n");
296 goto error;
297 }
298 avt = tmp;
299 }
300 if ((tmp = xsltSetAttrVTsegment(avt, (void *) comp)) == NULL) {
302 "out of memory\n");
303 goto error;
304 }
305 avt = tmp;
306 lastavt = 1;
307 xmlFree(expr);
308 expr = NULL;
309 comp = NULL;
310 }
311 cur++;
312 str = cur;
313 } else if (*cur == '}') {
314 cur++;
315 if (*cur == '}') { /* escaped '}' */
316 ret = xmlStrncat(ret, str, cur - str);
317 cur++;
318 str = cur;
319 continue;
320 } else {
322 "Attribute '%s': The AVT has an unmatched '}'.\n",
323 attr->name);
324 goto error;
325 }
326 } else
327 cur++;
328 }
329 if ((ret != NULL) || (cur - str > 0)) {
330 ret = xmlStrncat(ret, str, cur - str);
331 str = cur;
332 if (avt->nb_seg == 0)
333 avt->strstart = 1;
334 if ((tmp = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL)
335 goto error;
336 avt = tmp;
337 ret = NULL;
338 }
339
340error:
341 if (avt == NULL) {
343 "xsltCompileAttr: malloc problem\n");
344 } else {
345 if (attr->psvi != avt) { /* may have changed from realloc */
346 attr->psvi = avt;
347 /*
348 * This is a "hack", but I can't see any clean method of
349 * doing it. If a re-alloc has taken place, then the pointer
350 * for this AVT may have changed. style->attVTs was set by
351 * xsltNewAttrVT, so it needs to be re-set to the new value!
352 */
353 style->attVTs = avt;
354 }
355 }
356 if (ret != NULL)
357 xmlFree(ret);
358 if (expr != NULL)
359 xmlFree(expr);
360 if (comp != NULL)
361 xmlXPathFreeCompExpr(comp);
362}
static xsltAttrVTPtr xsltNewAttrVT(xsltStylesheetPtr style)
Definition: attrvt.c:68
static xsltAttrVTPtr xsltSetAttrVTsegment(xsltAttrVTPtr avt, void *val)
Definition: attrvt.c:153
return ret
Definition: mutex.c:146
FxCollectionEntry * cur
#define error(str)
Definition: mkdosfs.c:1605
const WCHAR * str
xmlFreeFunc xmlFree
Definition: globals.c:184
int strstart
Definition: attrvt.c:42
xmlNsPtr * nsList
Definition: attrvt.c:46
int nsNr
Definition: attrvt.c:47
int nb_seg
Definition: attrvt.c:40
Definition: cookie.c:202
WCHAR * name
Definition: cookie.c:203
Definition: query.h:86
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 const xmlChar * xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:327
unsigned char xmlChar
Definition: xmlstring.h:28
xmlXPathCompExprPtr xsltXPathCompile(xsltStylesheetPtr style, const xmlChar *str)
Definition: xsltutils.c:2593
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633
#define XSLT_TODO
Definition: xsltutils.h:31

Referenced by xsltParseTemplateContent().

◆ xsltCreateRVT()

XSLTPUBFUN xmlDocPtr XSLTCALL xsltCreateRVT ( xsltTransformContextPtr  ctxt)

xsltCreateRVT: @ctxt: an XSLT transformation context

Creates a Result Value Tree (the XSLT 1.0 term for this is "Result Tree Fragment")

Returns the result value tree or NULL in case of API or internal errors.

Definition at line 65 of file variables.c.

66{
67 xmlDocPtr container;
68
69 /*
70 * Question: Why is this function public?
71 * Answer: It is called by the EXSLT module.
72 */
73 if (ctxt == NULL)
74 return(NULL);
75
76 /*
77 * Reuse a RTF from the cache if available.
78 */
79 if (ctxt->cache->RVT) {
80 container = ctxt->cache->RVT;
81 ctxt->cache->RVT = (xmlDocPtr) container->next;
82 /* clear the internal pointers */
83 container->next = NULL;
84 container->prev = NULL;
85 if (ctxt->cache->nbRVT > 0)
86 ctxt->cache->nbRVT--;
87#ifdef XSLT_DEBUG_PROFILE_CACHE
88 ctxt->cache->dbgReusedRVTs++;
89#endif
90 return(container);
91 }
92
93 container = xmlNewDoc(NULL);
94 if (container == NULL)
95 return(NULL);
96 container->dict = ctxt->dict;
99 container->doc = container;
100 container->parent = NULL;
101 return(container);
102}
if(dx< 0)
Definition: linetemp.h:194
int xmlDictReference(xmlDictPtr dict)
Definition: dict.c:317
xsltTransformCachePtr cache
#define XSLT_MARK_RES_TREE_FRAG(n)
Definition: xsltInternals.h:47

Referenced by xsltEvalGlobalVariable(), and xsltEvalVariable().

◆ xsltDecimalFormatGetByName()

XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL xsltDecimalFormatGetByName ( xsltStylesheetPtr  style,
xmlChar name 
)

Definition at line 349 of file xslt.c.

350{
352
353 if (name == NULL)
354 return style->decimalFormat;
355
356 while (style != NULL) {
357 for (result = style->decimalFormat->next;
358 result != NULL;
359 result = result->next) {
360 if ((result->nsUri == NULL) && xmlStrEqual(name, result->name))
361 return result;
362 }
364 }
365 return result;
366}
GLuint64EXT * result
Definition: glext.h:11304
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:297
struct define * next
Definition: compiler.c:65
Definition: name.c:39
WCHAR * name
Definition: name.c:42
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162

◆ xsltDecimalFormatGetByQName()

XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL xsltDecimalFormatGetByQName ( xsltStylesheetPtr  style,
const xmlChar nsUri,
const xmlChar name 
)

Definition at line 379 of file xslt.c.

381{
383
384 if (name == NULL)
385 return style->decimalFormat;
386
387 while (style != NULL) {
388 for (result = style->decimalFormat->next;
389 result != NULL;
390 result = result->next) {
391 if (xmlStrEqual(nsUri, result->nsUri) &&
393 return result;
394 }
396 }
397 return result;
398}

Referenced by xsltFormatNumberFunction(), and xsltParseStylesheetDecimalFormat().

◆ xsltEvalAVT()

XSLTPUBFUN xmlChar *XSLTCALL xsltEvalAVT ( xsltTransformContextPtr  ctxt,
void avt,
xmlNodePtr  node 
)

xsltEvalAVT: @ctxt: the XSLT transformation context @avt: the prevompiled attribute value template info @node: the node hosting the attribute

Process the given AVT, and return the new string value.

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

Definition at line 377 of file attrvt.c.

377 {
378 xmlChar *ret = NULL, *tmp;
379 xmlXPathCompExprPtr comp;
381 int i;
382 int str;
383
384 if ((ctxt == NULL) || (avt == NULL) || (node == NULL))
385 return(NULL);
386 str = cur->strstart;
387 for (i = 0;i < cur->nb_seg;i++) {
388 if (str) {
389 ret = xmlStrcat(ret, (const xmlChar *) cur->segments[i]);
390 } else {
391 comp = (xmlXPathCompExprPtr) cur->segments[i];
392 tmp = xsltEvalXPathStringNs(ctxt, comp, cur->nsNr, cur->nsList);
393 if (tmp != NULL) {
394 if (ret != NULL) {
395 ret = xmlStrcat(ret, tmp);
396 xmlFree(tmp);
397 } else {
398 ret = tmp;
399 }
400 }
401 }
402 str = !str;
403 }
404 return(ret);
405}
xsltAttrVT * xsltAttrVTPtr
Definition: attrvt.c:37
xmlChar * xsltEvalXPathStringNs(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp, int nsNr, xmlNsPtr *nsList)
Definition: templates.c:123
Definition: dlist.c:348
XMLPUBFUN xmlChar * xmlStrcat(xmlChar *cur, const xmlChar *add)
Definition: xmlstring.c:524

Referenced by xsltAttrListTemplateProcess(), and xsltAttrTemplateProcess().

◆ xsltExtensionInstructionResultFinalize()

XSLTPUBFUN int XSLTCALL xsltExtensionInstructionResultFinalize ( xsltTransformContextPtr ctxt  ATTRIBUTE_UNUSED)

xsltExtensionInstructionResultFinalize: @ctxt: an XSLT transformation context

Finalizes the data (e.g. result tree fragments) created within a value-returning process (e.g. EXSLT's function). Tree fragments marked as being returned by a function are set to normal state, which means that the fragment garbage collector will free them after the function-calling process exits.

Returns 0 in case of success and -1 in case of API or internal errors.

This function is unsupported in newer releases of libxslt.

Definition at line 208 of file variables.c.

210{
212 "xsltExtensionInstructionResultFinalize is unsupported "
213 "in this release of libxslt.\n");
214 return(-1);
215}
void * xmlGenericErrorContext
Definition: globals.c:410
xmlGenericErrorFunc xmlGenericError
Definition: globals.c:396

◆ xsltExtensionInstructionResultRegister()

XSLTPUBFUN int XSLTCALL xsltExtensionInstructionResultRegister ( xsltTransformContextPtr ctxt  ATTRIBUTE_UNUSED,
xmlXPathObjectPtr obj  ATTRIBUTE_UNUSED 
)

xsltExtensionInstructionResultRegister: @ctxt: an XSLT transformation context @obj: an XPath object to be inspected for result tree fragments

Marks the result of a value-returning extension instruction in order to avoid it being garbage collected before the extension instruction exits. Note that one still has to additionally register any newly created tree fragments (via xsltCreateRVT()) with xsltRegisterLocalRVT().

Returns 0 in case of success and -1 in case of error.

It isn't necessary to call this function in newer releases of libxslt.

Definition at line 234 of file variables.c.

237{
238 return(0);
239}

◆ xsltFlagRVTs()

XSLTPUBFUN int XSLTCALL xsltFlagRVTs ( xsltTransformContextPtr  ctxt,
xmlXPathObjectPtr  obj,
int  val 
)

xsltFlagRVTs: @ctxt: an XSLT transformation context @obj: an XPath object to be inspected for result tree fragments @val: the flag value

Updates ownership information of RVTs in @obj according to @val.

@val = XSLT_RVT_FUNC_RESULT for the result of an extension function, so its RVTs won't be destroyed after leaving the returning scope. @val = XSLT_RVT_LOCAL for the result of an extension function to reset the state of its RVTs after it was returned to a new scope. @val = XSLT_RVT_GLOBAL for parts of global variables.

Returns 0 in case of success and -1 in case of error.

Definition at line 258 of file variables.c.

258 {
259 int i;
260 xmlNodePtr cur;
261 xmlDocPtr doc;
262
263 if ((ctxt == NULL) || (obj == NULL))
264 return(-1);
265
266 /*
267 * OPTIMIZE TODO: If no local variables/params and no local tree
268 * fragments were created, then we don't need to analyse the XPath
269 * objects for tree fragments.
270 */
271
272 if ((obj->type != XPATH_NODESET) && (obj->type != XPATH_XSLT_TREE))
273 return(0);
274 if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0))
275 return(0);
276
277 for (i = 0; i < obj->nodesetval->nodeNr; i++) {
278 cur = obj->nodesetval->nodeTab[i];
279 if (cur->type == XML_NAMESPACE_DECL) {
280 /*
281 * The XPath module sets the owner element of a ns-node on
282 * the ns->next field.
283 */
284 if ((((xmlNsPtr) cur)->next != NULL) &&
285 (((xmlNsPtr) cur)->next->type == XML_ELEMENT_NODE))
286 {
287 cur = (xmlNodePtr) ((xmlNsPtr) cur)->next;
288 doc = cur->doc;
289 } else {
290 xsltTransformError(ctxt, NULL, ctxt->inst,
291 "Internal error in xsltFlagRVTs(): "
292 "Cannot retrieve the doc of a namespace node.\n");
293 return(-1);
294 }
295 } else {
296 doc = cur->doc;
297 }
298 if (doc == NULL) {
299 xsltTransformError(ctxt, NULL, ctxt->inst,
300 "Internal error in xsltFlagRVTs(): "
301 "Cannot retrieve the doc of a node.\n");
302 return(-1);
303 }
304 if (doc->name && (doc->name[0] == ' ') &&
305 doc->compression != XSLT_RVT_GLOBAL) {
306 /*
307 * This is a result tree fragment.
308 * We store ownership information in the @compression field.
309 * TODO: How do we know if this is a doc acquired via the
310 * document() function?
311 */
312#ifdef WITH_XSLT_DEBUG_VARIABLE
315 "Flagging RVT %p: %d -> %d\n",
316 (void *) doc, doc->compression, val));
317#endif
318
319 if (val == XSLT_RVT_LOCAL) {
320 if (doc->compression == XSLT_RVT_FUNC_RESULT)
321 doc->compression = XSLT_RVT_LOCAL;
322 } else if (val == XSLT_RVT_GLOBAL) {
323 if (doc->compression != XSLT_RVT_LOCAL) {
325 "xsltFlagRVTs: Invalid transition %d => GLOBAL\n",
326 doc->compression);
327 doc->compression = XSLT_RVT_GLOBAL;
328 return(-1);
329 }
330
331 /* Will be registered as persistant in xsltReleaseLocalRVTs. */
332 doc->compression = XSLT_RVT_GLOBAL;
333 } else if (val == XSLT_RVT_FUNC_RESULT) {
334 doc->compression = val;
335 }
336 }
337 }
338
339 return(0);
340}
GLuint GLfloat * val
Definition: glext.h:7180
static unsigned __int64 next
Definition: rand_nt.c:6
#define XSLT_RVT_GLOBAL
Definition: variables.h:62
#define XSLT_RVT_FUNC_RESULT
Definition: variables.h:55
#define XSLT_RVT_LOCAL
Definition: variables.h:46
@ XSLT_TRACE_VARIABLES
Definition: xsltutils.h:124
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:132

Referenced by xsltEvalGlobalVariable().

◆ xsltFormatNumberConversion()

XSLTPUBFUN xmlXPathError XSLTCALL xsltFormatNumberConversion ( xsltDecimalFormatPtr  self,
xmlChar format,
double  number,
xmlChar **  result 
)

xsltFormatNumberConversion: @self: the decimal format @format: the format requested @number: the value to format

Returns
: the place to output the result

format-number() uses the JDK 1.1 DecimalFormat class:

http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormat.html

Structure:

pattern := subpattern{;subpattern} subpattern := {prefix}integer{.fraction}{suffix} prefix := '\u0000'..'\uFFFD' - specialCharacters suffix := '\u0000'..'\uFFFD' - specialCharacters integer := '#'* '0'* '0' fraction := '0'* '#'*

Notation: X* 0 or more instances of X (X | Y) either X or Y. X..Y any character from X up to Y, inclusive. S - T characters in S, except those in T

Special Characters:

Symbol Meaning 0 a digit

a digit, zero shows as absent

. placeholder for decimal separator , placeholder for grouping separator. ; separates formats.

  • default negative prefix. % multiply by 100 and show as percentage ? multiply by 1000 and show as per mille X any other characters can be used in the prefix or suffix ' used to quote special characters in a prefix or suffix.

Returns a possible XPath error

Definition at line 957 of file numbers.c.

961{
962 xmlXPathError status = XPATH_EXPRESSION_OK;
963 xmlBufferPtr buffer;
964 xmlChar *the_format, *prefix = NULL, *suffix = NULL;
965 xmlChar *nprefix, *nsuffix = NULL;
966 int prefix_length, suffix_length = 0, nprefix_length, nsuffix_length;
967 int exp10;
968 double scale;
969 int j, len = 0;
970 int self_grouping_len;
972 /*
973 * delayed_multiplier allows a 'trailing' percent or
974 * permille to be treated as suffix
975 */
976 int delayed_multiplier = 0;
977 /* flag to show no -ve format present for -ve number */
978 char default_sign = 0;
979 /* flag to show error found, should use default format */
980 char found_error = 0;
981
982 if (xmlStrlen(format) <= 0) {
984 "xsltFormatNumberConversion : "
985 "Invalid format (0-length)\n");
986 }
987 *result = NULL;
988 if (xmlXPathIsNaN(number)) {
989 if ((self == NULL) || (self->noNumber == NULL))
990 *result = xmlStrdup(BAD_CAST "NaN");
991 else
992 *result = xmlStrdup(self->noNumber);
993 return(status);
994 }
995
996 format_info.integer_hash = 0;
997 format_info.integer_digits = 0;
998 format_info.frac_digits = 0;
999 format_info.frac_hash = 0;
1000 format_info.group = -1;
1001 format_info.multiplier = 1;
1002 format_info.add_decimal = FALSE;
1003 format_info.is_multiplier_set = FALSE;
1004 format_info.is_negative_pattern = FALSE;
1005
1006 the_format = format;
1007
1008 /*
1009 * First we process the +ve pattern to get percent / permille,
1010 * as well as main format
1011 */
1012 prefix = the_format;
1013 prefix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info);
1014 if (prefix_length < 0) {
1015 found_error = 1;
1016 goto OUTPUT_NUMBER;
1017 }
1018
1019 /*
1020 * Here we process the "number" part of the format. It gets
1021 * a little messy because of the percent/per-mille - if that
1022 * appears at the end, it may be part of the suffix instead
1023 * of part of the number, so the variable delayed_multiplier
1024 * is used to handle it
1025 */
1026 self_grouping_len = xmlStrlen(self->grouping);
1027 while ((*the_format != 0) &&
1028 (xsltUTF8Charcmp(the_format, self->decimalPoint) != 0) &&
1029 (xsltUTF8Charcmp(the_format, self->patternSeparator) != 0)) {
1030
1031 if (delayed_multiplier != 0) {
1032 format_info.multiplier = delayed_multiplier;
1033 format_info.is_multiplier_set = TRUE;
1034 delayed_multiplier = 0;
1035 }
1036 if (xsltUTF8Charcmp(the_format, self->digit) == 0) {
1037 if (format_info.integer_digits > 0) {
1038 found_error = 1;
1039 goto OUTPUT_NUMBER;
1040 }
1041 format_info.integer_hash++;
1042 if (format_info.group >= 0)
1043 format_info.group++;
1044 } else if (xsltUTF8Charcmp(the_format, self->zeroDigit) == 0) {
1045 format_info.integer_digits++;
1046 if (format_info.group >= 0)
1047 format_info.group++;
1048 } else if ((self_grouping_len > 0) &&
1049 (!xmlStrncmp(the_format, self->grouping, self_grouping_len))) {
1050 /* Reset group count */
1051 format_info.group = 0;
1052 the_format += self_grouping_len;
1053 continue;
1054 } else if (xsltUTF8Charcmp(the_format, self->percent) == 0) {
1055 if (format_info.is_multiplier_set) {
1056 found_error = 1;
1057 goto OUTPUT_NUMBER;
1058 }
1059 delayed_multiplier = 100;
1060 } else if (xsltUTF8Charcmp(the_format, self->permille) == 0) {
1061 if (format_info.is_multiplier_set) {
1062 found_error = 1;
1063 goto OUTPUT_NUMBER;
1064 }
1065 delayed_multiplier = 1000;
1066 } else
1067 break; /* while */
1068
1069 if ((len=xmlUTF8Strsize(the_format, 1)) < 1) {
1070 found_error = 1;
1071 goto OUTPUT_NUMBER;
1072 }
1073 the_format += len;
1074
1075 }
1076
1077 /* We have finished the integer part, now work on fraction */
1078 if ( (*the_format != 0) &&
1079 (xsltUTF8Charcmp(the_format, self->decimalPoint) == 0) ) {
1080 format_info.add_decimal = TRUE;
1081 if ((len = xmlUTF8Strsize(the_format, 1)) < 1) {
1082 found_error = 1;
1083 goto OUTPUT_NUMBER;
1084 }
1085 the_format += len; /* Skip over the decimal */
1086 }
1087
1088 while (*the_format != 0) {
1089
1090 if (xsltUTF8Charcmp(the_format, self->zeroDigit) == 0) {
1091 if (format_info.frac_hash != 0) {
1092 found_error = 1;
1093 goto OUTPUT_NUMBER;
1094 }
1095 format_info.frac_digits++;
1096 } else if (xsltUTF8Charcmp(the_format, self->digit) == 0) {
1097 format_info.frac_hash++;
1098 } else if (xsltUTF8Charcmp(the_format, self->percent) == 0) {
1099 if (format_info.is_multiplier_set) {
1100 found_error = 1;
1101 goto OUTPUT_NUMBER;
1102 }
1103 delayed_multiplier = 100;
1104 if ((len = xmlUTF8Strsize(the_format, 1)) < 1) {
1105 found_error = 1;
1106 goto OUTPUT_NUMBER;
1107 }
1108 the_format += len;
1109 continue; /* while */
1110 } else if (xsltUTF8Charcmp(the_format, self->permille) == 0) {
1111 if (format_info.is_multiplier_set) {
1112 found_error = 1;
1113 goto OUTPUT_NUMBER;
1114 }
1115 delayed_multiplier = 1000;
1116 if ((len = xmlUTF8Strsize(the_format, 1)) < 1) {
1117 found_error = 1;
1118 goto OUTPUT_NUMBER;
1119 }
1120 the_format += len;
1121 continue; /* while */
1122 } else if (xsltUTF8Charcmp(the_format, self->grouping) != 0) {
1123 break; /* while */
1124 }
1125 if ((len = xmlUTF8Strsize(the_format, 1)) < 1) {
1126 found_error = 1;
1127 goto OUTPUT_NUMBER;
1128 }
1129 the_format += len;
1130 if (delayed_multiplier != 0) {
1131 format_info.multiplier = delayed_multiplier;
1132 delayed_multiplier = 0;
1133 format_info.is_multiplier_set = TRUE;
1134 }
1135 }
1136
1137 /*
1138 * If delayed_multiplier is set after processing the
1139 * "number" part, should be in suffix
1140 */
1141 if (delayed_multiplier != 0) {
1142 the_format -= len;
1143 delayed_multiplier = 0;
1144 }
1145
1146 suffix = the_format;
1147 suffix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info);
1148 if ( (suffix_length < 0) ||
1149 ((*the_format != 0) &&
1150 (xsltUTF8Charcmp(the_format, self->patternSeparator) != 0)) ) {
1151 found_error = 1;
1152 goto OUTPUT_NUMBER;
1153 }
1154
1155 /*
1156 * We have processed the +ve prefix, number part and +ve suffix.
1157 * If the number is -ve, we must substitute the -ve prefix / suffix
1158 */
1159 if (number < 0) {
1160 /*
1161 * Note that j is the number of UTF8 chars before the separator,
1162 * not the number of bytes! (bug 151975)
1163 */
1165 if (j < 0) {
1166 /* No -ve pattern present, so use default signing */
1167 default_sign = 1;
1168 }
1169 else {
1170 /* Skip over pattern separator (accounting for UTF8) */
1171 the_format = (xmlChar *)xmlUTF8Strpos(format, j + 1);
1172 /*
1173 * Flag changes interpretation of percent/permille
1174 * in -ve pattern
1175 */
1176 format_info.is_negative_pattern = TRUE;
1177 format_info.is_multiplier_set = FALSE;
1178
1179 /* First do the -ve prefix */
1180 nprefix = the_format;
1181 nprefix_length = xsltFormatNumberPreSuffix(self,
1182 &the_format, &format_info);
1183 if (nprefix_length<0) {
1184 found_error = 1;
1185 goto OUTPUT_NUMBER;
1186 }
1187
1188 while (*the_format != 0) {
1189 if ( (xsltUTF8Charcmp(the_format, (self)->percent) == 0) ||
1190 (xsltUTF8Charcmp(the_format, (self)->permille)== 0) ) {
1191 if (format_info.is_multiplier_set) {
1192 found_error = 1;
1193 goto OUTPUT_NUMBER;
1194 }
1195 format_info.is_multiplier_set = TRUE;
1196 delayed_multiplier = 1;
1197 }
1198 else if (IS_SPECIAL(self, the_format))
1199 delayed_multiplier = 0;
1200 else
1201 break; /* while */
1202 if ((len = xmlUTF8Strsize(the_format, 1)) < 1) {
1203 found_error = 1;
1204 goto OUTPUT_NUMBER;
1205 }
1206 the_format += len;
1207 }
1208 if (delayed_multiplier != 0) {
1209 format_info.is_multiplier_set = FALSE;
1210 the_format -= len;
1211 }
1212
1213 /* Finally do the -ve suffix */
1214 if (*the_format != 0) {
1215 nsuffix = the_format;
1216 nsuffix_length = xsltFormatNumberPreSuffix(self,
1217 &the_format, &format_info);
1218 if (nsuffix_length < 0) {
1219 found_error = 1;
1220 goto OUTPUT_NUMBER;
1221 }
1222 }
1223 else
1224 nsuffix_length = 0;
1225 if (*the_format != 0) {
1226 found_error = 1;
1227 goto OUTPUT_NUMBER;
1228 }
1229 /*
1230 * Here's another Java peculiarity:
1231 * if -ve prefix/suffix == +ve ones, discard & use default
1232 */
1233 if ((nprefix_length != prefix_length) ||
1234 (nsuffix_length != suffix_length) ||
1235 ((nprefix_length > 0) &&
1236 (xmlStrncmp(nprefix, prefix, prefix_length) !=0 )) ||
1237 ((nsuffix_length > 0) &&
1238 (xmlStrncmp(nsuffix, suffix, suffix_length) !=0 ))) {
1239 prefix = nprefix;
1240 prefix_length = nprefix_length;
1241 suffix = nsuffix;
1242 suffix_length = nsuffix_length;
1243 } /* else {
1244 default_sign = 1;
1245 }
1246 */
1247 }
1248 }
1249
1250OUTPUT_NUMBER:
1251 if (found_error != 0) {
1253 "xsltFormatNumberConversion : "
1254 "error in format string '%s', using default\n", format);
1255 default_sign = (number < 0.0) ? 1 : 0;
1256 prefix_length = suffix_length = 0;
1257 format_info.integer_hash = 0;
1258 format_info.integer_digits = 1;
1259 format_info.frac_digits = 1;
1260 format_info.frac_hash = 4;
1261 format_info.group = -1;
1262 format_info.multiplier = 1;
1263 format_info.add_decimal = TRUE;
1264 }
1265
1266 /* Apply multiplier */
1267 number *= (double)format_info.multiplier;
1268 switch (xmlXPathIsInf(number)) {
1269 case -1:
1270 if (self->minusSign == NULL)
1271 *result = xmlStrdup(BAD_CAST "-");
1272 else
1273 *result = xmlStrdup(self->minusSign);
1274 /* Intentional fall-through */
1275 case 1:
1276 if ((self == NULL) || (self->infinity == NULL))
1277 *result = xmlStrcat(*result, BAD_CAST "Infinity");
1278 else
1279 *result = xmlStrcat(*result, self->infinity);
1280 return(status);
1281 default:
1282 break;
1283 }
1284
1285 buffer = xmlBufferCreate();
1286 if (buffer == NULL) {
1287 return XPATH_MEMORY_ERROR;
1288 }
1289
1290 /* Ready to output our number. First see if "default sign" is required */
1291 if (default_sign != 0)
1292 xmlBufferAdd(buffer, self->minusSign, xmlUTF8Strsize(self->minusSign, 1));
1293
1294 /* Put the prefix into the buffer */
1295 for (j = 0; j < prefix_length; ) {
1296 if (*prefix == SYMBOL_QUOTE)
1297 prefix++;
1299 xmlBufferAdd(buffer, prefix, len);
1300 prefix += len;
1301 j += len;
1302 }
1303
1304 /* Round to n digits */
1305 number = fabs(number);
1306 exp10 = format_info.frac_digits + format_info.frac_hash;
1307 /* DBL_MAX_10_EXP should be 308 on IEEE platforms. */
1308 if (exp10 > DBL_MAX_10_EXP) {
1309 if (format_info.frac_digits > DBL_MAX_10_EXP) {
1310 format_info.frac_digits = DBL_MAX_10_EXP;
1311 format_info.frac_hash = 0;
1312 } else {
1313 format_info.frac_hash = DBL_MAX_10_EXP - format_info.frac_digits;
1314 }
1315 exp10 = DBL_MAX_10_EXP;
1316 }
1317 scale = pow(10.0, (double) exp10);
1318 number += .5 / scale;
1319 number -= fmod(number, 1 / scale);
1320
1321 /* Next do the integer part of the number */
1322 if ((self->grouping != NULL) &&
1323 (self->grouping[0] != 0)) {
1324 int gchar;
1325
1326 len = xmlStrlen(self->grouping);
1327 gchar = xsltGetUTF8Char(self->grouping, &len);
1329 format_info.integer_digits,
1330 format_info.group,
1331 gchar, len);
1332 } else
1334 format_info.integer_digits,
1335 format_info.group,
1336 ',', 1);
1337
1338 /* Special case: java treats '.#' like '.0', '.##' like '.0#', etc. */
1339 if ((format_info.integer_digits + format_info.integer_hash +
1340 format_info.frac_digits == 0) && (format_info.frac_hash > 0)) {
1341 ++format_info.frac_digits;
1342 --format_info.frac_hash;
1343 }
1344
1345 /* Add leading zero, if required */
1346 if ((floor(number) == 0) &&
1347 (format_info.integer_digits + format_info.frac_digits == 0)) {
1348 xmlBufferAdd(buffer, self->zeroDigit, xmlUTF8Strsize(self->zeroDigit, 1));
1349 }
1350
1351 /* Next the fractional part, if required */
1352 if (format_info.frac_digits + format_info.frac_hash == 0) {
1353 if (format_info.add_decimal)
1354 xmlBufferAdd(buffer, self->decimalPoint,
1355 xmlUTF8Strsize(self->decimalPoint, 1));
1356 }
1357 else {
1358 number -= floor(number);
1359 if ((number != 0) || (format_info.frac_digits != 0)) {
1360 xmlBufferAdd(buffer, self->decimalPoint,
1361 xmlUTF8Strsize(self->decimalPoint, 1));
1362 number = floor(scale * number + 0.5);
1363 for (j = format_info.frac_hash; j > 0; j--) {
1364 if (fmod(number, 10.0) >= 1.0)
1365 break; /* for */
1366 number /= 10.0;
1367 }
1369 format_info.frac_digits + j,
1370 0, 0, 0);
1371 }
1372 }
1373 /* Put the suffix into the buffer */
1374 for (j = 0; j < suffix_length; ) {
1375 if (*suffix == SYMBOL_QUOTE)
1376 suffix++;
1377 len = xmlUTF8Strsize(suffix, 1);
1378 xmlBufferAdd(buffer, suffix, len);
1379 suffix += len;
1380 j += len;
1381 }
1382
1383 *result = xmlStrdup(xmlBufferContent(buffer));
1384 xmlBufferFree(buffer);
1385 return status;
1386}
#define SYMBOL_QUOTE
Definition: numbers.c:37
static void xsltNumberFormatDecimal(xmlBufferPtr buffer, double number, int digit_zero, int width, int digitsPerGroup, int groupingCharacter, int groupingCharacterLen)
Definition: numbers.c:139
#define TRUE
Definition: numbers.c:34
#define FALSE
Definition: numbers.c:33
#define IS_SPECIAL(self, letter)
Definition: numbers.c:108
static int xsltUTF8Charcmp(xmlChar *utf1, xmlChar *utf2)
Definition: numbers.c:82
static int xsltFormatNumberPreSuffix(xsltDecimalFormatPtr self, xmlChar **format, xsltFormatNumberInfoPtr info)
Definition: numbers.c:865
format_info
#define DBL_MAX_10_EXP
Definition: float.h:22
_ACRTIMP double __cdecl fabs(double)
_ACRTIMP double __cdecl fmod(double, double)
_ACRTIMP double __cdecl floor(double)
Definition: floor.c:18
switch(r->id)
Definition: btrfs.c:3046
double pow(double x, double y)
Definition: freeldr.c:178
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
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 GLint GLint j
Definition: glfuncs.h:250
static unsigned int number
Definition: dsound.c:1479
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:91
xmlChar * decimalPoint
xmlChar * patternSeparator
Definition: format.c:58
Definition: ps.c:97
Character const *const prefix
Definition: tempnam.cpp:195
XMLPUBFUN int xmlUTF8Strloc(const xmlChar *utf, const xmlChar *utfchar)
Definition: xmlstring.c:926
XMLPUBFUN int xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:428
XMLPUBFUN const xmlChar * xmlUTF8Strpos(const xmlChar *utf, int pos)
Definition: xmlstring.c:894
XMLPUBFUN int xmlStrncmp(const xmlChar *str1, const xmlChar *str2, int len)
Definition: xmlstring.c:215
XMLPUBFUN int xmlUTF8Strsize(const xmlChar *utf, int len)
Definition: xmlstring.c:833
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69
int xsltGetUTF8Char(const unsigned char *utf, int *len)
Definition: xsltutils.c:251

Referenced by xsltFormatNumberFunction().

◆ xsltFreeAVTList()

XSLTPUBFUN void XSLTCALL xsltFreeAVTList ( void avt)

xsltFreeAVTList: @avt: pointer to an list of AVT structures

Free up the memory associated to the attribute value templates

Definition at line 131 of file attrvt.c.

131 {
133
134 while (cur != NULL) {
135 next = cur->next;
137 cur = next;
138 }
139}
static void xsltFreeAttrVT(xsltAttrVTPtr avt)
Definition: attrvt.c:101

Referenced by xsltFreeStylesheet().

◆ xsltFreeRVTs()

xsltFreeRVTs: @ctxt: an XSLT transformation context

Frees all registered result value trees (Result Tree Fragments) of the transformation. Internal function; should not be called by user-code.

Definition at line 439 of file variables.c.

440{
441 xmlDocPtr cur, next;
442
443 if (ctxt == NULL)
444 return;
445 /*
446 * Local fragments.
447 */
448 cur = ctxt->localRVT;
449 while (cur != NULL) {
450 next = (xmlDocPtr) cur->next;
451 if (cur->_private != NULL) {
452 xsltFreeDocumentKeys(cur->_private);
453 xmlFree(cur->_private);
454 }
455 xmlFreeDoc(cur);
456 cur = next;
457 }
458 ctxt->localRVT = NULL;
459 /*
460 * User-created per-template fragments.
461 */
462 cur = ctxt->tmpRVT;
463 while (cur != NULL) {
464 next = (xmlDocPtr) cur->next;
465 if (cur->_private != NULL) {
466 xsltFreeDocumentKeys(cur->_private);
467 xmlFree(cur->_private);
468 }
469 xmlFreeDoc(cur);
470 cur = next;
471 }
472 ctxt->tmpRVT = NULL;
473 /*
474 * Global fragments.
475 */
476 cur = ctxt->persistRVT;
477 while (cur != NULL) {
478 next = (xmlDocPtr) cur->next;
479 if (cur->_private != NULL) {
480 xsltFreeDocumentKeys(cur->_private);
481 xmlFree(cur->_private);
482 }
483 xmlFreeDoc(cur);
484 cur = next;
485 }
486 ctxt->persistRVT = NULL;
487}
void xsltFreeDocumentKeys(xsltDocumentPtr idoc)
Definition: keys.c:931

Referenced by xsltApplyStylesheetInternal(), and xsltFreeTransformContext().

◆ xsltFreeStackElemList()

XSLTPUBFUN void XSLTCALL xsltFreeStackElemList ( xsltStackElemPtr  elem)

xsltFreeStackElemList: @elem: an XSLT stack element

Free up the memory allocated by @elem

Definition at line 626 of file variables.c.

626 {
628
629 while (elem != NULL) {
630 next = elem->next;
632 elem = next;
633 }
634}
static size_t elem
Definition: string.c:71
static void xsltFreeStackElem(xsltStackElemPtr elem)
Definition: variables.c:565

Referenced by xsltApplyStylesheetInternal(), xsltApplyTemplates(), xsltCallTemplate(), xsltFreeStylesheet(), xsltLocalVariablePop(), and xsltTemplateParamsCleanup().

◆ xsltFreeStylesheet()

XSLTPUBFUN void XSLTCALL xsltFreeStylesheet ( xsltStylesheetPtr  style)

xsltFreeStylesheet: @style: an XSLT stylesheet

Free up the memory allocated by @style

Definition at line 965 of file xslt.c.

966{
967 if (style == NULL)
968 return;
969
970#ifdef XSLT_REFACTORED
971 /*
972 * Start with a cleanup of the main stylesheet's doc.
973 */
974 if ((style->principal == style) && (style->doc))
976 xmlDocGetRootElement(style->doc));
977#ifdef XSLT_REFACTORED_XSLT_NSCOMP
978 /*
979 * Restore changed ns-decls before freeing the document.
980 */
981 if ((style->doc != NULL) &&
982 XSLT_HAS_INTERNAL_NSMAP(style))
983 {
984 xsltRestoreDocumentNamespaces(XSLT_GET_INTERNAL_NSMAP(style),
985 style->doc);
986 }
987#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
988#else
989 /*
990 * Start with a cleanup of the main stylesheet's doc.
991 */
992 if ((style->parent == NULL) && (style->doc))
994 xmlDocGetRootElement(style->doc));
995#endif /* XSLT_REFACTORED */
996
1001 xsltFreeTemplateList(style->templates);
1005 /*
1006 * Free documents of all included stylsheet modules of this
1007 * stylesheet level.
1008 */
1010 /*
1011 * TODO: Best time to shutdown extension stuff?
1012 */
1014
1015 if (style->variables != NULL)
1016 xsltFreeStackElemList(style->variables);
1017 if (style->cdataSection != NULL)
1018 xmlHashFree(style->cdataSection, NULL);
1019 if (style->stripSpaces != NULL)
1020 xmlHashFree(style->stripSpaces, NULL);
1021 if (style->nsHash != NULL)
1022 xmlHashFree(style->nsHash, NULL);
1023 if (style->exclPrefixTab != NULL)
1024 xmlFree(style->exclPrefixTab);
1025 if (style->method != NULL)
1026 xmlFree(style->method);
1027 if (style->methodURI != NULL)
1028 xmlFree(style->methodURI);
1029 if (style->version != NULL)
1030 xmlFree(style->version);
1031 if (style->encoding != NULL)
1032 xmlFree(style->encoding);
1033 if (style->doctypePublic != NULL)
1034 xmlFree(style->doctypePublic);
1035 if (style->doctypeSystem != NULL)
1036 xmlFree(style->doctypeSystem);
1037 if (style->mediaType != NULL)
1038 xmlFree(style->mediaType);
1039 if (style->attVTs)
1040 xsltFreeAVTList(style->attVTs);
1041 if (style->imports != NULL)
1042 xsltFreeStylesheetList(style->imports);
1043
1044#ifdef XSLT_REFACTORED
1045 /*
1046 * If this is the principal stylesheet, then
1047 * free its internal data.
1048 */
1049 if (style->principal == style) {
1050 if (style->principalData) {
1051 xsltFreePrincipalStylesheetData(style->principalData);
1052 style->principalData = NULL;
1053 }
1054 }
1055#endif
1056 /*
1057 * Better to free the main document of this stylesheet level
1058 * at the end - so here.
1059 */
1060 if (style->doc != NULL) {
1061 xmlFreeDoc(style->doc);
1062 }
1063
1064#ifdef WITH_XSLT_DEBUG
1066 "freeing dictionary from stylesheet\n");
1067#endif
1068 xmlDictFree(style->dict);
1069
1070 if (style->xpathCtxt != NULL)
1071 xmlXPathFreeContext(style->xpathCtxt);
1072
1073 memset(style, -1, sizeof(xsltStylesheet));
1074 xmlFree(style);
1075}
void xsltShutdownExts(xsltStylesheetPtr style)
Definition: extensions.c:1158
void xsltFreeExts(xsltStylesheetPtr style)
Definition: extensions.c:501
void xsltFreeStylePreComps(xsltStylesheetPtr style)
Definition: preproc.c:1951
void xsltFreeAVTList(void *avt)
Definition: attrvt.c:131
void xsltFreeAttributeSetsHashes(xsltStylesheetPtr style)
Definition: attributes.c:1237
void xsltFreeTemplateHashes(xsltStylesheetPtr style)
Definition: pattern.c:2512
void xsltFreeStyleDocuments(xsltStylesheetPtr style)
Definition: documents.c:208
void xsltFreeKeys(xsltStylesheetPtr style)
Definition: keys.c:203
void xsltFreeNamespaceAliasHashes(xsltStylesheetPtr style)
Definition: namespaces.c:831
void xmlDictFree(xmlDictPtr dict)
Definition: dict.c:333
void xmlHashFree(xmlHashTablePtr hash, xmlHashDeallocator dealloc)
Definition: hash.c:229
#define memset(x, y, z)
Definition: compat.h:39
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:626
static void xsltFreeTemplateList(xsltTemplatePtr template)
Definition: xslt.c:460
static void xsltFreeStylesheetList(xsltStylesheetPtr style)
Definition: xslt.c:888
static void xsltFreeDecimalFormatList(xsltStylesheetPtr self)
Definition: xslt.c:323
static int xsltCleanupStylesheetTree(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr rootElem ATTRIBUTE_UNUSED)
Definition: xslt.c:910

Referenced by node_transform_node_params(), xsltDocumentElem(), xsltFreeStylesheetList(), xsltNewStylesheetInternal(), and xsltParseStylesheetImportedDoc().

◆ xsltInitAllDocKeys()

XSLTPUBFUN int XSLTCALL xsltInitAllDocKeys ( xsltTransformContextPtr  ctxt)

xsltInitAllDocKeys: @ctxt: transformation context

INTERNAL ROUTINE ONLY

Check if any keys on the current document need to be computed

Returns 0 in case of success, -1 in case of failure

Definition at line 555 of file keys.c.

556{
558 xsltKeyDefPtr keyd;
560
561 if (ctxt == NULL)
562 return(-1);
563
564#ifdef KEY_INIT_DEBUG
565fprintf(stderr, "xsltInitAllDocKeys %d %d\n",
566 ctxt->document->nbKeysComputed, ctxt->nbKeys);
567#endif
568
569 if (ctxt->document->nbKeysComputed == ctxt->nbKeys)
570 return(0);
571
572
573 /*
574 * TODO: This could be further optimized
575 */
576 style = ctxt->style;
577 while (style) {
578 keyd = (xsltKeyDefPtr) style->keys;
579 while (keyd != NULL) {
580#ifdef KEY_INIT_DEBUG
581fprintf(stderr, "Init key %s\n", keyd->name);
582#endif
583 /*
584 * Check if keys with this QName have been already
585 * computed.
586 */
588 while (table) {
589 if (((keyd->nameURI != NULL) == (table->nameURI != NULL)) &&
590 xmlStrEqual(keyd->name, table->name) &&
591 xmlStrEqual(keyd->nameURI, table->nameURI))
592 {
593 break;
594 }
595 table = table->next;
596 }
597 if (table == NULL) {
598 /*
599 * Keys with this QName have not been yet computed.
600 */
601 xsltInitDocKeyTable(ctxt, keyd->name, keyd->nameURI);
602 }
603 keyd = keyd->next;
604 }
606 }
607#ifdef KEY_INIT_DEBUG
608fprintf(stderr, "xsltInitAllDocKeys: done\n");
609#endif
610 return(0);
611}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
#define stderr
static int xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:499
struct _xsltKeyDef * next
xmlChar * nameURI
xmlChar * name
xsltDocumentPtr document
xsltStylesheetPtr style
const WCHAR * name
xsltKeyDef * xsltKeyDefPtr
xsltKeyTable * xsltKeyTablePtr

Referenced by xsltComputeAllKeys(), and xsltGetKey().

◆ xsltInitCtxtKey()

XSLTPUBFUN int XSLTCALL xsltInitCtxtKey ( xsltTransformContextPtr  ctxt,
xsltDocumentPtr  idoc,
xsltKeyDefPtr  keyDef 
)

xsltInitCtxtKey: @ctxt: an XSLT transformation context @idoc: the document information (holds key values) @keyDef: the key definition

Computes the key tables this key and for the current input document.

Returns: 0 on success, -1 on error

Multiple key definitions for the same name are allowed, so we must check if the key is already present for this doc

If the key was not previously defined, create it now and chain it to the list of keys for the doc

Definition at line 624 of file keys.c.

626{
627 int i, len, k;
628 xmlNodeSetPtr matchList = NULL, keylist;
629 xmlXPathObjectPtr matchRes = NULL, useRes = NULL;
630 xmlChar *str = NULL;
632 xmlNodePtr oldInst, cur;
633 xmlNodePtr oldContextNode;
634 xsltDocumentPtr oldDocInfo;
635 int oldXPPos, oldXPSize;
636 xmlNodePtr oldXPNode;
637 xmlDocPtr oldXPDoc;
638 int oldXPNsNr;
639 xmlNsPtr *oldXPNamespaces;
640 xmlXPathContextPtr xpctxt;
641
642#ifdef KEY_INIT_DEBUG
643fprintf(stderr, "xsltInitCtxtKey %s : %d\n", keyDef->name, ctxt->keyInitLevel);
644#endif
645
646 if ((keyDef->comp == NULL) || (keyDef->usecomp == NULL))
647 return(-1);
648
649 /*
650 * Detect recursive keys
651 */
652 if (ctxt->keyInitLevel > ctxt->nbKeys) {
653#ifdef WITH_XSLT_DEBUG_KEYS
656 "xsltInitCtxtKey: key definition of %s is recursive\n",
657 keyDef->name));
658#endif
659 xsltTransformError(ctxt, NULL, keyDef->inst,
660 "Key definition for %s is recursive\n", keyDef->name);
662 return(-1);
663 }
664 ctxt->keyInitLevel++;
665
666 xpctxt = ctxt->xpathCtxt;
667 idoc->nbKeysComputed++;
668 /*
669 * Save context state.
670 */
671 oldInst = ctxt->inst;
672 oldDocInfo = ctxt->document;
673 oldContextNode = ctxt->node;
674
675 oldXPNode = xpctxt->node;
676 oldXPDoc = xpctxt->doc;
677 oldXPPos = xpctxt->proximityPosition;
678 oldXPSize = xpctxt->contextSize;
679 oldXPNsNr = xpctxt->nsNr;
680 oldXPNamespaces = xpctxt->namespaces;
681
682 /*
683 * Set up contexts.
684 */
685 ctxt->document = idoc;
686 ctxt->node = (xmlNodePtr) idoc->doc;
687 ctxt->inst = keyDef->inst;
688
689 xpctxt->doc = idoc->doc;
690 xpctxt->node = (xmlNodePtr) idoc->doc;
691 /* TODO : clarify the use of namespaces in keys evaluation */
692 xpctxt->namespaces = keyDef->nsList;
693 xpctxt->nsNr = keyDef->nsNr;
694
695 /*
696 * Evaluate the 'match' expression of the xsl:key.
697 * TODO: The 'match' is a *pattern*.
698 */
699 matchRes = xmlXPathCompiledEval(keyDef->comp, xpctxt);
700 if (matchRes == NULL) {
701
702#ifdef WITH_XSLT_DEBUG_KEYS
704 "xsltInitCtxtKey: %s evaluation failed\n", keyDef->match));
705#endif
706 xsltTransformError(ctxt, NULL, keyDef->inst,
707 "Failed to evaluate the 'match' expression.\n");
709 goto error;
710 } else {
711 if (matchRes->type == XPATH_NODESET) {
712 matchList = matchRes->nodesetval;
713
714#ifdef WITH_XSLT_DEBUG_KEYS
715 if (matchList != NULL)
717 "xsltInitCtxtKey: %s evaluates to %d nodes\n",
718 keyDef->match, matchList->nodeNr));
719#endif
720 } else {
721 /*
722 * Is not a node set, but must be.
723 */
724#ifdef WITH_XSLT_DEBUG_KEYS
726 "xsltInitCtxtKey: %s is not a node set\n", keyDef->match));
727#endif
728 xsltTransformError(ctxt, NULL, keyDef->inst,
729 "The 'match' expression did not evaluate to a node set.\n");
731 goto error;
732 }
733 }
734 if ((matchList == NULL) || (matchList->nodeNr <= 0))
735 goto exit;
736
741 table = (xsltKeyTablePtr) idoc->keys;
742 while (table != NULL) {
743 if (xmlStrEqual(table->name, keyDef->name) &&
744 (((keyDef->nameURI == NULL) && (table->nameURI == NULL)) ||
745 ((keyDef->nameURI != NULL) && (table->nameURI != NULL) &&
746 (xmlStrEqual(table->nameURI, keyDef->nameURI)))))
747 break;
748 table = table->next;
749 }
754 if (table == NULL) {
755 table = xsltNewKeyTable(keyDef->name, keyDef->nameURI);
756 if (table == NULL)
757 goto error;
758 table->next = idoc->keys;
759 idoc->keys = table;
760 }
761
762 /*
763 * SPEC XSLT 1.0 (XSLT 2.0 does not clarify the context size!)
764 * "...the use attribute of the xsl:key element is evaluated with x as
765 " the current node and with a node list containing just x as the
766 * current node list"
767 */
768 xpctxt->contextSize = 1;
769 xpctxt->proximityPosition = 1;
770
771 for (i = 0; i < matchList->nodeNr; i++) {
772 cur = matchList->nodeTab[i];
773 if (! IS_XSLT_REAL_NODE(cur))
774 continue;
775 ctxt->node = cur;
776 xpctxt->node = cur;
777 /*
778 * Process the 'use' of the xsl:key.
779 * SPEC XSLT 1.0:
780 * "The use attribute is an expression specifying the values of
781 * the key; the expression is evaluated once for each node that
782 * matches the pattern."
783 */
784 if (useRes != NULL)
785 xmlXPathFreeObject(useRes);
786 useRes = xmlXPathCompiledEval(keyDef->usecomp, xpctxt);
787 if (useRes == NULL) {
788 xsltTransformError(ctxt, NULL, keyDef->inst,
789 "Failed to evaluate the 'use' expression.\n");
791 break;
792 }
793 if (useRes->type == XPATH_NODESET) {
794 if ((useRes->nodesetval != NULL) &&
795 (useRes->nodesetval->nodeNr != 0))
796 {
797 len = useRes->nodesetval->nodeNr;
798 str = xmlXPathCastNodeToString(useRes->nodesetval->nodeTab[0]);
799 } else {
800 continue;
801 }
802 } else {
803 len = 1;
804 if (useRes->type == XPATH_STRING) {
805 /*
806 * Consume the string value.
807 */
808 str = useRes->stringval;
809 useRes->stringval = NULL;
810 } else {
811 str = xmlXPathCastToString(useRes);
812 }
813 }
814 /*
815 * Process all strings.
816 */
817 k = 0;
818 while (1) {
819 if (str == NULL)
820 goto next_string;
821
822#ifdef WITH_XSLT_DEBUG_KEYS
824 "xsl:key : node associated to ('%s', '%s')\n", keyDef->name, str));
825#endif
826
827 keylist = xmlHashLookup(table->keys, str);
828 if (keylist == NULL) {
829 keylist = xmlXPathNodeSetCreate(cur);
830 if (keylist == NULL)
831 goto error;
832 if (xmlHashAddEntry(table->keys, str, keylist) < 0) {
833 xmlXPathFreeNodeSet(keylist);
834 goto error;
835 }
836 } else {
837 /*
838 * TODO: How do we know if this function failed?
839 */
840 xmlXPathNodeSetAdd(keylist, cur);
841 }
842 xsltSetSourceNodeFlags(ctxt, cur, XSLT_SOURCE_NODE_HAS_KEY);
843 xmlFree(str);
844 str = NULL;
845
846next_string:
847 k++;
848 if (k >= len)
849 break;
850 str = xmlXPathCastNodeToString(useRes->nodesetval->nodeTab[k]);
851 }
852 }
853
854exit:
855error:
856 ctxt->keyInitLevel--;
857 /*
858 * Restore context state.
859 */
860 xpctxt->node = oldXPNode;
861 xpctxt->doc = oldXPDoc;
862 xpctxt->nsNr = oldXPNsNr;
863 xpctxt->namespaces = oldXPNamespaces;
864 xpctxt->proximityPosition = oldXPPos;
865 xpctxt->contextSize = oldXPSize;
866
867 ctxt->node = oldContextNode;
868 ctxt->document = oldDocInfo;
869 ctxt->inst = oldInst;
870
871 if (str)
872 xmlFree(str);
873 if (useRes != NULL)
874 xmlXPathFreeObject(useRes);
875 if (matchRes != NULL)
876 xmlXPathFreeObject(matchRes);
877 return(0);
878}
static xsltKeyTablePtr xsltNewKeyTable(const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:129
int k
Definition: mpi.c:3369
#define exit(n)
Definition: config.h:202
void * xmlHashLookup(xmlHashTablePtr hash, const xmlChar *key)
Definition: hash.c:739
int xmlHashAddEntry(xmlHashTablePtr hash, const xmlChar *key, void *payload)
Definition: hash.c:621
xmlDocPtr doc
xmlNsPtr * nsList
xmlChar * match
xmlXPathCompExprPtr comp
xmlXPathCompExprPtr usecomp
xmlNodePtr inst
xsltTransformState state
xmlXPathContextPtr xpathCtxt
Definition: path.c:35
int xsltSetSourceNodeFlags(xsltTransformContextPtr ctxt, xmlNodePtr node, int flags)
Definition: xsltutils.c:1961
@ XSLT_TRACE_KEYS
Definition: xsltutils.h:123
#define IS_XSLT_REAL_NODE(n)
Definition: xsltutils.h:68

Referenced by xsltInitCtxtKeys(), and xsltInitDocKeyTable().

◆ xsltIsBlank()

XSLTPUBFUN int XSLTCALL xsltIsBlank ( xmlChar str)

xsltIsBlank: @str: a string

Check if a string is ignorable

Returns 1 if the string is NULL or made of blanks chars, 0 otherwise

Definition at line 249 of file xslt.c.

249 {
250 if (str == NULL)
251 return(1);
252 while (*str != 0) {
253 if (!(IS_BLANK(*str))) return(0);
254 str++;
255 }
256 return(1);
257}
#define IS_BLANK(c)
Definition: xslt.c:102

Referenced by xsltVariableComp().

◆ xsltLoadStylesheetPI()

XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltLoadStylesheetPI ( xmlDocPtr  doc)

xsltLoadStylesheetPI: @doc: a document to process

This function tries to locate the stylesheet PI in the given document If found, and if contained within the document, it will extract that subtree to build the stylesheet to process @doc (doc itself will be modified). If found but referencing an external document it will attempt to load it and generate a stylesheet from it. In both cases, the resulting stylesheet and the document need to be freed once the transformation is done.

Returns a new XSLT stylesheet structure or NULL if not found.

Definition at line 6915 of file xslt.c.

6915 {
6916 xmlNodePtr child;
6918 xmlChar *href = NULL;
6919 xmlURIPtr URI;
6920
6922
6923 if (doc == NULL)
6924 return(NULL);
6925
6926 /*
6927 * Find the text/xml stylesheet PI id any before the root
6928 */
6929 child = doc->children;
6930 while ((child != NULL) && (child->type != XML_ELEMENT_NODE)) {
6931 if ((child->type == XML_PI_NODE) &&
6932 (xmlStrEqual(child->name, BAD_CAST "xml-stylesheet"))) {
6933 href = xsltParseStylesheetPI(child->content);
6934 if (href != NULL)
6935 break;
6936 }
6937 child = child->next;
6938 }
6939
6940 /*
6941 * If found check the href to select processing
6942 */
6943 if (href != NULL) {
6944#ifdef WITH_XSLT_DEBUG_PARSING
6946 "xsltLoadStylesheetPI : found PI href=%s\n", href);
6947#endif
6948 URI = xmlParseURI((const char *) href);
6949 if (URI == NULL) {
6951 "xml-stylesheet : href %s is not valid\n", href);
6952 xmlFree(href);
6953 return(NULL);
6954 }
6955 if ((URI->fragment != NULL) && (URI->scheme == NULL) &&
6956 (URI->opaque == NULL) && (URI->authority == NULL) &&
6957 (URI->server == NULL) && (URI->user == NULL) &&
6958 (URI->path == NULL) && (URI->query == NULL)) {
6959 xmlAttrPtr ID;
6960
6961#ifdef WITH_XSLT_DEBUG_PARSING
6963 "xsltLoadStylesheetPI : Reference to ID %s\n", href);
6964#endif
6965 if (URI->fragment[0] == '#')
6966 ID = xmlGetID(doc, (const xmlChar *) &(URI->fragment[1]));
6967 else
6968 ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
6969 if (ID == NULL) {
6971 "xml-stylesheet : no ID %s found\n", URI->fragment);
6972 } else {
6973 xmlDocPtr fake;
6974 xmlNodePtr subtree, newtree;
6975 xmlNsPtr ns;
6976
6977#ifdef WITH_XSLT_DEBUG
6979 "creating new document from %s for embedded stylesheet\n",
6980 doc->URL);
6981#endif
6982 /*
6983 * move the subtree in a new document passed to
6984 * the stylesheet analyzer
6985 */
6986 subtree = ID->parent;
6987 fake = xmlNewDoc(NULL);
6988 if (fake != NULL) {
6989 /*
6990 * Should the dictionary still be shared even though
6991 * the nodes are being copied rather than moved?
6992 */
6993 fake->dict = doc->dict;
6994 xmlDictReference(doc->dict);
6995#ifdef WITH_XSLT_DEBUG
6997 "reusing dictionary from %s for embedded stylesheet\n",
6998 doc->URL);
6999#endif
7000
7001 newtree = xmlDocCopyNode(subtree, fake, 1);
7002
7003 fake->URL = xmlNodeGetBase(doc, subtree->parent);
7004#ifdef WITH_XSLT_DEBUG
7006 "set base URI for embedded stylesheet as %s\n",
7007 fake->URL);
7008#endif
7009
7010 /*
7011 * Add all namespaces in scope of embedded stylesheet to
7012 * root element of newly created stylesheet document
7013 */
7014 while ((subtree = subtree->parent) != (xmlNodePtr)doc) {
7015 for (ns = subtree->ns; ns; ns = ns->next) {
7016 xmlNewNs(newtree, ns->href, ns->prefix);
7017 }
7018 }
7019
7020 xmlAddChild((xmlNodePtr)fake, newtree);
7022 if (ret == NULL)
7023 xmlFreeDoc(fake);
7024 }
7025 }
7026 } else {
7027 xmlChar *URL, *base;
7028
7029 /*
7030 * Reference to an external stylesheet
7031 */
7032
7033 base = xmlNodeGetBase(doc, (xmlNodePtr) doc);
7034 URL = xmlBuildURI(href, base);
7035 if (URL != NULL) {
7036#ifdef WITH_XSLT_DEBUG_PARSING
7038 "xsltLoadStylesheetPI : fetching %s\n", URL);
7039#endif
7041 xmlFree(URL);
7042 } else {
7043#ifdef WITH_XSLT_DEBUG_PARSING
7045 "xsltLoadStylesheetPI : fetching %s\n", href);
7046#endif
7048 }
7049 if (base != NULL)
7050 xmlFree(base);
7051 }
7052 xmlFreeURI(URI);
7053 xmlFree(href);
7054 }
7055 return(ret);
7056}
void xsltInitGlobals(void)
Definition: extensions.c:2282
static HWND child
Definition: cursoricon.c:298
#define ID
Definition: ruserpass.c:36
Definition: uri.h:34
char * authority
Definition: uri.h:37
char * server
Definition: uri.h:38
char * opaque
Definition: uri.h:36
char * user
Definition: uri.h:39
char * path
Definition: uri.h:41
char * scheme
Definition: uri.h:35
char * query
Definition: uri.h:42
char * fragment
Definition: uri.h:43
Definition: mxnamespace.c:38
BSTR prefix
Definition: mxnamespace.c:39
XMLPUBFUN xmlChar * xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1902
XMLPUBFUN void xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1396
XMLPUBFUN xmlURIPtr xmlParseURI(const char *str)
Definition: uri.c:947
XMLPUBFUN xmlAttrPtr xmlGetID(xmlDocPtr doc, const xmlChar *ID)
Definition: valid.c:2719
xsltStylesheetPtr xsltParseStylesheetFile(const xmlChar *filename)
Definition: xslt.c:6752
xsltStylesheetPtr xsltParseStylesheetDoc(xmlDocPtr doc)
Definition: xslt.c:6736
static xmlChar * xsltParseStylesheetPI(const xmlChar *value)
Definition: xslt.c:6824

◆ xsltNewStylesheet()

XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltNewStylesheet ( void  )

xsltNewStylesheet:

Create a new XSLT Stylesheet

Returns the newly allocated xsltStylesheetPtr or NULL in case of error

Definition at line 810 of file xslt.c.

810 {
812}
static xsltStylesheetPtr xsltNewStylesheetInternal(xsltStylesheetPtr parent)
Definition: xslt.c:745

Referenced by xsltDocumentElem().

◆ xsltNumberFormat()

XSLTPUBFUN void XSLTCALL xsltNumberFormat ( xsltTransformContextPtr  ctxt,
xsltNumberDataPtr  data,
xmlNodePtr  node 
)

xsltNumberFormat: @ctxt: the XSLT transformation context @data: the formatting information @node: the data to format

Convert one number.

Definition at line 744 of file numbers.c.

747{
748 xmlBufferPtr output = NULL;
749 int amount, i;
750 double number;
751 xsltFormat tokens;
752
753 if (data->format != NULL) {
754 xsltNumberFormatTokenize(data->format, &tokens);
755 }
756 else {
758
759 /* The format needs to be recomputed each time */
760 if (data->has_format == 0)
761 return;
763 (const xmlChar *) "format",
765 if (format == NULL)
766 return;
769 }
770
771 output = xmlBufferCreate();
772 if (output == NULL)
773 goto XSLT_NUMBER_FORMAT_END;
774
775 /*
776 * Evaluate the XPath expression to find the value(s)
777 */
778 if (data->value) {
779 amount = xsltNumberFormatGetValue(ctxt->xpathCtxt,
780 node,
781 data->value,
782 &number);
783 if (amount == 1) {
785 &number,
786 1,
787 &tokens,
788 output);
789 }
790
791 } else if (data->level) {
792
793 if (xmlStrEqual(data->level, (const xmlChar *) "single")) {
795 node,
796 data->countPat,
797 data->fromPat,
798 &number,
799 1);
800 if (amount == 1) {
802 &number,
803 1,
804 &tokens,
805 output);
806 }
807 } else if (xmlStrEqual(data->level, (const xmlChar *) "multiple")) {
808 double numarray[1024];
809 int max = sizeof(numarray)/sizeof(numarray[0]);
811 node,
812 data->countPat,
813 data->fromPat,
814 numarray,
815 max);
816 if (amount > 0) {
818 numarray,
819 amount,
820 &tokens,
821 output);
822 }
823 } else if (xmlStrEqual(data->level, (const xmlChar *) "any")) {
824 amount = xsltNumberFormatGetAnyLevel(ctxt,
825 node,
826 data->countPat,
827 data->fromPat,
828 &number);
829 if (amount > 0) {
831 &number,
832 1,
833 &tokens,
834 output);
835 }
836 }
837
838 /*
839 * Unlike `match` patterns, `count` and `from` patterns can contain
840 * variable references, so we have to clear the pattern match
841 * cache if the "direct" matching algorithm was used.
842 */
843 if (data->countPat != NULL)
844 xsltCompMatchClearCache(ctxt, data->countPat);
845 if (data->fromPat != NULL)
846 xsltCompMatchClearCache(ctxt, data->fromPat);
847 }
848 /* Insert number as text node */
849 xsltCopyTextString(ctxt, ctxt->insert, xmlBufferContent(output), 0);
850
851 xmlBufferFree(output);
852
853XSLT_NUMBER_FORMAT_END:
854 if (tokens.start != NULL)
855 xmlFree(tokens.start);
856 if (tokens.end != NULL)
857 xmlFree(tokens.end);
858 for (i = 0;i < tokens.nTokens;i++) {
859 if (tokens.tokens[i].separator != NULL)
860 xmlFree(tokens.tokens[i].separator);
861 }
862}
static void xsltNumberFormatInsertNumbers(xsltNumberDataPtr data, double *numbers, int numbers_max, xsltFormatPtr tokens, xmlBufferPtr buffer)
Definition: numbers.c:443
static int xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xsltCompMatchPtr fromPat, double *array, int max)
Definition: numbers.c:650
static int xsltNumberFormatGetValue(xmlXPathContextPtr context, xmlNodePtr node, const xmlChar *value, double *number)
Definition: numbers.c:708
static void xsltNumberFormatTokenize(const xmlChar *format, xsltFormatPtr tokens)
Definition: numbers.c:335
static int xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xsltCompMatchPtr fromPat, double *array)
Definition: numbers.c:596
void xsltCompMatchClearCache(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp)
Definition: pattern.c:1155
xmlNodePtr xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int noescape)
Definition: transform.c:881
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
xmlChar * separator
Definition: numbers.c:47
xsltFormatToken tokens[MAX_TOKENS]
Definition: numbers.c:56
xmlChar * start
Definition: numbers.c:55
xmlChar * end
Definition: numbers.c:58
int nTokens
Definition: numbers.c:57
#define max(a, b)
Definition: svc.c:63
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:410
#define XSLT_NAMESPACE
Definition: xslt.h:46

Referenced by xsltNumber().

◆ xsltParseStylesheetDoc()

XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetDoc ( xmlDocPtr  doc)

xsltParseStylesheetDoc: @doc: an xmlDoc parsed XML

parse an XSLT stylesheet, building the associated structures. doc is kept as a reference within the returned stylesheet, so changes to doc after the parsing will be reflected when the stylesheet is applied, and the doc is automatically freed when the stylesheet is closed.

Returns a new XSLT stylesheet structure.

Definition at line 6736 of file xslt.c.

6736 {
6738
6740}
xsltStylesheetPtr xsltParseStylesheetImportedDoc(xmlDocPtr doc, xsltStylesheetPtr parentStyle)
Definition: xslt.c:6555

Referenced by node_transform_node_params(), xsltLoadStylesheetPI(), and xsltParseStylesheetFile().

◆ xsltParseStylesheetFile()

XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetFile ( const xmlChar filename)

xsltParseStylesheetFile: @filename: the filename/URL to the stylesheet

Load and parse an XSLT stylesheet

Returns a new XSLT stylesheet structure.

Definition at line 6752 of file xslt.c.

6752 {
6755 xmlDocPtr doc;
6756
6758
6759 if (filename == NULL)
6760 return(NULL);
6761
6762#ifdef WITH_XSLT_DEBUG_PARSING
6764 "xsltParseStylesheetFile : parse %s\n", filename);
6765#endif
6766
6767 /*
6768 * Security framework check
6769 */
6771 if (sec != NULL) {
6772 int res;
6773
6774 res = xsltCheckRead(sec, NULL, filename);
6775 if (res <= 0) {
6776 if (res == 0)
6778 "xsltParseStylesheetFile: read rights for %s denied\n",
6779 filename);
6780 return(NULL);
6781 }
6782 }
6783
6786 if (doc == NULL) {
6788 "xsltParseStylesheetFile : cannot parse %s\n", filename);
6789 return(NULL);
6790 }
6792 if (ret == NULL) {
6793 xmlFreeDoc(doc);
6794 return(NULL);
6795 }
6796
6797 return(ret);
6798}
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:180
int xsltCheckRead(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:419
xsltDocLoaderFunc xsltDocDefaultLoader
Definition: documents.c:108
@ XSLT_LOAD_START
Definition: documents.h:54
GLuint res
Definition: glext.h:9613
const char * filename
Definition: ioapi.h:137
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54

Referenced by xsltLoadStylesheetPI().

◆ xsltParseStylesheetImportedDoc()

XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetImportedDoc ( xmlDocPtr  doc,
xsltStylesheetPtr  parentStyle 
)

xsltParseStylesheetImportedDoc: @doc: an xmlDoc parsed XML @parentStyle: pointer to the parent stylesheet (if it exists)

parse an XSLT stylesheet building the associated structures except the processing not needed for imported documents.

Returns a new XSLT stylesheet structure.

Definition at line 6555 of file xslt.c.

6556 {
6557 xsltStylesheetPtr retStyle;
6558
6559 if (doc == NULL)
6560 return(NULL);
6561
6562 retStyle = xsltNewStylesheetInternal(parentStyle);
6563 if (retStyle == NULL)
6564 return(NULL);
6565
6566 if (xsltParseStylesheetUser(retStyle, doc) != 0) {
6567 xsltFreeStylesheet(retStyle);
6568 return(NULL);
6569 }
6570
6571 return(retStyle);
6572}
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:965
int xsltParseStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc)
Definition: xslt.c:6584

Referenced by xsltParseStylesheetDoc(), and xsltParseStylesheetImport().

◆ xsltParseStylesheetOutput()

XSLTPUBFUN void XSLTCALL xsltParseStylesheetOutput ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)

xsltParseStylesheetOutput: @style: the XSLT stylesheet @cur: the "output" element

parse an XSLT stylesheet output element and record information related to the stylesheet output

Definition at line 1185 of file xslt.c.

1186{
1187 xmlChar *elements,
1188 *prop;
1190 *end;
1191
1192 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
1193 return;
1194
1195 prop = xmlGetNsProp(cur, (const xmlChar *) "version", NULL);
1196 if (prop != NULL) {
1197 if (style->version != NULL)
1198 xmlFree(style->version);
1199 style->version = prop;
1200 }
1201
1202 prop = xmlGetNsProp(cur, (const xmlChar *) "encoding", NULL);
1203 if (prop != NULL) {
1204 if (style->encoding != NULL)
1205 xmlFree(style->encoding);
1206 style->encoding = prop;
1207 }
1208
1209 /* relaxed to support xt:document
1210 * TODO KB: What does "relaxed to support xt:document" mean?
1211 */
1212 prop = xmlGetNsProp(cur, (const xmlChar *) "method", NULL);
1213 if (prop != NULL) {
1214 const xmlChar *URI;
1215
1216 if (style->method != NULL)
1217 xmlFree(style->method);
1218 style->method = NULL;
1219 if (style->methodURI != NULL)
1220 xmlFree(style->methodURI);
1221 style->methodURI = NULL;
1222
1223 /*
1224 * TODO: Don't use xsltGetQNameURI().
1225 */
1226 URI = xsltGetQNameURI(cur, &prop);
1227 if (prop == NULL) {
1228 if (style != NULL) style->errors++;
1229 } else if (URI == NULL) {
1230 if ((xmlStrEqual(prop, (const xmlChar *) "xml")) ||
1231 (xmlStrEqual(prop, (const xmlChar *) "html")) ||
1232 (xmlStrEqual(prop, (const xmlChar *) "text"))) {
1233 style->method = prop;
1234 } else {
1236 "invalid value for method: %s\n", prop);
1237 if (style != NULL) style->warnings++;
1238 xmlFree(prop);
1239 }
1240 } else {
1241 style->method = prop;
1242 style->methodURI = xmlStrdup(URI);
1243 }
1244 }
1245
1246 prop = xmlGetNsProp(cur, (const xmlChar *) "doctype-system", NULL);
1247 if (prop != NULL) {
1248 if (style->doctypeSystem != NULL)
1249 xmlFree(style->doctypeSystem);
1250 style->doctypeSystem = prop;
1251 }
1252
1253 prop = xmlGetNsProp(cur, (const xmlChar *) "doctype-public", NULL);
1254 if (prop != NULL) {
1255 if (style->doctypePublic != NULL)
1256 xmlFree(style->doctypePublic);
1257 style->doctypePublic = prop;
1258 }
1259
1260 prop = xmlGetNsProp(cur, (const xmlChar *) "standalone", NULL);
1261 if (prop != NULL) {
1262 if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
1263 style->standalone = 1;
1264 } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
1265 style->standalone = 0;
1266 } else {
1268 "invalid value for standalone: %s\n", prop);
1269 style->errors++;
1270 }
1271 xmlFree(prop);
1272 }
1273
1274 prop = xmlGetNsProp(cur, (const xmlChar *) "indent", NULL);
1275 if (prop != NULL) {
1276 if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
1277 style->indent = 1;
1278 } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
1279 style->indent = 0;
1280 } else {
1282 "invalid value for indent: %s\n", prop);
1283 style->errors++;
1284 }
1285 xmlFree(prop);
1286 }
1287
1288 prop = xmlGetNsProp(cur, (const xmlChar *) "omit-xml-declaration", NULL);
1289 if (prop != NULL) {
1290 if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
1291 style->omitXmlDeclaration = 1;
1292 } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
1293 style->omitXmlDeclaration = 0;
1294 } else {
1296 "invalid value for omit-xml-declaration: %s\n",
1297 prop);
1298 style->errors++;
1299 }
1300 xmlFree(prop);
1301 }
1302
1303 elements = xmlGetNsProp(cur, (const xmlChar *) "cdata-section-elements",
1304 NULL);
1305 if (elements != NULL) {
1306 if (style->cdataSection == NULL)
1307 style->cdataSection = xmlHashCreate(10);
1308 if (style->cdataSection == NULL) {
1309 xmlFree(elements);
1310 return;
1311 }
1312
1313 element = elements;
1314 while (*element != 0) {
1315 while (IS_BLANK(*element))
1316 element++;
1317 if (*element == 0)
1318 break;
1319 end = element;
1320 while ((*end != 0) && (!IS_BLANK(*end)))
1321 end++;
1323 if (element) {
1324#ifdef WITH_XSLT_DEBUG_PARSING
1326 "add cdata section output element %s\n",
1327 element);
1328#endif
1329 if (xmlValidateQName(BAD_CAST element, 0) != 0) {
1331 "Attribute 'cdata-section-elements': The value "
1332 "'%s' is not a valid QName.\n", element);
1334 style->errors++;
1335 } else {
1336 const xmlChar *URI;
1337
1338 /*
1339 * TODO: Don't use xsltGetQNameURI().
1340 */
1341 URI = xsltGetQNameURI(cur, &element);
1342 if (element == NULL) {
1343 /*
1344 * TODO: We'll report additionally an error
1345 * via the stylesheet's error handling.
1346 */
1348 "Attribute 'cdata-section-elements': "
1349 "Not a valid QName.\n");
1350 style->errors++;
1351 } else {
1352 xmlNsPtr ns;
1353
1354 /*
1355 * XSLT-1.0 "Each QName is expanded into an
1356 * expanded-name using the namespace declarations in
1357 * effect on the xsl:output element in which the QName
1358 * occurs; if there is a default namespace, it is used
1359 * for QNames that do not have a prefix"
1360 * NOTE: Fix of bug #339570.
1361 */
1362 if (URI == NULL) {
1363 ns = xmlSearchNs(style->doc, cur, NULL);
1364 if (ns != NULL)
1365 URI = ns->href;
1366 }
1367 xmlHashAddEntry2(style->cdataSection, element, URI,
1368 (void *) "cdata");
1370 }
1371 }
1372 }
1373 element = end;
1374 }
1375 xmlFree(elements);
1376 }
1377
1378 prop = xmlGetNsProp(cur, (const xmlChar *) "media-type", NULL);
1379 if (prop != NULL) {
1380 if (style->mediaType)
1381 xmlFree(style->mediaType);
1382 style->mediaType = prop;
1383 }
1384 if (cur->children != NULL) {
1385 xsltParseContentError(style, cur->children);
1386 }
1387}
GLuint GLuint end
Definition: gl.h:1545
xmlHashTablePtr xmlHashCreate(int size)
Definition: hash.c:160
int xmlHashAddEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, void *payload)
Definition: hash.c:639
static void xsltParseContentError(xsltStylesheetPtr style, xmlNodePtr node)
Definition: xslt.c:120
const xmlChar * xsltGetQNameURI(xmlNodePtr node, xmlChar **name)
Definition: xsltutils.c:837

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetProcess()

XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetProcess ( xsltStylesheetPtr  ret,
xmlDocPtr  doc 
)

xsltParseStylesheetProcess: @ret: the XSLT stylesheet (the current stylesheet-level) @doc: and xmlDoc parsed XML

Parses an XSLT stylesheet, adding the associated structures. Called by: xsltParseStylesheetImportedDoc() (xslt.c) xsltParseStylesheetInclude() (imports.c)

Returns the value of the @style parameter if everything went right, NULL if something went amiss.

Definition at line 6447 of file xslt.c.

6447 {
6448 xmlNodePtr cur;
6449
6451
6452 if (doc == NULL)
6453 return(NULL);
6454 if (ret == NULL)
6455 return(ret);
6456
6457 /*
6458 * First steps, remove blank nodes,
6459 * locate the xsl:stylesheet element and the
6460 * namespace declaration.
6461 */
6462 cur = xmlDocGetRootElement(doc);
6463 if (cur == NULL) {
6464 xsltTransformError(NULL, ret, (xmlNodePtr) doc,
6465 "xsltParseStylesheetProcess : empty stylesheet\n");
6466 return(NULL);
6467 }
6468
6469 if ((IS_XSLT_ELEM(cur)) &&
6470 ((IS_XSLT_NAME(cur, "stylesheet")) ||
6471 (IS_XSLT_NAME(cur, "transform")))) {
6472#ifdef WITH_XSLT_DEBUG_PARSING
6474 "xsltParseStylesheetProcess : found stylesheet\n");
6475#endif
6476 ret->literal_result = 0;
6479 } else {
6482 ret->literal_result = 1;
6483 }
6484 if (!ret->nopreproc) {
6486 }
6487 if (ret->literal_result == 0) {
6489 } else {
6490 xmlChar *prop;
6491 xsltTemplatePtr template;
6492
6493 /*
6494 * the document itself might be the template, check xsl:version
6495 */
6496 prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
6497 if (prop == NULL) {
6499 "xsltParseStylesheetProcess : document is not a stylesheet\n");
6500 return(NULL);
6501 }
6502
6503#ifdef WITH_XSLT_DEBUG_PARSING
6505 "xsltParseStylesheetProcess : document is stylesheet\n");
6506#endif
6507
6508 if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
6509 (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
6511 "xsl:version: only 1.1 features are supported\n");
6512 ret->forwards_compatible = 1;
6513 ret->warnings++;
6514 }
6515 xmlFree(prop);
6516
6517 /*
6518 * Create and link the template
6519 */
6520 template = xsltNewTemplate();
6521 if (template == NULL) {
6522 return(NULL);
6523 }
6524 template->next = ret->templates;
6525 ret->templates = template;
6526 template->match = xmlStrdup((const xmlChar *)"/");
6527
6528 /*
6529 * parse the content and register the pattern
6530 */
6531 xsltParseTemplateContent(ret, (xmlNodePtr) doc);
6532 template->elem = (xmlNodePtr) doc;
6533 template->content = doc->children;
6534 xsltAddTemplate(ret, template, NULL, NULL);
6535 ret->literal_result = 1;
6536 }
6537
6538 return(ret);
6539}
int xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, const xmlChar *mode, const xmlChar *modeURI)
Definition: pattern.c:2030
static void xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top)
Definition: xslt.c:6106
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4894
static void xsltPreprocessStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:3477
static int xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1743
static void xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1607
static xsltTemplatePtr xsltNewTemplate(void)
Definition: xslt.c:409
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:60
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:51

Referenced by xsltParseStylesheetInclude(), and xsltParseStylesheetUser().

◆ xsltParseStylesheetUser()

XSLTPUBFUN int XSLTCALL xsltParseStylesheetUser ( xsltStylesheetPtr  style,
xmlDocPtr  doc 
)

xsltParseStylesheetUser: @style: pointer to the stylesheet @doc: an xmlDoc parsed XML

Parse an XSLT stylesheet with a user-provided stylesheet struct.

Returns 0 if successful, -1 in case of error.

Definition at line 6584 of file xslt.c.

6584 {
6585 if ((style == NULL) || (doc == NULL))
6586 return(-1);
6587
6588 /*
6589 * Adjust the string dict.
6590 */
6591 if (doc->dict != NULL) {
6592 xmlDictFree(style->dict);
6593 style->dict = doc->dict;
6594#ifdef WITH_XSLT_DEBUG
6596 "reusing dictionary from %s for stylesheet\n",
6597 doc->URL);
6598#endif
6599 xmlDictReference(style->dict);
6600 }
6601
6602 /*
6603 * TODO: Eliminate xsltGatherNamespaces(); we must not restrict
6604 * the stylesheet to containt distinct namespace prefixes.
6605 */
6607
6608#ifdef XSLT_REFACTORED
6609 {
6610 xsltCompilerCtxtPtr cctxt;
6611 xsltStylesheetPtr oldCurSheet;
6612
6613 if (style->parent == NULL) {
6614 xsltPrincipalStylesheetDataPtr principalData;
6615 /*
6616 * Create extra data for the principal stylesheet.
6617 */
6618 principalData = xsltNewPrincipalStylesheetData();
6619 if (principalData == NULL) {
6620 return(-1);
6621 }
6622 style->principalData = principalData;
6623 /*
6624 * Create the compilation context
6625 * ------------------------------
6626 * (only once; for the principal stylesheet).
6627 * This is currently the only function where the
6628 * compilation context is created.
6629 */
6630 cctxt = xsltCompilationCtxtCreate(style);
6631 if (cctxt == NULL) {
6632 return(-1);
6633 }
6634 style->compCtxt = (void *) cctxt;
6635 cctxt->style = style;
6636 cctxt->dict = style->dict;
6637 cctxt->psData = principalData;
6638 /*
6639 * Push initial dummy node info.
6640 */
6641 cctxt->depth = -1;
6642 xsltCompilerNodePush(cctxt, (xmlNodePtr) doc);
6643 } else {
6644 /*
6645 * Imported stylesheet.
6646 */
6647 cctxt = style->parent->compCtxt;
6648 style->compCtxt = cctxt;
6649 }
6650 /*
6651 * Save the old and set the current stylesheet structure in the
6652 * compilation context.
6653 */
6654 oldCurSheet = cctxt->style;
6655 cctxt->style = style;
6656
6657 style->doc = doc;
6659
6660 cctxt->style = oldCurSheet;
6661 if (style->parent == NULL) {
6662 /*
6663 * Pop the initial dummy node info.
6664 */
6665 xsltCompilerNodePop(cctxt, (xmlNodePtr) doc);
6666 } else {
6667 /*
6668 * Clear the compilation context of imported
6669 * stylesheets.
6670 * TODO: really?
6671 */
6672 /* style->compCtxt = NULL; */
6673 }
6674
6675#ifdef XSLT_REFACTORED_XSLT_NSCOMP
6676 if (style->errors != 0) {
6677 /*
6678 * Restore all changes made to namespace URIs of ns-decls.
6679 */
6680 if (cctxt->psData->nsMap)
6681 xsltRestoreDocumentNamespaces(cctxt->psData->nsMap, doc);
6682 }
6683#endif
6684
6685 if (style->parent == NULL) {
6686 xsltCompilationCtxtFree(style->compCtxt);
6687 style->compCtxt = NULL;
6688 }
6689 }
6690
6691#else /* XSLT_REFACTORED */
6692 /*
6693 * Old behaviour.
6694 */
6695 style->doc = doc;
6696 if (xsltParseStylesheetProcess(style, doc) == NULL) {
6697 style->doc = NULL;
6698 return(-1);
6699 }
6700#endif /* else of XSLT_REFACTORED */
6701
6702 if (style->parent == NULL)
6704
6705 if (style->errors != 0) {
6706 /*
6707 * Detach the doc from the stylesheet; otherwise the doc
6708 * will be freed in xsltFreeStylesheet().
6709 */
6710 style->doc = NULL;
6711 /*
6712 * Cleanup the doc if its the main stylesheet.
6713 */
6714 if (style->parent == NULL)
6715 xsltCleanupStylesheetTree(doc, xmlDocGetRootElement(doc));
6716 return(-1);
6717 }
6718
6719 return(0);
6720}
void xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style)
Definition: attributes.c:701
xsltStylesheetPtr xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc)
Definition: xslt.c:6447
static void xsltGatherNamespaces(xsltStylesheetPtr style)
Definition: xslt.c:3682

Referenced by xsltParseStylesheetImportedDoc().

◆ xsltParseTemplateContent()

XSLTPUBFUN void XSLTCALL xsltParseTemplateContent ( xsltStylesheetPtr  style,
xmlNodePtr  templ 
)

xsltParseTemplateContent: @style: the XSLT stylesheet @templ: the container node (can be a document for literal results)

parse a template content-model Clean-up the template content from unwanted ignorable blank nodes and process xslt:text

Definition at line 4894 of file xslt.c.

4894 {
4895 xmlNodePtr cur, delete;
4896
4897 if ((style == NULL) || (templ == NULL) ||
4898 (templ->type == XML_NAMESPACE_DECL)) return;
4899
4900 /*
4901 * This content comes from the stylesheet
4902 * For stylesheets, the set of whitespace-preserving
4903 * element names consists of just xsl:text.
4904 */
4905 cur = templ->children;
4906 delete = NULL;
4907 while (cur != NULL) {
4908 style->principal->opCount += 1;
4909
4910 if (delete != NULL) {
4911#ifdef WITH_XSLT_DEBUG_BLANKS
4913 "xsltParseTemplateContent: removing text\n");
4914#endif
4915 xmlUnlinkNode(delete);
4916 xmlFreeNode(delete);
4917 delete = NULL;
4918 }
4919 if (IS_XSLT_ELEM(cur)) {
4921
4922 if (IS_XSLT_NAME(cur, "text")) {
4923 /*
4924 * TODO: Processing of xsl:text should be moved to
4925 * xsltPreprocessStylesheet(), since otherwise this
4926 * will be performed for every multiply included
4927 * stylesheet; i.e. this here is not skipped with
4928 * the use of the style->nopreproc flag.
4929 */
4930 if (cur->children != NULL) {
4931 xmlChar *prop;
4932 xmlNodePtr text = cur->children, next;
4933 int noesc = 0;
4934
4935 prop = xmlGetNsProp(cur,
4936 (const xmlChar *)"disable-output-escaping",
4937 NULL);
4938 if (prop != NULL) {
4939#ifdef WITH_XSLT_DEBUG_PARSING
4941 "Disable escaping: %s\n", text->content);
4942#endif
4943 if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
4944 noesc = 1;
4945 } else if (!xmlStrEqual(prop,
4946 (const xmlChar *)"no")){
4948 "xsl:text: disable-output-escaping allows only yes or no\n");
4949 style->warnings++;
4950
4951 }
4952 xmlFree(prop);
4953 }
4954
4955 while (text != NULL) {
4956 if (text->type == XML_COMMENT_NODE) {
4957 text = text->next;
4958 continue;
4959 }
4960 if ((text->type != XML_TEXT_NODE) &&
4961 (text->type != XML_CDATA_SECTION_NODE)) {
4963 "xsltParseTemplateContent: xslt:text content problem\n");
4964 style->errors++;
4965 break;
4966 }
4967 if ((noesc) && (text->type != XML_CDATA_SECTION_NODE))
4968 text->name = xmlStringTextNoenc;
4969 text = text->next;
4970 }
4971
4972 /*
4973 * replace xsl:text by the list of childs
4974 */
4975 if (text == NULL) {
4976 text = cur->children;
4977 while (text != NULL) {
4978 if ((style->internalized) &&
4979 (text->content != NULL) &&
4980 (!xmlDictOwns(style->dict, text->content))) {
4981
4982 /*
4983 * internalize the text string
4984 */
4985 if (text->doc->dict != NULL) {
4986 const xmlChar *tmp;
4987
4988 tmp = xmlDictLookup(text->doc->dict,
4989 text->content, -1);
4990 if (tmp != text->content) {
4991 xmlNodeSetContent(text, NULL);
4992 text->content = (xmlChar *) tmp;
4993 }
4994 }
4995 }
4996
4997 next = text->next;
4998 xmlUnlinkNode(text);
4999 if (xmlAddPrevSibling(cur, text) == NULL) {
5001 "out of memory\n");
5002 xmlFreeNode(text);
5003 }
5004 text = next;
5005 }
5006 }
5007 }
5008 delete = cur;
5009 goto skip_children;
5010 }
5011 }
5012 else if ((cur->ns != NULL) && (style->nsDefs != NULL) &&
5013 (xsltCheckExtPrefix(style, cur->ns->prefix)))
5014 {
5015 /*
5016 * okay this is an extension element compile it too
5017 */
5019 }
5020 else if (cur->type == XML_ELEMENT_NODE)
5021 {
5022 /*
5023 * This is an element which will be output as part of the
5024 * template exectution, precompile AVT if found.
5025 */
5026 if ((cur->ns == NULL) && (style->defaultAlias != NULL)) {
5027 cur->ns = xmlSearchNsByHref(cur->doc, cur,
5028 style->defaultAlias);
5029 }
5030 if (cur->properties != NULL) {
5031 xmlAttrPtr attr = cur->properties;
5032
5033 while (attr != NULL) {
5035 attr = attr->next;
5036 }
5037 }
5038 }
5039 /*
5040 * Skip to next node
5041 */
5042 if (cur->children != NULL) {
5043 if (cur->children->type != XML_ENTITY_DECL) {
5044 cur = cur->children;
5045 continue;
5046 }
5047 }
5048skip_children:
5049 if (cur->next != NULL) {
5050 cur = cur->next;
5051 continue;
5052 }
5053
5054 do {
5055 cur = cur->parent;
5056 if (cur == NULL)
5057 break;
5058 if (cur == templ) {
5059 cur = NULL;
5060 break;
5061 }
5062 if (cur->next != NULL) {
5063 cur = cur->next;
5064 break;
5065 }
5066 } while (cur != NULL);
5067 }
5068 if (delete != NULL) {
5069#ifdef WITH_XSLT_DEBUG_PARSING
5071 "xsltParseTemplateContent: removing text\n");
5072#endif
5073 xmlUnlinkNode(delete);
5074 xmlFreeNode(delete);
5075 delete = NULL;
5076 }
5077
5078 /*
5079 * Skip the first params
5080 */
5081 cur = templ->children;
5082 while (cur != NULL) {
5083 if ((IS_XSLT_ELEM(cur)) && (!(IS_XSLT_NAME(cur, "param"))))
5084 break;
5085 cur = cur->next;
5086 }
5087
5088 /*
5089 * Browse the remainder of the template
5090 */
5091 while (cur != NULL) {
5092 if ((IS_XSLT_ELEM(cur)) && (IS_XSLT_NAME(cur, "param"))) {
5093 xmlNodePtr param = cur;
5094
5096 "xsltParseTemplateContent: ignoring misplaced param element\n");
5097 if (style != NULL) style->warnings++;
5098 cur = cur->next;
5099 xmlUnlinkNode(param);
5100 xmlFreeNode(param);
5101 } else
5102 break;
5103 }
5104}
int xsltCheckExtPrefix(xsltStylesheetPtr style, const xmlChar *URI)
Definition: extensions.c:1183
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2191
void xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr)
Definition: attrvt.c:177
const WCHAR * text
Definition: package.c:1794
GLfloat param
Definition: glext.h:5796
XMLPUBVAR const xmlChar xmlStringTextNoenc[]
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

Referenced by xsltParseGlobalParam(), xsltParseGlobalVariable(), xsltParseStylesheetAttributeSet(), xsltParseStylesheetProcess(), and xsltParseStylesheetTemplate().

◆ xsltRegisterLocalRVT()

XSLTPUBFUN int XSLTCALL xsltRegisterLocalRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

xsltRegisterLocalRVT: @ctxt: an XSLT transformation context @RVT: a result value tree (Result Tree Fragment; xmlDocPtr)

Registers a result value tree (XSLT 1.0 term: Result Tree Fragment) in the RVT garbage collector. The fragment will be freed when the instruction which created the fragment exits.

Returns 0 in case of success and -1 in case of API or internal errors.

Definition at line 159 of file variables.c.

161{
162 if ((ctxt == NULL) || (RVT == NULL))
163 return(-1);
164
165 RVT->prev = NULL;
166 RVT->compression = XSLT_RVT_LOCAL;
167
168 /*
169 * When evaluating "select" expressions of xsl:variable
170 * and xsl:param, we need to bind newly created tree fragments
171 * to the variable itself; otherwise the fragment will be
172 * freed before we leave the scope of a var.
173 */
174 if ((ctxt->contextVariable != NULL) &&
176 {
177 RVT->next = (xmlNodePtr) XSLT_TCTXT_VARIABLE(ctxt)->fragment;
178 XSLT_TCTXT_VARIABLE(ctxt)->fragment = RVT;
179 return(0);
180 }
181 /*
182 * Store the fragment in the scope of the current instruction.
183 * If not reference by a returning instruction (like EXSLT's function),
184 * then this fragment will be freed, when the instruction exits.
185 */
186 RVT->next = (xmlNodePtr) ctxt->localRVT;
187 if (ctxt->localRVT != NULL)
188 ctxt->localRVT->prev = (xmlNodePtr) RVT;
189 ctxt->localRVT = RVT;
190 return(0);
191}
GLbitfield flags
Definition: glext.h:7161
#define XSLT_VAR_IN_SELECT
Definition: variables.c:47
#define XSLT_TCTXT_VARIABLE(c)
Definition: variables.c:48

Referenced by xsltFreeStackElem(), and xsltReleaseLocalRVTs().

◆ xsltRegisterPersistRVT()

XSLTPUBFUN int XSLTCALL xsltRegisterPersistRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

xsltRegisterPersistRVT: @ctxt: an XSLT transformation context @RVT: a result value tree (Result Tree Fragment)

Register the result value tree (XSLT 1.0 term: Result Tree Fragment) in the fragment garbage collector. The fragment will be freed when the transformation context is freed.

Returns 0 in case of success and -1 in case of error.

Definition at line 417 of file variables.c.

418{
419 if ((ctxt == NULL) || (RVT == NULL)) return(-1);
420
421 RVT->compression = XSLT_RVT_GLOBAL;
422 RVT->prev = NULL;
423 RVT->next = (xmlNodePtr) ctxt->persistRVT;
424 if (ctxt->persistRVT != NULL)
425 ctxt->persistRVT->prev = (xmlNodePtr) RVT;
426 ctxt->persistRVT = RVT;
427 return(0);
428}

Referenced by xsltEvalGlobalVariable(), and xsltReleaseLocalRVTs().

◆ xsltRegisterTmpRVT()

XSLTPUBFUN int XSLTCALL xsltRegisterTmpRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

xsltRegisterTmpRVT: @ctxt: an XSLT transformation context @RVT: a result value tree (Result Tree Fragment)

Registers the result value tree (XSLT 1.0 term: Result Tree Fragment) in the garbage collector. The fragment will be freed at the exit of the currently instantiated xsl:template. Obsolete; this function might produce massive memory overhead, since the fragment is only freed when the current xsl:template exits. Use xsltRegisterLocalRVT() instead.

Returns 0 in case of success and -1 in case of API or internal errors.

Definition at line 120 of file variables.c.

121{
122 if ((ctxt == NULL) || (RVT == NULL))
123 return(-1);
124
125 RVT->prev = NULL;
126 RVT->compression = XSLT_RVT_LOCAL;
127
128 /*
129 * We'll restrict the lifetime of user-created fragments
130 * insinde an xsl:variable and xsl:param to the lifetime of the
131 * var/param itself.
132 */
133 if (ctxt->contextVariable != NULL) {
134 RVT->next = (xmlNodePtr) XSLT_TCTXT_VARIABLE(ctxt)->fragment;
135 XSLT_TCTXT_VARIABLE(ctxt)->fragment = RVT;
136 return(0);
137 }
138
139 RVT->next = (xmlNodePtr) ctxt->tmpRVT;
140 if (ctxt->tmpRVT != NULL)
141 ctxt->tmpRVT->prev = (xmlNodePtr) RVT;
142 ctxt->tmpRVT = RVT;
143 return(0);
144}

◆ xsltReleaseRVT()

XSLTPUBFUN void XSLTCALL xsltReleaseRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

xsltReleaseRVT: @ctxt: an XSLT transformation context @RVT: a result value tree (Result Tree Fragment)

Either frees the RVT (which is an xmlDoc) or stores it in the context's cache for later reuse.

Definition at line 351 of file variables.c.

352{
353 if (RVT == NULL)
354 return;
355
356 if (ctxt && (ctxt->cache->nbRVT < 40)) {
357 /*
358 * Store the Result Tree Fragment.
359 * Free the document info.
360 */
361 if (RVT->_private != NULL) {
362 xsltFreeDocumentKeys((xsltDocumentPtr) RVT->_private);
363 xmlFree(RVT->_private);
364 RVT->_private = NULL;
365 }
366 /*
367 * Clear the document tree.
368 */
369 if (RVT->children != NULL) {
370 xmlFreeNodeList(RVT->children);
371 RVT->children = NULL;
372 RVT->last = NULL;
373 }
374 if (RVT->ids != NULL) {
375 xmlFreeIDTable((xmlIDTablePtr) RVT->ids);
376 RVT->ids = NULL;
377 }
378
379 /*
380 * Reset the ownership information.
381 */
382 RVT->compression = 0;
383
384 RVT->next = (xmlNodePtr) ctxt->cache->RVT;
385 ctxt->cache->RVT = RVT;
386
387 ctxt->cache->nbRVT++;
388
389#ifdef XSLT_DEBUG_PROFILE_CACHE
390 ctxt->cache->dbgCachedRVTs++;
391#endif
392 return;
393 }
394 /*
395 * Free it.
396 */
397 if (RVT->_private != NULL) {
398 xsltFreeDocumentKeys((xsltDocumentPtr) RVT->_private);
399 xmlFree(RVT->_private);
400 }
401 xmlFreeDoc(RVT);
402}
XMLPUBFUN void xmlFreeIDTable(xmlIDTablePtr table)
Definition: valid.c:2601

Referenced by xsltApplyXSLTTemplate(), xsltFreeStackElem(), and xsltReleaseLocalRVTs().

◆ xsltUninit()

XSLTPUBFUN void XSLTCALL xsltUninit ( void  )

xsltUninit:

Uninitializes the processor.

Definition at line 232 of file xslt.c.

232 {
233#ifdef XSLT_LOCALE_WINAPI
234 xmlFreeRMutex(xsltLocaleMutex);
235 xsltLocaleMutex = NULL;
236#endif
237 initialized = 0;
238}
XMLPUBFUN void xmlFreeRMutex(xmlRMutexPtr tok)
Definition: threads.c:275
static int initialized
Definition: xslt.c:208

Referenced by xsltCleanupGlobals().