ReactOS 0.4.15-dev-7934-g1dc8d80
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 "xsltlocale.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
 

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, void *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 1797 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 1813 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 1805 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 1835 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 74 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
@ XML_DOCUMENT_NODE
Definition: tree.h:168

XSLT_IS_RES_TREE_FRAG:

internal macro to test tree fragments

Definition at line 56 of file xsltInternals.h.

◆ XSLT_IS_TEXT_NODE

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

XSLT_IS_TEXT_NODE:

check if the argument is a text node

Definition at line 38 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 48 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 209 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 216 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 66 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 89 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 257 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 249 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 241 of file xsltInternals.h.

Typedef Documentation

◆ xsltDecimalFormat

xsltDecimalFormat:

Data structure of decimal-format.

Definition at line 304 of file xsltInternals.h.

◆ xsltDecimalFormatPtr

Definition at line 305 of file xsltInternals.h.

◆ xsltDocument

xsltDocument:

Data structure associated to a parsed document.

Definition at line 330 of file xsltInternals.h.

◆ xsltDocumentPtr

Definition at line 331 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 394 of file xsltInternals.h.

◆ xsltElemPreCompDeallocator

typedef void(* xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp)

xsltElemPreCompDeallocator: @comp: the xsltElemPreComp to free up

Deallocates an xsltElemPreComp structure.

Definition at line 464 of file xsltInternals.h.

◆ xsltElemPreCompPtr

Definition at line 395 of file xsltInternals.h.

◆ xsltKeyDef

xsltKeyDef:

Representation of an xsl:key.

Definition at line 347 of file xsltInternals.h.

◆ xsltKeyDefPtr

Definition at line 348 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 368 of file xsltInternals.h.

◆ xsltKeyTablePtr

Definition at line 369 of file xsltInternals.h.

◆ xsltRuntimeExtra

xsltRuntimeExtra:

Extra information added to the transformation context.

Definition at line 223 of file xsltInternals.h.

◆ xsltRuntimeExtraPtr

Definition at line 224 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 420 of file xsltInternals.h.

◆ xsltStackElem

Definition at line 1421 of file xsltInternals.h.

◆ xsltStackElemPtr

Definition at line 1422 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 495 of file xsltInternals.h.

◆ xsltStylePreCompPtr

Definition at line 496 of file xsltInternals.h.

◆ xsltStylesheet

Definition at line 382 of file xsltInternals.h.

◆ xsltStylesheetPtr

Definition at line 383 of file xsltInternals.h.

◆ xsltTemplate

xsltTemplate:

The in-memory structure corresponding to an XSLT Template.

Definition at line 264 of file xsltInternals.h.

◆ xsltTemplatePtr

Definition at line 265 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 386 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 407 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 423 of file xsltInternals.h.

423 {
446#ifdef XSLT_REFACTORED
447 ,
448 XSLT_FUNC_OTHERWISE,
449 XSLT_FUNC_FALLBACK,
450 XSLT_FUNC_MESSAGE,
451 XSLT_FUNC_INCLUDE,
452 XSLT_FUNC_ATTRSET,
453 XSLT_FUNC_LITERAL_RESULT_ELEMENT,
454 XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
455#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 1666 of file xsltInternals.h.

1666 {
1667 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 809 of file xslt.c.

810{
811 return(style->extrasNr++);
812}
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 825 of file xslt.c.

826{
827 if (ctxt->extrasNr >= ctxt->extrasMax) {
828 int i;
829 if (ctxt->extrasNr == 0) {
830 ctxt->extrasMax = 20;
832 xmlMalloc(ctxt->extrasMax * sizeof(xsltRuntimeExtra));
833 if (ctxt->extras == NULL) {
835 "xsltAllocateExtraCtxt: out of memory\n");
836 return(0);
837 }
838 for (i = 0;i < ctxt->extrasMax;i++) {
839 ctxt->extras[i].info = NULL;
840 ctxt->extras[i].deallocate = NULL;
841 ctxt->extras[i].val.ptr = NULL;
842 }
843
844 } else {
846
847 ctxt->extrasMax += 100;
849 ctxt->extrasMax * sizeof(xsltRuntimeExtra));
850 if (tmp == NULL) {
852 "xsltAllocateExtraCtxt: out of memory\n");
853 return(0);
854 }
855 ctxt->extras = tmp;
856 for (i = ctxt->extrasNr;i < ctxt->extrasMax;i++) {
857 ctxt->extras[i].info = NULL;
858 ctxt->extras[i].deallocate = NULL;
859 ctxt->extras[i].val.ptr = NULL;
860 }
861 }
862 }
863 return(ctxt->extrasNr++);
864}
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
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
xmlFreeFunc deallocate
union _xsltRuntimeExtra::@3470 val
xsltRuntimeExtraPtr extras
xsltRuntimeExtra * xsltRuntimeExtraPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

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 168 of file attrvt.c.

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

Referenced by xsltParseTemplateContent().

◆ xsltCreateRVT()

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 44 of file variables.c.

45{
47
48 /*
49 * Question: Why is this function public?
50 * Answer: It is called by the EXSLT module.
51 */
52 if (ctxt == NULL)
53 return(NULL);
54
55 /*
56 * Reuse a RTF from the cache if available.
57 */
58 if (ctxt->cache->RVT) {
59 container = ctxt->cache->RVT;
60 ctxt->cache->RVT = (xmlDocPtr) container->next;
61 /* clear the internal pointers */
62 container->next = NULL;
63 container->prev = NULL;
64 if (ctxt->cache->nbRVT > 0)
65 ctxt->cache->nbRVT--;
66#ifdef XSLT_DEBUG_PROFILE_CACHE
67 ctxt->cache->dbgReusedRVTs++;
68#endif
69 return(container);
70 }
71
73 if (container == NULL)
74 return(NULL);
75 container->dict = ctxt->dict;
78 container->doc = container;
79 container->parent = NULL;
80 return(container);
81}
if(dx< 0)
Definition: linetemp.h:194
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:647
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
xmlDoc * xmlDocPtr
Definition: tree.h:550
Definition: tree.h:551
xsltTransformCachePtr cache
#define XSLT_MARK_RES_TREE_FRAG(n)
Definition: xsltInternals.h:48

Referenced by xsltEvalGlobalVariable(), and xsltEvalVariable().

◆ xsltDecimalFormatGetByName()

XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL xsltDecimalFormatGetByName ( xsltStylesheetPtr  style,
xmlChar name 
)

Definition at line 334 of file xslt.c.

335{
337
338 if (name == NULL)
339 return style->decimalFormat;
340
341 while (style != NULL) {
342 for (result = style->decimalFormat->next;
343 result != NULL;
344 result = result->next) {
345 if ((result->nsUri == NULL) && xmlStrEqual(name, result->name))
346 return result;
347 }
349 }
350 return result;
351}
GLuint64EXT * result
Definition: glext.h:11304
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:251
struct define * next
Definition: compiler.c:65
Definition: name.c:39
WCHAR * name
Definition: name.c:42
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160

◆ xsltDecimalFormatGetByQName()

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

Definition at line 364 of file xslt.c.

366{
368
369 if (name == NULL)
370 return style->decimalFormat;
371
372 while (style != NULL) {
373 for (result = style->decimalFormat->next;
374 result != NULL;
375 result = result->next) {
376 if (xmlStrEqual(nsUri, result->nsUri) &&
378 return result;
379 }
381 }
382 return result;
383}

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 356 of file attrvt.c.

356 {
357 xmlChar *ret = NULL, *tmp;
358 xmlXPathCompExprPtr comp;
360 int i;
361 int str;
362
363 if ((ctxt == NULL) || (avt == NULL) || (node == NULL))
364 return(NULL);
365 str = cur->strstart;
366 for (i = 0;i < cur->nb_seg;i++) {
367 if (str) {
368 ret = xmlStrcat(ret, (const xmlChar *) cur->segments[i]);
369 } else {
370 comp = (xmlXPathCompExprPtr) cur->segments[i];
371 tmp = xsltEvalXPathStringNs(ctxt, comp, cur->nsNr, cur->nsList);
372 if (tmp != NULL) {
373 if (ret != NULL) {
374 ret = xmlStrcat(ret, tmp);
375 xmlFree(tmp);
376 } else {
377 ret = tmp;
378 }
379 }
380 }
381 str = !str;
382 }
383 return(ret);
384}
xsltAttrVT * xsltAttrVTPtr
Definition: attrvt.c:25
xmlChar * xsltEvalXPathStringNs(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp, int nsNr, xmlNsPtr *nsList)
Definition: templates.c:105
Definition: dlist.c:348
XMLPUBFUN xmlChar *XMLCALL 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 187 of file variables.c.

189{
191 "xsltExtensionInstructionResultFinalize is unsupported "
192 "in this release of libxslt.\n");
193 return(-1);
194}
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337

◆ 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 213 of file variables.c.

216{
217 return(0);
218}

◆ xsltFlagRVTs()

XSLTPUBFUN int XSLTCALL xsltFlagRVTs ( xsltTransformContextPtr  ctxt,
xmlXPathObjectPtr  obj,
void 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 237 of file variables.c.

237 {
238 int i;
240 xmlDocPtr doc;
241
242 if ((ctxt == NULL) || (obj == NULL))
243 return(-1);
244
245 /*
246 * OPTIMIZE TODO: If no local variables/params and no local tree
247 * fragments were created, then we don't need to analyse the XPath
248 * objects for tree fragments.
249 */
250
251 if ((obj->type != XPATH_NODESET) && (obj->type != XPATH_XSLT_TREE))
252 return(0);
253 if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0))
254 return(0);
255
256 for (i = 0; i < obj->nodesetval->nodeNr; i++) {
257 cur = obj->nodesetval->nodeTab[i];
258 if (cur->type == XML_NAMESPACE_DECL) {
259 /*
260 * The XPath module sets the owner element of a ns-node on
261 * the ns->next field.
262 */
263 if ((((xmlNsPtr) cur)->next != NULL) &&
264 (((xmlNsPtr) cur)->next->type == XML_ELEMENT_NODE))
265 {
266 cur = (xmlNodePtr) ((xmlNsPtr) cur)->next;
267 doc = cur->doc;
268 } else {
269 xsltTransformError(ctxt, NULL, ctxt->inst,
270 "Internal error in xsltFlagRVTs(): "
271 "Cannot retrieve the doc of a namespace node.\n");
272 return(-1);
273 }
274 } else {
275 doc = cur->doc;
276 }
277 if (doc == NULL) {
278 xsltTransformError(ctxt, NULL, ctxt->inst,
279 "Internal error in xsltFlagRVTs(): "
280 "Cannot retrieve the doc of a node.\n");
281 return(-1);
282 }
283 if (doc->name && (doc->name[0] == ' ') &&
284 doc->psvi != XSLT_RVT_GLOBAL) {
285 /*
286 * This is a result tree fragment.
287 * We store ownership information in the @psvi field.
288 * TODO: How do we know if this is a doc acquired via the
289 * document() function?
290 */
291#ifdef WITH_XSLT_DEBUG_VARIABLE
293 "Flagging RVT %p: %p -> %p\n", doc, doc->psvi, val));
294#endif
295
296 if (val == XSLT_RVT_LOCAL) {
297 if (doc->psvi == XSLT_RVT_FUNC_RESULT)
298 doc->psvi = XSLT_RVT_LOCAL;
299 } else if (val == XSLT_RVT_GLOBAL) {
300 if (doc->psvi != XSLT_RVT_LOCAL) {
302 "xsltFlagRVTs: Invalid transition %p => GLOBAL\n",
303 doc->psvi);
304 doc->psvi = XSLT_RVT_GLOBAL;
305 return(-1);
306 }
307
308 /* Will be registered as persistant in xsltReleaseLocalRVTs. */
309 doc->psvi = XSLT_RVT_GLOBAL;
310 } else if (val == XSLT_RVT_FUNC_RESULT) {
311 doc->psvi = val;
312 }
313 }
314 }
315
316 return(0);
317}
GLuint GLfloat * val
Definition: glext.h:7180
static unsigned __int64 next
Definition: rand_nt.c:6
xmlNode * xmlNodePtr
Definition: tree.h:488
@ XML_NAMESPACE_DECL
Definition: tree.h:177
@ XML_ELEMENT_NODE
Definition: tree.h:160
char * name
Definition: tree.h:554
void * psvi
Definition: tree.h:581
Definition: tree.h:489
Definition: tree.h:389
#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:117
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:125

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 941 of file numbers.c.

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

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 119 of file attrvt.c.

119 {
121
122 while (cur != NULL) {
123 next = cur->next;
125 cur = next;
126 }
127}
static void xsltFreeAttrVT(xsltAttrVTPtr avt)
Definition: attrvt.c:89

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 416 of file variables.c.

417{
419
420 if (ctxt == NULL)
421 return;
422 /*
423 * Local fragments.
424 */
425 cur = ctxt->localRVT;
426 while (cur != NULL) {
427 next = (xmlDocPtr) cur->next;
428 if (cur->_private != NULL) {
429 xsltFreeDocumentKeys(cur->_private);
430 xmlFree(cur->_private);
431 }
433 cur = next;
434 }
435 ctxt->localRVT = NULL;
436 /*
437 * User-created per-template fragments.
438 */
439 cur = ctxt->tmpRVT;
440 while (cur != NULL) {
441 next = (xmlDocPtr) cur->next;
442 if (cur->_private != NULL) {
443 xsltFreeDocumentKeys(cur->_private);
444 xmlFree(cur->_private);
445 }
447 cur = next;
448 }
449 ctxt->tmpRVT = NULL;
450 /*
451 * Global fragments.
452 */
453 cur = ctxt->persistRVT;
454 while (cur != NULL) {
455 next = (xmlDocPtr) cur->next;
456 if (cur->_private != NULL) {
457 xsltFreeDocumentKeys(cur->_private);
458 xmlFree(cur->_private);
459 }
461 cur = next;
462 }
463 ctxt->persistRVT = NULL;
464}
void xsltFreeDocumentKeys(xsltDocumentPtr idoc)
Definition: keys.c:925
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)

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 603 of file variables.c.

603 {
605
606 while (elem != NULL) {
607 next = elem->next;
609 elem = next;
610 }
611}
static size_t elem
Definition: string.c:68
static void xsltFreeStackElem(xsltStackElemPtr elem)
Definition: variables.c:542

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 950 of file xslt.c.

951{
952 if (style == NULL)
953 return;
954
955#ifdef XSLT_REFACTORED
956 /*
957 * Start with a cleanup of the main stylesheet's doc.
958 */
959 if ((style->principal == style) && (style->doc))
962#ifdef XSLT_REFACTORED_XSLT_NSCOMP
963 /*
964 * Restore changed ns-decls before freeing the document.
965 */
966 if ((style->doc != NULL) &&
967 XSLT_HAS_INTERNAL_NSMAP(style))
968 {
969 xsltRestoreDocumentNamespaces(XSLT_GET_INTERNAL_NSMAP(style),
970 style->doc);
971 }
972#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
973#else
974 /*
975 * Start with a cleanup of the main stylesheet's doc.
976 */
977 if ((style->parent == NULL) && (style->doc))
980#endif /* XSLT_REFACTORED */
981
986 xsltFreeTemplateList(style->templates);
990 /*
991 * Free documents of all included stylsheet modules of this
992 * stylesheet level.
993 */
995 /*
996 * TODO: Best time to shutdown extension stuff?
997 */
999
1000 if (style->variables != NULL)
1001 xsltFreeStackElemList(style->variables);
1002 if (style->cdataSection != NULL)
1003 xmlHashFree(style->cdataSection, NULL);
1004 if (style->stripSpaces != NULL)
1005 xmlHashFree(style->stripSpaces, NULL);
1006 if (style->nsHash != NULL)
1007 xmlHashFree(style->nsHash, NULL);
1008 if (style->exclPrefixTab != NULL)
1009 xmlFree(style->exclPrefixTab);
1010 if (style->method != NULL)
1011 xmlFree(style->method);
1012 if (style->methodURI != NULL)
1013 xmlFree(style->methodURI);
1014 if (style->version != NULL)
1015 xmlFree(style->version);
1016 if (style->encoding != NULL)
1017 xmlFree(style->encoding);
1018 if (style->doctypePublic != NULL)
1019 xmlFree(style->doctypePublic);
1020 if (style->doctypeSystem != NULL)
1021 xmlFree(style->doctypeSystem);
1022 if (style->mediaType != NULL)
1023 xmlFree(style->mediaType);
1024 if (style->attVTs)
1025 xsltFreeAVTList(style->attVTs);
1026 if (style->imports != NULL)
1027 xsltFreeStylesheetList(style->imports);
1028
1029#ifdef XSLT_REFACTORED
1030 /*
1031 * If this is the principal stylesheet, then
1032 * free its internal data.
1033 */
1034 if (style->principal == style) {
1035 if (style->principalData) {
1036 xsltFreePrincipalStylesheetData(style->principalData);
1037 style->principalData = NULL;
1038 }
1039 }
1040#endif
1041 /*
1042 * Better to free the main document of this stylesheet level
1043 * at the end - so here.
1044 */
1045 if (style->doc != NULL) {
1046 xmlFreeDoc(style->doc);
1047 }
1048
1049#ifdef WITH_XSLT_DEBUG
1051 "freeing dictionary from stylesheet\n");
1052#endif
1053 xmlDictFree(style->dict);
1054
1055 if (style->xpathCtxt != NULL)
1056 xmlXPathFreeContext(style->xpathCtxt);
1057
1058 memset(style, -1, sizeof(xsltStylesheet));
1059 xmlFree(style);
1060}
void xsltShutdownExts(xsltStylesheetPtr style)
Definition: extensions.c:1133
void xsltFreeExts(xsltStylesheetPtr style)
Definition: extensions.c:479
void xsltFreeAVTList(void *avt)
Definition: attrvt.c:119
void xsltFreeAttributeSetsHashes(xsltStylesheetPtr style)
Definition: attributes.c:1205
void xsltFreeTemplateHashes(xsltStylesheetPtr style)
Definition: pattern.c:2527
void xsltFreeStylePreComps(xsltStylesheetPtr style)
Definition: preproc.c:1937
void xsltFreeStyleDocuments(xsltStylesheetPtr style)
Definition: documents.c:193
void xsltFreeKeys(xsltStylesheetPtr style)
Definition: keys.c:185
void xsltFreeNamespaceAliasHashes(xsltStylesheetPtr style)
Definition: namespaces.c:811
XMLPUBFUN void XMLCALL xmlDictFree(xmlDictPtr dict)
Definition: dict.c:802
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:322
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
#define memset(x, y, z)
Definition: compat.h:39
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:603
static void xsltFreeTemplateList(xsltTemplatePtr template)
Definition: xslt.c:445
static void xsltFreeStylesheetList(xsltStylesheetPtr style)
Definition: xslt.c:873
static void xsltFreeDecimalFormatList(xsltStylesheetPtr self)
Definition: xslt.c:308
static int xsltCleanupStylesheetTree(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr rootElem ATTRIBUTE_UNUSED)
Definition: xslt.c:895

Referenced by 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 535 of file keys.c.

536{
538 xsltKeyDefPtr keyd;
540
541 if (ctxt == NULL)
542 return(-1);
543
544#ifdef KEY_INIT_DEBUG
545fprintf(stderr, "xsltInitAllDocKeys %d %d\n",
546 ctxt->document->nbKeysComputed, ctxt->nbKeys);
547#endif
548
549 if (ctxt->document->nbKeysComputed == ctxt->nbKeys)
550 return(0);
551
552
553 /*
554 * TODO: This could be further optimized
555 */
556 style = ctxt->style;
557 while (style) {
558 keyd = (xsltKeyDefPtr) style->keys;
559 while (keyd != NULL) {
560#ifdef KEY_INIT_DEBUG
561fprintf(stderr, "Init key %s\n", keyd->name);
562#endif
563 /*
564 * Check if keys with this QName have been already
565 * computed.
566 */
568 while (table) {
569 if (((keyd->nameURI != NULL) == (table->nameURI != NULL)) &&
570 xmlStrEqual(keyd->name, table->name) &&
571 xmlStrEqual(keyd->nameURI, table->nameURI))
572 {
573 break;
574 }
575 table = table->next;
576 }
577 if (table == NULL) {
578 /*
579 * Keys with this QName have not been yet computed.
580 */
581 xsltInitDocKeyTable(ctxt, keyd->name, keyd->nameURI);
582 }
583 keyd = keyd->next;
584 }
586 }
587#ifdef KEY_INIT_DEBUG
588fprintf(stderr, "xsltInitAllDocKeys: done\n");
589#endif
590 return(0);
591}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static int xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:479
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 604 of file keys.c.

606{
607 int i, len, k;
608 xmlNodeSetPtr matchList = NULL, keylist;
609 xmlXPathObjectPtr matchRes = NULL, useRes = NULL;
610 xmlChar *str = NULL;
612 xmlNodePtr oldInst, cur;
613 xmlNodePtr oldContextNode;
614 xsltDocumentPtr oldDocInfo;
615 int oldXPPos, oldXPSize;
616 xmlNodePtr oldXPNode;
617 xmlDocPtr oldXPDoc;
618 int oldXPNsNr;
619 xmlNsPtr *oldXPNamespaces;
620 xmlXPathContextPtr xpctxt;
621
622#ifdef KEY_INIT_DEBUG
623fprintf(stderr, "xsltInitCtxtKey %s : %d\n", keyDef->name, ctxt->keyInitLevel);
624#endif
625
626 if ((keyDef->comp == NULL) || (keyDef->usecomp == NULL))
627 return(-1);
628
629 /*
630 * Detect recursive keys
631 */
632 if (ctxt->keyInitLevel > ctxt->nbKeys) {
633#ifdef WITH_XSLT_DEBUG_KEYS
636 "xsltInitCtxtKey: key definition of %s is recursive\n",
637 keyDef->name));
638#endif
639 xsltTransformError(ctxt, NULL, keyDef->inst,
640 "Key definition for %s is recursive\n", keyDef->name);
642 return(-1);
643 }
644 ctxt->keyInitLevel++;
645
646 xpctxt = ctxt->xpathCtxt;
647 idoc->nbKeysComputed++;
648 /*
649 * Save context state.
650 */
651 oldInst = ctxt->inst;
652 oldDocInfo = ctxt->document;
653 oldContextNode = ctxt->node;
654
655 oldXPNode = xpctxt->node;
656 oldXPDoc = xpctxt->doc;
657 oldXPPos = xpctxt->proximityPosition;
658 oldXPSize = xpctxt->contextSize;
659 oldXPNsNr = xpctxt->nsNr;
660 oldXPNamespaces = xpctxt->namespaces;
661
662 /*
663 * Set up contexts.
664 */
665 ctxt->document = idoc;
666 ctxt->node = (xmlNodePtr) idoc->doc;
667 ctxt->inst = keyDef->inst;
668
669 xpctxt->doc = idoc->doc;
670 xpctxt->node = (xmlNodePtr) idoc->doc;
671 /* TODO : clarify the use of namespaces in keys evaluation */
672 xpctxt->namespaces = keyDef->nsList;
673 xpctxt->nsNr = keyDef->nsNr;
674
675 /*
676 * Evaluate the 'match' expression of the xsl:key.
677 * TODO: The 'match' is a *pattern*.
678 */
679 matchRes = xmlXPathCompiledEval(keyDef->comp, xpctxt);
680 if (matchRes == NULL) {
681
682#ifdef WITH_XSLT_DEBUG_KEYS
684 "xsltInitCtxtKey: %s evaluation failed\n", keyDef->match));
685#endif
686 xsltTransformError(ctxt, NULL, keyDef->inst,
687 "Failed to evaluate the 'match' expression.\n");
689 goto error;
690 } else {
691 if (matchRes->type == XPATH_NODESET) {
692 matchList = matchRes->nodesetval;
693
694#ifdef WITH_XSLT_DEBUG_KEYS
695 if (matchList != NULL)
697 "xsltInitCtxtKey: %s evaluates to %d nodes\n",
698 keyDef->match, matchList->nodeNr));
699#endif
700 } else {
701 /*
702 * Is not a node set, but must be.
703 */
704#ifdef WITH_XSLT_DEBUG_KEYS
706 "xsltInitCtxtKey: %s is not a node set\n", keyDef->match));
707#endif
708 xsltTransformError(ctxt, NULL, keyDef->inst,
709 "The 'match' expression did not evaluate to a node set.\n");
711 goto error;
712 }
713 }
714 if ((matchList == NULL) || (matchList->nodeNr <= 0))
715 goto exit;
716
721 table = (xsltKeyTablePtr) idoc->keys;
722 while (table != NULL) {
723 if (xmlStrEqual(table->name, keyDef->name) &&
724 (((keyDef->nameURI == NULL) && (table->nameURI == NULL)) ||
725 ((keyDef->nameURI != NULL) && (table->nameURI != NULL) &&
726 (xmlStrEqual(table->nameURI, keyDef->nameURI)))))
727 break;
728 table = table->next;
729 }
734 if (table == NULL) {
735 table = xsltNewKeyTable(keyDef->name, keyDef->nameURI);
736 if (table == NULL)
737 goto error;
738 table->next = idoc->keys;
739 idoc->keys = table;
740 }
741
742 /*
743 * SPEC XSLT 1.0 (XSLT 2.0 does not clarify the context size!)
744 * "...the use attribute of the xsl:key element is evaluated with x as
745 " the current node and with a node list containing just x as the
746 * current node list"
747 */
748 xpctxt->contextSize = 1;
749 xpctxt->proximityPosition = 1;
750
751 for (i = 0; i < matchList->nodeNr; i++) {
752 cur = matchList->nodeTab[i];
753 if (! IS_XSLT_REAL_NODE(cur))
754 continue;
755 ctxt->node = cur;
756 xpctxt->node = cur;
757 /*
758 * Process the 'use' of the xsl:key.
759 * SPEC XSLT 1.0:
760 * "The use attribute is an expression specifying the values of
761 * the key; the expression is evaluated once for each node that
762 * matches the pattern."
763 */
764 if (useRes != NULL)
765 xmlXPathFreeObject(useRes);
766 useRes = xmlXPathCompiledEval(keyDef->usecomp, xpctxt);
767 if (useRes == NULL) {
768 xsltTransformError(ctxt, NULL, keyDef->inst,
769 "Failed to evaluate the 'use' expression.\n");
771 break;
772 }
773 if (useRes->type == XPATH_NODESET) {
774 if ((useRes->nodesetval != NULL) &&
775 (useRes->nodesetval->nodeNr != 0))
776 {
777 len = useRes->nodesetval->nodeNr;
778 str = xmlXPathCastNodeToString(useRes->nodesetval->nodeTab[0]);
779 } else {
780 continue;
781 }
782 } else {
783 len = 1;
784 if (useRes->type == XPATH_STRING) {
785 /*
786 * Consume the string value.
787 */
788 str = useRes->stringval;
789 useRes->stringval = NULL;
790 } else {
791 str = xmlXPathCastToString(useRes);
792 }
793 }
794 /*
795 * Process all strings.
796 */
797 k = 0;
798 while (1) {
799 if (str == NULL)
800 goto next_string;
801
802#ifdef WITH_XSLT_DEBUG_KEYS
804 "xsl:key : node associated to ('%s', '%s')\n", keyDef->name, str));
805#endif
806
807 keylist = xmlHashLookup(table->keys, str);
808 if (keylist == NULL) {
809 keylist = xmlXPathNodeSetCreate(cur);
810 if (keylist == NULL)
811 goto error;
813 } else {
814 /*
815 * TODO: How do we know if this function failed?
816 */
817 xmlXPathNodeSetAdd(keylist, cur);
818 }
819 switch (cur->type) {
820 case XML_ELEMENT_NODE:
821 case XML_TEXT_NODE:
823 case XML_PI_NODE:
824 case XML_COMMENT_NODE:
825 cur->psvi = keyDef;
826 break;
828 ((xmlAttrPtr) cur)->psvi = keyDef;
829 break;
832 ((xmlDocPtr) cur)->psvi = keyDef;
833 break;
834 default:
835 break;
836 }
837 xmlFree(str);
838 str = NULL;
839
840next_string:
841 k++;
842 if (k >= len)
843 break;
844 str = xmlXPathCastNodeToString(useRes->nodesetval->nodeTab[k]);
845 }
846 }
847
848exit:
849error:
850 ctxt->keyInitLevel--;
851 /*
852 * Restore context state.
853 */
854 xpctxt->node = oldXPNode;
855 xpctxt->doc = oldXPDoc;
856 xpctxt->nsNr = oldXPNsNr;
857 xpctxt->namespaces = oldXPNamespaces;
858 xpctxt->proximityPosition = oldXPPos;
859 xpctxt->contextSize = oldXPSize;
860
861 ctxt->node = oldContextNode;
862 ctxt->document = oldDocInfo;
863 ctxt->inst = oldInst;
864
865 if (str)
866 xmlFree(str);
867 if (useRes != NULL)
868 xmlXPathFreeObject(useRes);
869 if (matchRes != NULL)
870 xmlXPathFreeObject(matchRes);
871 return(0);
872}
static xsltKeyTablePtr xsltNewKeyTable(const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:111
int k
Definition: mpi.c:3369
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:461
XMLPUBFUN int XMLCALL xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata)
Definition: hash.c:389
@ XML_ATTRIBUTE_NODE
Definition: tree.h:161
@ XML_PI_NODE
Definition: tree.h:166
@ XML_COMMENT_NODE
Definition: tree.h:167
@ XML_HTML_DOCUMENT_NODE
Definition: tree.h:172
xmlAttr * xmlAttrPtr
Definition: tree.h:433
#define exit(n)
Definition: config.h:202
struct _xmlDoc * doc
Definition: tree.h:560
struct _xmlDoc * doc
Definition: tree.h:498
xmlDocPtr doc
xmlNsPtr * nsList
xmlChar * match
xmlXPathCompExprPtr comp
xmlXPathCompExprPtr usecomp
xmlNodePtr inst
xsltTransformState state
xmlXPathContextPtr xpathCtxt
Definition: path.c:35
@ XSLT_TRACE_KEYS
Definition: xsltutils.h:116
#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 234 of file xslt.c.

234 {
235 if (str == NULL)
236 return(1);
237 while (*str != 0) {
238 if (!(IS_BLANK(*str))) return(0);
239 str++;
240 }
241 return(1);
242}
#define IS_BLANK(c)
Definition: xslt.c:79

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 6873 of file xslt.c.

6873 {
6876 xmlChar *href = NULL;
6877 xmlURIPtr URI;
6878
6880
6881 if (doc == NULL)
6882 return(NULL);
6883
6884 /*
6885 * Find the text/xml stylesheet PI id any before the root
6886 */
6887 child = doc->children;
6888 while ((child != NULL) && (child->type != XML_ELEMENT_NODE)) {
6889 if ((child->type == XML_PI_NODE) &&
6890 (xmlStrEqual(child->name, BAD_CAST "xml-stylesheet"))) {
6891 href = xsltParseStylesheetPI(child->content);
6892 if (href != NULL)
6893 break;
6894 }
6895 child = child->next;
6896 }
6897
6898 /*
6899 * If found check the href to select processing
6900 */
6901 if (href != NULL) {
6902#ifdef WITH_XSLT_DEBUG_PARSING
6904 "xsltLoadStylesheetPI : found PI href=%s\n", href);
6905#endif
6906 URI = xmlParseURI((const char *) href);
6907 if (URI == NULL) {
6909 "xml-stylesheet : href %s is not valid\n", href);
6910 xmlFree(href);
6911 return(NULL);
6912 }
6913 if ((URI->fragment != NULL) && (URI->scheme == NULL) &&
6914 (URI->opaque == NULL) && (URI->authority == NULL) &&
6915 (URI->server == NULL) && (URI->user == NULL) &&
6916 (URI->path == NULL) && (URI->query == NULL)) {
6917 xmlAttrPtr ID;
6918
6919#ifdef WITH_XSLT_DEBUG_PARSING
6921 "xsltLoadStylesheetPI : Reference to ID %s\n", href);
6922#endif
6923 if (URI->fragment[0] == '#')
6924 ID = xmlGetID(doc, (const xmlChar *) &(URI->fragment[1]));
6925 else
6926 ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
6927 if (ID == NULL) {
6929 "xml-stylesheet : no ID %s found\n", URI->fragment);
6930 } else {
6931 xmlDocPtr fake;
6932 xmlNodePtr subtree, newtree;
6933 xmlNsPtr ns;
6934
6935#ifdef WITH_XSLT_DEBUG
6937 "creating new document from %s for embedded stylesheet\n",
6938 doc->URL);
6939#endif
6940 /*
6941 * move the subtree in a new document passed to
6942 * the stylesheet analyzer
6943 */
6944 subtree = ID->parent;
6945 fake = xmlNewDoc(NULL);
6946 if (fake != NULL) {
6947 /*
6948 * Should the dictionary still be shared even though
6949 * the nodes are being copied rather than moved?
6950 */
6951 fake->dict = doc->dict;
6952 xmlDictReference(doc->dict);
6953#ifdef WITH_XSLT_DEBUG
6955 "reusing dictionary from %s for embedded stylesheet\n",
6956 doc->URL);
6957#endif
6958
6959 newtree = xmlDocCopyNode(subtree, fake, 1);
6960
6961 fake->URL = xmlNodeGetBase(doc, subtree->parent);
6962#ifdef WITH_XSLT_DEBUG
6964 "set base URI for embedded stylesheet as %s\n",
6965 fake->URL);
6966#endif
6967
6968 /*
6969 * Add all namespaces in scope of embedded stylesheet to
6970 * root element of newly created stylesheet document
6971 */
6972 while ((subtree = subtree->parent) != (xmlNodePtr)doc) {
6973 for (ns = subtree->ns; ns; ns = ns->next) {
6974 xmlNewNs(newtree, ns->href, ns->prefix);
6975 }
6976 }
6977
6978 xmlAddChild((xmlNodePtr)fake, newtree);
6980 if (ret == NULL)
6981 xmlFreeDoc(fake);
6982 }
6983 }
6984 } else {
6985 xmlChar *URL, *base;
6986
6987 /*
6988 * Reference to an external stylesheet
6989 */
6990
6991 base = xmlNodeGetBase(doc, (xmlNodePtr) doc);
6992 URL = xmlBuildURI(href, base);
6993 if (URL != NULL) {
6994#ifdef WITH_XSLT_DEBUG_PARSING
6996 "xsltLoadStylesheetPI : fetching %s\n", URL);
6997#endif
6999 xmlFree(URL);
7000 } else {
7001#ifdef WITH_XSLT_DEBUG_PARSING
7003 "xsltLoadStylesheetPI : fetching %s\n", href);
7004#endif
7006 }
7007 if (base != NULL)
7008 xmlFree(base);
7009 }
7010 xmlFreeURI(URI);
7011 xmlFree(href);
7012 }
7013 return(ret);
7014}
void xsltInitGlobals(void)
Definition: extensions.c:2257
static HWND child
Definition: cursoricon.c:298
#define ID
Definition: ruserpass.c:36
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
XMLPUBFUN xmlNsPtr XMLCALL xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix)
XMLPUBFUN xmlNodePtr XMLCALL xmlDocCopyNode(xmlNodePtr node, xmlDocPtr doc, int recursive)
Definition: tree.h:434
const xmlChar * URL
Definition: tree.h:577
struct _xmlDict * dict
Definition: tree.h:580
struct _xmlNode * children
Definition: tree.h:555
struct _xmlNode * parent
Definition: tree.h:495
xmlNs * ns
Definition: tree.h:501
Definition: uri.h:33
char * authority
Definition: uri.h:36
char * server
Definition: uri.h:37
char * opaque
Definition: uri.h:35
char * user
Definition: uri.h:38
char * path
Definition: uri.h:40
char * scheme
Definition: uri.h:34
char * query
Definition: uri.h:41
char * fragment
Definition: uri.h:42
Definition: mxnamespace.c:45
BSTR prefix
Definition: mxnamespace.c:46
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
Definition: uri.c:940
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1387
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1892
XMLPUBFUN xmlAttrPtr XMLCALL xmlGetID(xmlDocPtr doc, const xmlChar *ID)
Definition: valid.c:2874
xsltStylesheetPtr xsltParseStylesheetFile(const xmlChar *filename)
Definition: xslt.c:6711
xsltStylesheetPtr xsltParseStylesheetDoc(xmlDocPtr doc)
Definition: xslt.c:6695
static xmlChar * xsltParseStylesheetPI(const xmlChar *value)
Definition: xslt.c:6783

◆ 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 795 of file xslt.c.

795 {
797}
static xsltStylesheetPtr xsltNewStylesheetInternal(xsltStylesheetPtr parent)
Definition: xslt.c:730

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 728 of file numbers.c.

731{
732 xmlBufferPtr output = NULL;
733 int amount, i;
734 double number;
735 xsltFormat tokens;
736
737 if (data->format != NULL) {
738 xsltNumberFormatTokenize(data->format, &tokens);
739 }
740 else {
742
743 /* The format needs to be recomputed each time */
744 if (data->has_format == 0)
745 return;
747 (const xmlChar *) "format",
749 if (format == NULL)
750 return;
753 }
754
755 output = xmlBufferCreate();
756 if (output == NULL)
757 goto XSLT_NUMBER_FORMAT_END;
758
759 /*
760 * Evaluate the XPath expression to find the value(s)
761 */
762 if (data->value) {
763 amount = xsltNumberFormatGetValue(ctxt->xpathCtxt,
764 node,
765 data->value,
766 &number);
767 if (amount == 1) {
769 &number,
770 1,
771 &tokens,
772 output);
773 }
774
775 } else if (data->level) {
776
777 if (xmlStrEqual(data->level, (const xmlChar *) "single")) {
779 node,
780 data->countPat,
781 data->fromPat,
782 &number,
783 1);
784 if (amount == 1) {
786 &number,
787 1,
788 &tokens,
789 output);
790 }
791 } else if (xmlStrEqual(data->level, (const xmlChar *) "multiple")) {
792 double numarray[1024];
793 int max = sizeof(numarray)/sizeof(numarray[0]);
795 node,
796 data->countPat,
797 data->fromPat,
798 numarray,
799 max);
800 if (amount > 0) {
802 numarray,
803 amount,
804 &tokens,
805 output);
806 }
807 } else if (xmlStrEqual(data->level, (const xmlChar *) "any")) {
808 amount = xsltNumberFormatGetAnyLevel(ctxt,
809 node,
810 data->countPat,
811 data->fromPat,
812 &number);
813 if (amount > 0) {
815 &number,
816 1,
817 &tokens,
818 output);
819 }
820 }
821
822 /*
823 * Unlike `match` patterns, `count` and `from` patterns can contain
824 * variable references, so we have to clear the pattern match
825 * cache if the "direct" matching algorithm was used.
826 */
827 if (data->countPat != NULL)
828 xsltCompMatchClearCache(ctxt, data->countPat);
829 if (data->fromPat != NULL)
830 xsltCompMatchClearCache(ctxt, data->fromPat);
831 }
832 /* Insert number as text node */
833 xsltCopyTextString(ctxt, ctxt->insert, xmlBufferContent(output), 0);
834
835 xmlBufferFree(output);
836
837XSLT_NUMBER_FORMAT_END:
838 if (tokens.start != NULL)
839 xmlFree(tokens.start);
840 if (tokens.end != NULL)
841 xmlFree(tokens.end);
842 for (i = 0;i < tokens.nTokens;i++) {
843 if (tokens.tokens[i].separator != NULL)
844 xmlFree(tokens.tokens[i].separator);
845 }
846}
static void xsltNumberFormatInsertNumbers(xsltNumberDataPtr data, double *numbers, int numbers_max, xsltFormatPtr tokens, xmlBufferPtr buffer)
Definition: numbers.c:427
static int xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xsltCompMatchPtr fromPat, double *array, int max)
Definition: numbers.c:634
static int xsltNumberFormatGetValue(xmlXPathContextPtr context, xmlNodePtr node, const xmlChar *value, double *number)
Definition: numbers.c:692
static void xsltNumberFormatTokenize(const xmlChar *format, xsltFormatPtr tokens)
Definition: numbers.c:318
static int xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xsltCompMatchPtr fromPat, double *array)
Definition: numbers.c:580
void xsltCompMatchClearCache(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp)
Definition: pattern.c:1144
xmlNodePtr xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int noescape)
Definition: transform.c:849
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
xmlChar * separator
Definition: numbers.c:30
xsltFormatToken tokens[MAX_TOKENS]
Definition: numbers.c:39
xmlChar * start
Definition: numbers.c:38
xmlChar * end
Definition: numbers.c:41
int nTokens
Definition: numbers.c:40
#define max(a, b)
Definition: svc.c:63
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:392
#define XSLT_NAMESPACE
Definition: xslt.h:46

Referenced by xsltNumber().

◆ xsltParseStylesheetDoc()

XSLTPUBFUN xsltStylesheetPtr XSLTCALL xsltParseStylesheetDoc ( xmlDocPtr  doc)

xsltParseStylesheetDoc: @doc: and 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 6695 of file xslt.c.

6695 {
6697
6699}
xsltStylesheetPtr xsltParseStylesheetImportedDoc(xmlDocPtr doc, xsltStylesheetPtr parentStyle)
Definition: xslt.c:6514

Referenced by 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 6711 of file xslt.c.

6711 {
6714 xmlDocPtr doc;
6715
6717
6718 if (filename == NULL)
6719 return(NULL);
6720
6721#ifdef WITH_XSLT_DEBUG_PARSING
6723 "xsltParseStylesheetFile : parse %s\n", filename);
6724#endif
6725
6726 /*
6727 * Security framework check
6728 */
6730 if (sec != NULL) {
6731 int res;
6732
6733 res = xsltCheckRead(sec, NULL, filename);
6734 if (res <= 0) {
6735 if (res == 0)
6737 "xsltParseStylesheetFile: read rights for %s denied\n",
6738 filename);
6739 return(NULL);
6740 }
6741 }
6742
6745 if (doc == NULL) {
6747 "xsltParseStylesheetFile : cannot parse %s\n", filename);
6748 return(NULL);
6749 }
6751 if (ret == NULL) {
6752 xmlFreeDoc(doc);
6753 return(NULL);
6754 }
6755
6756 return(ret);
6757}
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:163
int xsltCheckRead(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:402
xsltDocLoaderFunc xsltDocDefaultLoader
Definition: documents.c:93
@ 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 6514 of file xslt.c.

6515 {
6516 xsltStylesheetPtr retStyle;
6517
6518 if (doc == NULL)
6519 return(NULL);
6520
6521 retStyle = xsltNewStylesheetInternal(parentStyle);
6522 if (retStyle == NULL)
6523 return(NULL);
6524
6525 if (xsltParseStylesheetUser(retStyle, doc) != 0) {
6526 xsltFreeStylesheet(retStyle);
6527 return(NULL);
6528 }
6529
6530 return(retStyle);
6531}
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:950
int xsltParseStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc)
Definition: xslt.c:6543

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 1181 of file xslt.c.

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

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 6406 of file xslt.c.

6406 {
6408
6410
6411 if (doc == NULL)
6412 return(NULL);
6413 if (ret == NULL)
6414 return(ret);
6415
6416 /*
6417 * First steps, remove blank nodes,
6418 * locate the xsl:stylesheet element and the
6419 * namespace declaration.
6420 */
6422 if (cur == NULL) {
6424 "xsltParseStylesheetProcess : empty stylesheet\n");
6425 return(NULL);
6426 }
6427
6428 if ((IS_XSLT_ELEM(cur)) &&
6429 ((IS_XSLT_NAME(cur, "stylesheet")) ||
6430 (IS_XSLT_NAME(cur, "transform")))) {
6431#ifdef WITH_XSLT_DEBUG_PARSING
6433 "xsltParseStylesheetProcess : found stylesheet\n");
6434#endif
6435 ret->literal_result = 0;
6438 } else {
6441 ret->literal_result = 1;
6442 }
6443 if (!ret->nopreproc) {
6445 }
6446 if (ret->literal_result == 0) {
6448 } else {
6449 xmlChar *prop;
6450 xsltTemplatePtr template;
6451
6452 /*
6453 * the document itself might be the template, check xsl:version
6454 */
6455 prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
6456 if (prop == NULL) {
6458 "xsltParseStylesheetProcess : document is not a stylesheet\n");
6459 return(NULL);
6460 }
6461
6462#ifdef WITH_XSLT_DEBUG_PARSING
6464 "xsltParseStylesheetProcess : document is stylesheet\n");
6465#endif
6466
6467 if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
6468 (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
6470 "xsl:version: only 1.1 features are supported\n");
6471 ret->forwards_compatible = 1;
6472 ret->warnings++;
6473 }
6474 xmlFree(prop);
6475
6476 /*
6477 * Create and link the template
6478 */
6479 template = xsltNewTemplate();
6480 if (template == NULL) {
6481 return(NULL);
6482 }
6483 template->next = ret->templates;
6484 ret->templates = template;
6485 template->match = xmlStrdup((const xmlChar *)"/");
6486
6487 /*
6488 * parse the content and register the pattern
6489 */
6491 template->elem = (xmlNodePtr) doc;
6492 template->content = doc->children;
6493 xsltAddTemplate(ret, template, NULL, NULL);
6494 ret->literal_result = 1;
6495 }
6496
6497 return(ret);
6498}
int xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, const xmlChar *mode, const xmlChar *modeURI)
Definition: pattern.c:2016
static void xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top)
Definition: xslt.c:6078
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4878
static void xsltPreprocessStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:3469
static int xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1735
static void xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1599
static xsltTemplatePtr xsltNewTemplate(void)
Definition: xslt.c:394
#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 6543 of file xslt.c.

6543 {
6544 if ((style == NULL) || (doc == NULL))
6545 return(-1);
6546
6547 /*
6548 * Adjust the string dict.
6549 */
6550 if (doc->dict != NULL) {
6551 xmlDictFree(style->dict);
6552 style->dict = doc->dict;
6553#ifdef WITH_XSLT_DEBUG
6555 "reusing dictionary from %s for stylesheet\n",
6556 doc->URL);
6557#endif
6558 xmlDictReference(style->dict);
6559 }
6560
6561 /*
6562 * TODO: Eliminate xsltGatherNamespaces(); we must not restrict
6563 * the stylesheet to containt distinct namespace prefixes.
6564 */
6566
6567#ifdef XSLT_REFACTORED
6568 {
6569 xsltCompilerCtxtPtr cctxt;
6570 xsltStylesheetPtr oldCurSheet;
6571
6572 if (style->parent == NULL) {
6573 xsltPrincipalStylesheetDataPtr principalData;
6574 /*
6575 * Create extra data for the principal stylesheet.
6576 */
6577 principalData = xsltNewPrincipalStylesheetData();
6578 if (principalData == NULL) {
6579 return(-1);
6580 }
6581 style->principalData = principalData;
6582 /*
6583 * Create the compilation context
6584 * ------------------------------
6585 * (only once; for the principal stylesheet).
6586 * This is currently the only function where the
6587 * compilation context is created.
6588 */
6589 cctxt = xsltCompilationCtxtCreate(style);
6590 if (cctxt == NULL) {
6591 return(-1);
6592 }
6593 style->compCtxt = (void *) cctxt;
6594 cctxt->style = style;
6595 cctxt->dict = style->dict;
6596 cctxt->psData = principalData;
6597 /*
6598 * Push initial dummy node info.
6599 */
6600 cctxt->depth = -1;
6601 xsltCompilerNodePush(cctxt, (xmlNodePtr) doc);
6602 } else {
6603 /*
6604 * Imported stylesheet.
6605 */
6606 cctxt = style->parent->compCtxt;
6607 style->compCtxt = cctxt;
6608 }
6609 /*
6610 * Save the old and set the current stylesheet structure in the
6611 * compilation context.
6612 */
6613 oldCurSheet = cctxt->style;
6614 cctxt->style = style;
6615
6616 style->doc = doc;
6618
6619 cctxt->style = oldCurSheet;
6620 if (style->parent == NULL) {
6621 /*
6622 * Pop the initial dummy node info.
6623 */
6624 xsltCompilerNodePop(cctxt, (xmlNodePtr) doc);
6625 } else {
6626 /*
6627 * Clear the compilation context of imported
6628 * stylesheets.
6629 * TODO: really?
6630 */
6631 /* style->compCtxt = NULL; */
6632 }
6633
6634#ifdef XSLT_REFACTORED_XSLT_NSCOMP
6635 if (style->errors != 0) {
6636 /*
6637 * Restore all changes made to namespace URIs of ns-decls.
6638 */
6639 if (cctxt->psData->nsMap)
6640 xsltRestoreDocumentNamespaces(cctxt->psData->nsMap, doc);
6641 }
6642#endif
6643
6644 if (style->parent == NULL) {
6645 xsltCompilationCtxtFree(style->compCtxt);
6646 style->compCtxt = NULL;
6647 }
6648 }
6649
6650#else /* XSLT_REFACTORED */
6651 /*
6652 * Old behaviour.
6653 */
6654 style->doc = doc;
6655 if (xsltParseStylesheetProcess(style, doc) == NULL) {
6656 style->doc = NULL;
6657 return(-1);
6658 }
6659#endif /* else of XSLT_REFACTORED */
6660
6661 if (style->errors != 0) {
6662 /*
6663 * Detach the doc from the stylesheet; otherwise the doc
6664 * will be freed in xsltFreeStylesheet().
6665 */
6666 style->doc = NULL;
6667 /*
6668 * Cleanup the doc if its the main stylesheet.
6669 */
6670 if (style->parent == NULL)
6672 return(-1);
6673 }
6674
6675 if (style->parent == NULL)
6677
6678 return(0);
6679}
void xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style)
Definition: attributes.c:670
xsltStylesheetPtr xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc)
Definition: xslt.c:6406
static void xsltGatherNamespaces(xsltStylesheetPtr style)
Definition: xslt.c:3674

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 4878 of file xslt.c.

4878 {
4879 xmlNodePtr cur, delete;
4880
4881 if ((style == NULL) || (templ == NULL) ||
4882 (templ->type == XML_NAMESPACE_DECL)) return;
4883
4884 /*
4885 * This content comes from the stylesheet
4886 * For stylesheets, the set of whitespace-preserving
4887 * element names consists of just xsl:text.
4888 */
4889 cur = templ->children;
4890 delete = NULL;
4891 while (cur != NULL) {
4892 if (delete != NULL) {
4893#ifdef WITH_XSLT_DEBUG_BLANKS
4895 "xsltParseTemplateContent: removing text\n");
4896#endif
4897 xmlUnlinkNode(delete);
4898 xmlFreeNode(delete);
4899 delete = NULL;
4900 }
4901 if (IS_XSLT_ELEM(cur)) {
4903
4904 if (IS_XSLT_NAME(cur, "text")) {
4905 /*
4906 * TODO: Processing of xsl:text should be moved to
4907 * xsltPreprocessStylesheet(), since otherwise this
4908 * will be performed for every multiply included
4909 * stylesheet; i.e. this here is not skipped with
4910 * the use of the style->nopreproc flag.
4911 */
4912 if (cur->children != NULL) {
4913 xmlChar *prop;
4914 xmlNodePtr text = cur->children, next;
4915 int noesc = 0;
4916
4917 prop = xmlGetNsProp(cur,
4918 (const xmlChar *)"disable-output-escaping",
4919 NULL);
4920 if (prop != NULL) {
4921#ifdef WITH_XSLT_DEBUG_PARSING
4923 "Disable escaping: %s\n", text->content);
4924#endif
4925 if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
4926 noesc = 1;
4927 } else if (!xmlStrEqual(prop,
4928 (const xmlChar *)"no")){
4930 "xsl:text: disable-output-escaping allows only yes or no\n");
4931 style->warnings++;
4932
4933 }
4934 xmlFree(prop);
4935 }
4936
4937 while (text != NULL) {
4938 if (text->type == XML_COMMENT_NODE) {
4939 text = text->next;
4940 continue;
4941 }
4942 if ((text->type != XML_TEXT_NODE) &&
4943 (text->type != XML_CDATA_SECTION_NODE)) {
4945 "xsltParseTemplateContent: xslt:text content problem\n");
4946 style->errors++;
4947 break;
4948 }
4949 if ((noesc) && (text->type != XML_CDATA_SECTION_NODE))
4950 text->name = xmlStringTextNoenc;
4951 text = text->next;
4952 }
4953
4954 /*
4955 * replace xsl:text by the list of childs
4956 */
4957 if (text == NULL) {
4958 text = cur->children;
4959 while (text != NULL) {
4960 if ((style->internalized) &&
4961 (text->content != NULL) &&
4962 (!xmlDictOwns(style->dict, text->content))) {
4963
4964 /*
4965 * internalize the text string
4966 */
4967 if (text->doc->dict != NULL) {
4968 const xmlChar *tmp;
4969
4970 tmp = xmlDictLookup(text->doc->dict,
4971 text->content, -1);
4972 if (tmp != text->content) {
4974 text->content = (xmlChar *) tmp;
4975 }
4976 }
4977 }
4978
4979 next = text->next;
4981 xmlAddPrevSibling(cur, text);
4982 text = next;
4983 }
4984 }
4985 }
4986 delete = cur;
4987 goto skip_children;
4988 }
4989 }
4990 else if ((cur->ns != NULL) && (style->nsDefs != NULL) &&
4991 (xsltCheckExtPrefix(style, cur->ns->prefix)))
4992 {
4993 /*
4994 * okay this is an extension element compile it too
4995 */
4997 }
4998 else if (cur->type == XML_ELEMENT_NODE)
4999 {
5000 /*
5001 * This is an element which will be output as part of the
5002 * template exectution, precompile AVT if found.
5003 */
5004 if ((cur->ns == NULL) && (style->defaultAlias != NULL)) {
5005 cur->ns = xmlSearchNsByHref(cur->doc, cur,
5006 style->defaultAlias);
5007 }
5008 if (cur->properties != NULL) {
5009 xmlAttrPtr attr = cur->properties;
5010
5011 while (attr != NULL) {
5013 attr = attr->next;
5014 }
5015 }
5016 }
5017 /*
5018 * Skip to next node
5019 */
5020 if (cur->children != NULL) {
5021 if (cur->children->type != XML_ENTITY_DECL) {
5022 cur = cur->children;
5023 continue;
5024 }
5025 }
5026skip_children:
5027 if (cur->next != NULL) {
5028 cur = cur->next;
5029 continue;
5030 }
5031
5032 do {
5033 cur = cur->parent;
5034 if (cur == NULL)
5035 break;
5036 if (cur == templ) {
5037 cur = NULL;
5038 break;
5039 }
5040 if (cur->next != NULL) {
5041 cur = cur->next;
5042 break;
5043 }
5044 } while (cur != NULL);
5045 }
5046 if (delete != NULL) {
5047#ifdef WITH_XSLT_DEBUG_PARSING
5049 "xsltParseTemplateContent: removing text\n");
5050#endif
5051 xmlUnlinkNode(delete);
5052 xmlFreeNode(delete);
5053 delete = NULL;
5054 }
5055
5056 /*
5057 * Skip the first params
5058 */
5059 cur = templ->children;
5060 while (cur != NULL) {
5061 if ((IS_XSLT_ELEM(cur)) && (!(IS_XSLT_NAME(cur, "param"))))
5062 break;
5063 cur = cur->next;
5064 }
5065
5066 /*
5067 * Browse the remainder of the template
5068 */
5069 while (cur != NULL) {
5070 if ((IS_XSLT_ELEM(cur)) && (IS_XSLT_NAME(cur, "param"))) {
5072
5074 "xsltParseTemplateContent: ignoring misplaced param element\n");
5075 if (style != NULL) style->warnings++;
5076 cur = cur->next;
5079 } else
5080 break;
5081 }
5082}
int xsltCheckExtPrefix(xsltStylesheetPtr style, const xmlChar *URI)
Definition: extensions.c:1158
void xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr)
Definition: attrvt.c:168
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2177
const WCHAR * text
Definition: package.c:1799
GLfloat param
Definition: glext.h:5796
XMLPUBVAR const xmlChar xmlStringTextNoenc[]
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1220
@ XML_ENTITY_DECL
Definition: tree.h:176
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar *href)
XMLPUBFUN void XMLCALL xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content)
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
struct _xmlNode * children
Definition: tree.h:493
xmlElementType type
Definition: tree.h:491

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 138 of file variables.c.

140{
141 if ((ctxt == NULL) || (RVT == NULL))
142 return(-1);
143
144 RVT->prev = NULL;
145 RVT->psvi = XSLT_RVT_LOCAL;
146
147 /*
148 * When evaluating "select" expressions of xsl:variable
149 * and xsl:param, we need to bind newly created tree fragments
150 * to the variable itself; otherwise the fragment will be
151 * freed before we leave the scope of a var.
152 */
153 if ((ctxt->contextVariable != NULL) &&
155 {
156 RVT->next = (xmlNodePtr) XSLT_TCTXT_VARIABLE(ctxt)->fragment;
157 XSLT_TCTXT_VARIABLE(ctxt)->fragment = RVT;
158 return(0);
159 }
160 /*
161 * Store the fragment in the scope of the current instruction.
162 * If not reference by a returning instruction (like EXSLT's function),
163 * then this fragment will be freed, when the instruction exits.
164 */
165 RVT->next = (xmlNodePtr) ctxt->localRVT;
166 if (ctxt->localRVT != NULL)
167 ctxt->localRVT->prev = (xmlNodePtr) RVT;
168 ctxt->localRVT = RVT;
169 return(0);
170}
GLbitfield flags
Definition: glext.h:7161
struct _xmlNode * next
Definition: tree.h:558
struct _xmlNode * prev
Definition: tree.h:559
#define XSLT_VAR_IN_SELECT
Definition: variables.c:26
#define XSLT_TCTXT_VARIABLE(c)
Definition: variables.c:27

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 394 of file variables.c.

395{
396 if ((ctxt == NULL) || (RVT == NULL)) return(-1);
397
398 RVT->psvi = XSLT_RVT_GLOBAL;
399 RVT->prev = NULL;
400 RVT->next = (xmlNodePtr) ctxt->persistRVT;
401 if (ctxt->persistRVT != NULL)
402 ctxt->persistRVT->prev = (xmlNodePtr) RVT;
403 ctxt->persistRVT = RVT;
404 return(0);
405}

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 99 of file variables.c.

100{
101 if ((ctxt == NULL) || (RVT == NULL))
102 return(-1);
103
104 RVT->prev = NULL;
105 RVT->psvi = XSLT_RVT_LOCAL;
106
107 /*
108 * We'll restrict the lifetime of user-created fragments
109 * insinde an xsl:variable and xsl:param to the lifetime of the
110 * var/param itself.
111 */
112 if (ctxt->contextVariable != NULL) {
113 RVT->next = (xmlNodePtr) XSLT_TCTXT_VARIABLE(ctxt)->fragment;
114 XSLT_TCTXT_VARIABLE(ctxt)->fragment = RVT;
115 return(0);
116 }
117
118 RVT->next = (xmlNodePtr) ctxt->tmpRVT;
119 if (ctxt->tmpRVT != NULL)
120 ctxt->tmpRVT->prev = (xmlNodePtr) RVT;
121 ctxt->tmpRVT = RVT;
122 return(0);
123}

◆ 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 328 of file variables.c.

329{
330 if (RVT == NULL)
331 return;
332
333 if (ctxt && (ctxt->cache->nbRVT < 40)) {
334 /*
335 * Store the Result Tree Fragment.
336 * Free the document info.
337 */
338 if (RVT->_private != NULL) {
340 xmlFree(RVT->_private);
341 RVT->_private = NULL;
342 }
343 /*
344 * Clear the document tree.
345 */
346 if (RVT->children != NULL) {
348 RVT->children = NULL;
349 RVT->last = NULL;
350 }
351 if (RVT->ids != NULL) {
353 RVT->ids = NULL;
354 }
355
356 /*
357 * Reset the ownership information.
358 */
359 RVT->psvi = NULL;
360
361 RVT->next = (xmlNodePtr) ctxt->cache->RVT;
362 ctxt->cache->RVT = RVT;
363
364 ctxt->cache->nbRVT++;
365
366#ifdef XSLT_DEBUG_PROFILE_CACHE
367 ctxt->cache->dbgCachedRVTs++;
368#endif
369 return;
370 }
371 /*
372 * Free it.
373 */
374 if (RVT->_private != NULL) {
376 xmlFree(RVT->_private);
377 }
378 xmlFreeDoc(RVT);
379}
XMLPUBFUN void XMLCALL xmlFreeNodeList(xmlNodePtr cur)
void * _private
Definition: tree.h:552
void * ids
Definition: tree.h:575
struct _xmlNode * last
Definition: tree.h:556
XMLPUBFUN void XMLCALL xmlFreeIDTable(xmlIDTablePtr table)
Definition: valid.c:2756

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

◆ xsltUninit()

XSLTPUBFUN void XSLTCALL xsltUninit ( void  )

xsltUninit:

Uninitializes the processor.

Definition at line 217 of file xslt.c.

217 {
218#ifdef XSLT_LOCALE_WINAPI
219 xmlFreeRMutex(xsltLocaleMutex);
220 xsltLocaleMutex = NULL;
221#endif
222 initialized = 0;
223}
XMLPUBFUN void XMLCALL xmlFreeRMutex(xmlRMutexPtr tok)
Definition: threads.c:309
static int initialized
Definition: xslt.c:193

Referenced by xsltCleanupGlobals().