ReactOS  0.4.14-dev-114-gc8cbd56
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 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 1800 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 1816 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 1808 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 1838 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] == ' '))
GLdouble n
Definition: glext.h:7729
smooth NULL
Definition: ftsmooth.c:416

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) || \
GLdouble n
Definition: glext.h:7729
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
smooth NULL
Definition: ftsmooth.c:416

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 217 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 224 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 265 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 257 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 249 of file xsltInternals.h.

Typedef Documentation

◆ xsltDecimalFormat

xsltDecimalFormat:

Data structure of decimal-format.

Definition at line 309 of file xsltInternals.h.

◆ xsltDecimalFormatPtr

Definition at line 310 of file xsltInternals.h.

◆ xsltDocument

xsltDocument:

Data structure associated to a parsed document.

Definition at line 335 of file xsltInternals.h.

◆ xsltDocumentPtr

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

◆ xsltElemPreCompDeallocator

typedef void(* xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp)

xsltElemPreCompDeallocator: @comp: the xsltElemPreComp to free up

Deallocates an xsltElemPreComp structure.

Definition at line 469 of file xsltInternals.h.

◆ xsltElemPreCompPtr

Definition at line 400 of file xsltInternals.h.

◆ xsltKeyDef

xsltKeyDef:

Representation of an xsl:key.

Definition at line 352 of file xsltInternals.h.

◆ xsltKeyDefPtr

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

◆ xsltKeyTablePtr

Definition at line 374 of file xsltInternals.h.

◆ xsltRuntimeExtra

xsltRuntimeExtra:

Extra information added to the transformation context.

Definition at line 231 of file xsltInternals.h.

◆ xsltRuntimeExtraPtr

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

◆ xsltStackElem

Definition at line 1429 of file xsltInternals.h.

◆ xsltStackElemPtr

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

◆ xsltStylePreCompPtr

Definition at line 501 of file xsltInternals.h.

◆ xsltStylesheet

Definition at line 387 of file xsltInternals.h.

◆ xsltStylesheetPtr

Definition at line 388 of file xsltInternals.h.

◆ xsltTemplate

xsltTemplate:

The in-memory structure corresponding to an XSLT Template.

Definition at line 272 of file xsltInternals.h.

◆ xsltTemplatePtr

Definition at line 273 of file xsltInternals.h.

◆ xsltTransformCache

Definition at line 1647 of file xsltInternals.h.

◆ xsltTransformCachePtr

Definition at line 1648 of file xsltInternals.h.

◆ xsltTransformContext

◆ xsltTransformContextPtr

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

Enumeration Type Documentation

◆ xsltOutputType

Enumerator
XSLT_OUTPUT_XML 
XSLT_OUTPUT_HTML 
XSLT_OUTPUT_TEXT 

Definition at line 1665 of file xsltInternals.h.

◆ 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 428 of file xsltInternals.h.

428  {
429  XSLT_FUNC_COPY=1,
435  XSLT_FUNC_PI,
443  XSLT_FUNC_IF,
451 #ifdef XSLT_REFACTORED
452  ,
453  XSLT_FUNC_OTHERWISE,
454  XSLT_FUNC_FALLBACK,
455  XSLT_FUNC_MESSAGE,
456  XSLT_FUNC_INCLUDE,
457  XSLT_FUNC_ATTRSET,
458  XSLT_FUNC_LITERAL_RESULT_ELEMENT,
459  XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
460 #endif
461 } xsltStyleType;
xsltStyleType

◆ xsltTransformState

Enumerator
XSLT_STATE_OK 
XSLT_STATE_ERROR 
XSLT_STATE_STOPPED 

Definition at line 1671 of file xsltInternals.h.

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

794 {
795  return(style->extrasNr++);
796 }
Arabic default style
Definition: afstyles.h:93

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

810 {
811  if (ctxt->extrasNr >= ctxt->extrasMax) {
812  int i;
813  if (ctxt->extrasNr == 0) {
814  ctxt->extrasMax = 20;
815  ctxt->extras = (xsltRuntimeExtraPtr)
816  xmlMalloc(ctxt->extrasMax * sizeof(xsltRuntimeExtra));
817  if (ctxt->extras == NULL) {
819  "xsltAllocateExtraCtxt: out of memory\n");
820  return(0);
821  }
822  for (i = 0;i < ctxt->extrasMax;i++) {
823  ctxt->extras[i].info = NULL;
824  ctxt->extras[i].deallocate = NULL;
825  ctxt->extras[i].val.ptr = NULL;
826  }
827 
828  } else {
830 
831  ctxt->extrasMax += 100;
832  tmp = (xsltRuntimeExtraPtr) xmlRealloc(ctxt->extras,
833  ctxt->extrasMax * sizeof(xsltRuntimeExtra));
834  if (tmp == NULL) {
836  "xsltAllocateExtraCtxt: out of memory\n");
837  return(0);
838  }
839  ctxt->extras = tmp;
840  for (i = ctxt->extrasNr;i < ctxt->extrasMax;i++) {
841  ctxt->extras[i].info = NULL;
842  ctxt->extras[i].deallocate = NULL;
843  ctxt->extras[i].val.ptr = NULL;
844  }
845  }
846  }
847  return(ctxt->extrasNr++);
848 }
xsltRuntimeExtraPtr extras
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
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
union _xsltRuntimeExtra::@3312 val
xmlFreeFunc deallocate
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
xsltRuntimeExtra * xsltRuntimeExtraPtr

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 attrubute value template, and if yes establish some structures needed to process it at transformation time.

Definition at line 159 of file attrvt.c.

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

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 }
xsltTransformCachePtr cache
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:638
struct container container
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define XSLT_MARK_RES_TREE_FRAG(n)
Definition: xsltInternals.h:48
xmlDoc * xmlDocPtr
Definition: tree.h:550
Definition: tree.h:551
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)

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 }
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
smooth NULL
Definition: ftsmooth.c:416
Definition: name.c:36
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
Arabic default style
Definition: afstyles.h:93
GLuint64EXT * result
Definition: glext.h:11304
WCHAR * name
Definition: name.c:40

◆ 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 }
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
smooth NULL
Definition: ftsmooth.c:416
Definition: name.c:36
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
Arabic default style
Definition: afstyles.h:93
GLuint64EXT * result
Definition: glext.h:11304
WCHAR * name
Definition: name.c:40

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

347  {
348  xmlChar *ret = NULL, *tmp;
349  xmlXPathCompExprPtr comp;
350  xsltAttrVTPtr cur = (xsltAttrVTPtr) avt;
351  int i;
352  int str;
353 
354  if ((ctxt == NULL) || (avt == NULL) || (node == NULL))
355  return(NULL);
356  str = cur->strstart;
357  for (i = 0;i < cur->nb_seg;i++) {
358  if (str) {
359  ret = xmlStrcat(ret, (const xmlChar *) cur->segments[i]);
360  } else {
361  comp = (xmlXPathCompExprPtr) cur->segments[i];
362  tmp = xsltEvalXPathStringNs(ctxt, comp, cur->nsNr, cur->nsList);
363  if (tmp != NULL) {
364  if (ret != NULL) {
365  ret = xmlStrcat(ret, tmp);
366  xmlFree(tmp);
367  } else {
368  ret = tmp;
369  }
370  }
371  }
372  str = !str;
373  }
374  return(ret);
375 }
int nb_seg
Definition: attrvt.c:28
int strstart
Definition: attrvt.c:30
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
XMLPUBFUN xmlChar *XMLCALL xmlStrcat(xmlChar *cur, const xmlChar *add)
Definition: xmlstring.c:526
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
void * segments[MAX_AVT_SEG]
Definition: attrvt.c:39
xmlNsPtr * nsList
Definition: attrvt.c:34
xmlChar * xsltEvalXPathStringNs(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp, int nsNr, xmlNsPtr *nsList)
Definition: templates.c:105
xsltAttrVT * xsltAttrVTPtr
Definition: attrvt.c:25
int nsNr
Definition: attrvt.c:35
Definition: dlist.c:348

Referenced by xsltAttrListTemplateProcess(), and xsltAttrTemplateProcess().

◆ xsltExtensionInstructionResultFinalize()

XSLTPUBFUN int XSLTCALL xsltExtensionInstructionResultFinalize ( xsltTransformContextPtr  ctxt)

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.

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

◆ xsltExtensionInstructionResultRegister()

XSLTPUBFUN int XSLTCALL xsltExtensionInstructionResultRegister ( xsltTransformContextPtr  ctxt,
xmlXPathObjectPtr  obj 
)

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

214 {
215  return(0);
216 }

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

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

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

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

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

113  {
114  xsltAttrVTPtr cur = (xsltAttrVTPtr) avt, next;
115 
116  while (cur != NULL) {
117  next = cur->next;
118  xsltFreeAttrVT(cur);
119  cur = next;
120  }
121 }
struct _xsltAttrVT * next
Definition: attrvt.c:27
smooth NULL
Definition: ftsmooth.c:416
static void xsltFreeAttrVT(xsltAttrVTPtr avt)
Definition: attrvt.c:83
static unsigned __int64 next
Definition: rand_nt.c:6
xsltAttrVT * xsltAttrVTPtr
Definition: attrvt.c:25

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

420 {
421  xmlDocPtr cur, next;
422 
423  if (ctxt == NULL)
424  return;
425  /*
426  * Local fragments.
427  */
428  cur = ctxt->localRVT;
429  while (cur != NULL) {
430  next = (xmlDocPtr) cur->next;
431  if (cur->_private != NULL) {
433  xmlFree(cur->_private);
434  }
435  xmlFreeDoc(cur);
436  cur = next;
437  }
438  ctxt->localRVT = NULL;
439  /*
440  * User-created per-template fragments.
441  */
442  cur = ctxt->tmpRVT;
443  while (cur != NULL) {
444  next = (xmlDocPtr) cur->next;
445  if (cur->_private != NULL) {
447  xmlFree(cur->_private);
448  }
449  xmlFreeDoc(cur);
450  cur = next;
451  }
452  ctxt->tmpRVT = NULL;
453  /*
454  * Global fragments.
455  */
456  cur = ctxt->persistRVT;
457  while (cur != NULL) {
458  next = (xmlDocPtr) cur->next;
459  if (cur->_private != NULL) {
461  xmlFree(cur->_private);
462  }
463  xmlFreeDoc(cur);
464  cur = next;
465  }
466  ctxt->persistRVT = NULL;
467 }
smooth NULL
Definition: ftsmooth.c:416
void * _private
Definition: tree.h:552
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
struct _xmlNode * next
Definition: tree.h:558
void xsltFreeDocumentKeys(xsltDocumentPtr idoc)
Definition: keys.c:920
xmlDoc * xmlDocPtr
Definition: tree.h:550
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: tree.h:551

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

606  {
608 
609  while (elem != NULL) {
610  next = elem->next;
612  elem = next;
613  }
614 }
static void xsltFreeStackElem(xsltStackElemPtr elem)
Definition: variables.c:545
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
static unsigned __int64 next
Definition: rand_nt.c:6

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

935 {
936  if (style == NULL)
937  return;
938 
939 #ifdef XSLT_REFACTORED
940  /*
941  * Start with a cleanup of the main stylesheet's doc.
942  */
943  if ((style->principal == style) && (style->doc))
946 #ifdef XSLT_REFACTORED_XSLT_NSCOMP
947  /*
948  * Restore changed ns-decls before freeing the document.
949  */
950  if ((style->doc != NULL) &&
951  XSLT_HAS_INTERNAL_NSMAP(style))
952  {
953  xsltRestoreDocumentNamespaces(XSLT_GET_INTERNAL_NSMAP(style),
954  style->doc);
955  }
956 #endif /* XSLT_REFACTORED_XSLT_NSCOMP */
957 #else
958  /*
959  * Start with a cleanup of the main stylesheet's doc.
960  */
961  if ((style->parent == NULL) && (style->doc))
964 #endif /* XSLT_REFACTORED */
965 
970  xsltFreeTemplateList(style->templates);
974  /*
975  * Free documents of all included stylsheet modules of this
976  * stylesheet level.
977  */
979  /*
980  * TODO: Best time to shutdown extension stuff?
981  */
983 
984  if (style->variables != NULL)
985  xsltFreeStackElemList(style->variables);
986  if (style->cdataSection != NULL)
987  xmlHashFree(style->cdataSection, NULL);
988  if (style->stripSpaces != NULL)
989  xmlHashFree(style->stripSpaces, NULL);
990  if (style->nsHash != NULL)
991  xmlHashFree(style->nsHash, NULL);
992  if (style->exclPrefixTab != NULL)
993  xmlFree(style->exclPrefixTab);
994  if (style->method != NULL)
995  xmlFree(style->method);
996  if (style->methodURI != NULL)
997  xmlFree(style->methodURI);
998  if (style->version != NULL)
999  xmlFree(style->version);
1000  if (style->encoding != NULL)
1001  xmlFree(style->encoding);
1002  if (style->doctypePublic != NULL)
1003  xmlFree(style->doctypePublic);
1004  if (style->doctypeSystem != NULL)
1005  xmlFree(style->doctypeSystem);
1006  if (style->mediaType != NULL)
1007  xmlFree(style->mediaType);
1008  if (style->attVTs)
1009  xsltFreeAVTList(style->attVTs);
1010  if (style->imports != NULL)
1011  xsltFreeStylesheetList(style->imports);
1012 
1013 #ifdef XSLT_REFACTORED
1014  /*
1015  * If this is the principal stylesheet, then
1016  * free its internal data.
1017  */
1018  if (style->principal == style) {
1019  if (style->principalData) {
1020  xsltFreePrincipalStylesheetData(style->principalData);
1021  style->principalData = NULL;
1022  }
1023  }
1024 #endif
1025  /*
1026  * Better to free the main document of this stylesheet level
1027  * at the end - so here.
1028  */
1029  if (style->doc != NULL) {
1030  xmlFreeDoc(style->doc);
1031  }
1032 
1033 #ifdef WITH_XSLT_DEBUG
1035  "freeing dictionary from stylesheet\n");
1036 #endif
1037  xmlDictFree(style->dict);
1038 
1039  memset(style, -1, sizeof(xsltStylesheet));
1040  xmlFree(style);
1041 }
void xsltFreeExts(xsltStylesheetPtr style)
Definition: extensions.c:479
void xsltFreeTemplateHashes(xsltStylesheetPtr style)
Definition: pattern.c:2573
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:320
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
static int xsltCleanupStylesheetTree(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr rootElem ATTRIBUTE_UNUSED)
Definition: xslt.c:879
void xsltFreeAttributeSetsHashes(xsltStylesheetPtr style)
Definition: attributes.c:1205
static void xsltFreeStylesheetList(xsltStylesheetPtr style)
Definition: xslt.c:857
XMLPUBFUN void XMLCALL xmlDictFree(xmlDictPtr dict)
Definition: dict.c:793
static void xsltFreeTemplateList(xsltTemplatePtr template)
Definition: xslt.c:445
void xsltFreeNamespaceAliasHashes(xsltStylesheetPtr style)
Definition: namespaces.c:811
static void xsltFreeDecimalFormatList(xsltStylesheetPtr self)
Definition: xslt.c:308
void xsltFreeKeys(xsltStylesheetPtr style)
Definition: keys.c:185
void xsltFreeStylePreComps(xsltStylesheetPtr style)
Definition: preproc.c:1935
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:606
void xsltShutdownExts(xsltStylesheetPtr style)
Definition: extensions.c:1133
void xsltFreeAVTList(void *avt)
Definition: attrvt.c:113
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
Arabic default style
Definition: afstyles.h:93
#define memset(x, y, z)
Definition: compat.h:39
void xsltFreeStyleDocuments(xsltStylesheetPtr style)
Definition: documents.c:193

Referenced by xsltDocumentElem(), xsltFreeStylesheetList(), xsltNewStylesheet(), 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 533 of file keys.c.

534 {
536  xsltKeyDefPtr keyd;
538 
539  if (ctxt == NULL)
540  return(-1);
541 
542 #ifdef KEY_INIT_DEBUG
543 fprintf(stderr, "xsltInitAllDocKeys %d %d\n",
544  ctxt->document->nbKeysComputed, ctxt->nbKeys);
545 #endif
546 
547  if (ctxt->document->nbKeysComputed == ctxt->nbKeys)
548  return(0);
549 
550 
551  /*
552  * TODO: This could be further optimized
553  */
554  style = ctxt->style;
555  while (style) {
556  keyd = (xsltKeyDefPtr) style->keys;
557  while (keyd != NULL) {
558 #ifdef KEY_INIT_DEBUG
559 fprintf(stderr, "Init key %s\n", keyd->name);
560 #endif
561  /*
562  * Check if keys with this QName have been already
563  * computed.
564  */
565  table = (xsltKeyTablePtr) ctxt->document->keys;
566  while (table) {
567  if (((keyd->nameURI != NULL) == (table->nameURI != NULL)) &&
568  xmlStrEqual(keyd->name, table->name) &&
569  xmlStrEqual(keyd->nameURI, table->nameURI))
570  {
571  break;
572  }
573  table = table->next;
574  }
575  if (table == NULL) {
576  /*
577  * Keys with this QName have not been yet computed.
578  */
579  xsltInitDocKeyTable(ctxt, keyd->name, keyd->nameURI);
580  }
581  keyd = keyd->next;
582  }
584  }
585 #ifdef KEY_INIT_DEBUG
586 fprintf(stderr, "xsltInitAllDocKeys: done\n");
587 #endif
588  return(0);
589 }
static int xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:477
const WCHAR * name
xsltKeyTable * xsltKeyTablePtr
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
xsltKeyDef * xsltKeyDefPtr
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
while(1)
Definition: macro.lex.yy.c:740
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
xsltDocumentPtr document
xmlChar * nameURI
xsltStylesheetPtr style
xmlChar * name
struct _xsltKeyDef * next
FILE * stderr
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
Arabic default style
Definition: afstyles.h:93

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 602 of file keys.c.

604 {
605  int i, len, k;
606  xmlNodeSetPtr matchList = NULL, keylist;
607  xmlXPathObjectPtr matchRes = NULL, useRes = NULL;
608  xmlChar *str = NULL;
610  xmlNodePtr oldInst, cur;
611  xmlNodePtr oldContextNode;
612  xsltDocumentPtr oldDocInfo;
613  int oldXPPos, oldXPSize;
614  xmlDocPtr oldXPDoc;
615  int oldXPNsNr;
616  xmlNsPtr *oldXPNamespaces;
617  xmlXPathContextPtr xpctxt;
618 
619 #ifdef KEY_INIT_DEBUG
620 fprintf(stderr, "xsltInitCtxtKey %s : %d\n", keyDef->name, ctxt->keyInitLevel);
621 #endif
622 
623  if ((keyDef->comp == NULL) || (keyDef->usecomp == NULL))
624  return(-1);
625 
626  /*
627  * Detect recursive keys
628  */
629  if (ctxt->keyInitLevel > ctxt->nbKeys) {
630 #ifdef WITH_XSLT_DEBUG_KEYS
633  "xsltInitCtxtKey: key definition of %s is recursive\n",
634  keyDef->name));
635 #endif
636  xsltTransformError(ctxt, NULL, keyDef->inst,
637  "Key definition for %s is recursive\n", keyDef->name);
638  ctxt->state = XSLT_STATE_STOPPED;
639  return(-1);
640  }
641  ctxt->keyInitLevel++;
642 
643  xpctxt = ctxt->xpathCtxt;
644  idoc->nbKeysComputed++;
645  /*
646  * Save context state.
647  */
648  oldInst = ctxt->inst;
649  oldDocInfo = ctxt->document;
650  oldContextNode = ctxt->node;
651 
652  oldXPDoc = xpctxt->doc;
653  oldXPPos = xpctxt->proximityPosition;
654  oldXPSize = xpctxt->contextSize;
655  oldXPNsNr = xpctxt->nsNr;
656  oldXPNamespaces = xpctxt->namespaces;
657 
658  /*
659  * Set up contexts.
660  */
661  ctxt->document = idoc;
662  ctxt->node = (xmlNodePtr) idoc->doc;
663  ctxt->inst = keyDef->inst;
664 
665  xpctxt->doc = idoc->doc;
666  xpctxt->node = (xmlNodePtr) idoc->doc;
667  /* TODO : clarify the use of namespaces in keys evaluation */
668  xpctxt->namespaces = keyDef->nsList;
669  xpctxt->nsNr = keyDef->nsNr;
670 
671  /*
672  * Evaluate the 'match' expression of the xsl:key.
673  * TODO: The 'match' is a *pattern*.
674  */
675  matchRes = xmlXPathCompiledEval(keyDef->comp, xpctxt);
676  if (matchRes == NULL) {
677 
678 #ifdef WITH_XSLT_DEBUG_KEYS
680  "xsltInitCtxtKey: %s evaluation failed\n", keyDef->match));
681 #endif
682  xsltTransformError(ctxt, NULL, keyDef->inst,
683  "Failed to evaluate the 'match' expression.\n");
684  ctxt->state = XSLT_STATE_STOPPED;
685  goto error;
686  } else {
687  if (matchRes->type == XPATH_NODESET) {
688  matchList = matchRes->nodesetval;
689 
690 #ifdef WITH_XSLT_DEBUG_KEYS
691  if (matchList != NULL)
693  "xsltInitCtxtKey: %s evaluates to %d nodes\n",
694  keyDef->match, matchList->nodeNr));
695 #endif
696  } else {
697  /*
698  * Is not a node set, but must be.
699  */
700 #ifdef WITH_XSLT_DEBUG_KEYS
702  "xsltInitCtxtKey: %s is not a node set\n", keyDef->match));
703 #endif
704  xsltTransformError(ctxt, NULL, keyDef->inst,
705  "The 'match' expression did not evaluate to a node set.\n");
706  ctxt->state = XSLT_STATE_STOPPED;
707  goto error;
708  }
709  }
710  if ((matchList == NULL) || (matchList->nodeNr <= 0))
711  goto exit;
712 
717  table = (xsltKeyTablePtr) idoc->keys;
718  while (table != NULL) {
719  if (xmlStrEqual(table->name, keyDef->name) &&
720  (((keyDef->nameURI == NULL) && (table->nameURI == NULL)) ||
721  ((keyDef->nameURI != NULL) && (table->nameURI != NULL) &&
722  (xmlStrEqual(table->nameURI, keyDef->nameURI)))))
723  break;
724  table = table->next;
725  }
730  if (table == NULL) {
731  table = xsltNewKeyTable(keyDef->name, keyDef->nameURI);
732  if (table == NULL)
733  goto error;
734  table->next = idoc->keys;
735  idoc->keys = table;
736  }
737 
738  /*
739  * SPEC XSLT 1.0 (XSLT 2.0 does not clarify the context size!)
740  * "...the use attribute of the xsl:key element is evaluated with x as
741  " the current node and with a node list containing just x as the
742  * current node list"
743  */
744  xpctxt->contextSize = 1;
745  xpctxt->proximityPosition = 1;
746 
747  for (i = 0; i < matchList->nodeNr; i++) {
748  cur = matchList->nodeTab[i];
749  if (! IS_XSLT_REAL_NODE(cur))
750  continue;
751  ctxt->node = cur;
752  xpctxt->node = cur;
753  /*
754  * Process the 'use' of the xsl:key.
755  * SPEC XSLT 1.0:
756  * "The use attribute is an expression specifying the values of
757  * the key; the expression is evaluated once for each node that
758  * matches the pattern."
759  */
760  if (useRes != NULL)
761  xmlXPathFreeObject(useRes);
762  useRes = xmlXPathCompiledEval(keyDef->usecomp, xpctxt);
763  if (useRes == NULL) {
764  xsltTransformError(ctxt, NULL, keyDef->inst,
765  "Failed to evaluate the 'use' expression.\n");
766  ctxt->state = XSLT_STATE_STOPPED;
767  break;
768  }
769  if (useRes->type == XPATH_NODESET) {
770  if ((useRes->nodesetval != NULL) &&
771  (useRes->nodesetval->nodeNr != 0))
772  {
773  len = useRes->nodesetval->nodeNr;
774  str = xmlXPathCastNodeToString(useRes->nodesetval->nodeTab[0]);
775  } else {
776  continue;
777  }
778  } else {
779  len = 1;
780  if (useRes->type == XPATH_STRING) {
781  /*
782  * Consume the string value.
783  */
784  str = useRes->stringval;
785  useRes->stringval = NULL;
786  } else {
787  str = xmlXPathCastToString(useRes);
788  }
789  }
790  /*
791  * Process all strings.
792  */
793  k = 0;
794  while (1) {
795  if (str == NULL)
796  goto next_string;
797 
798 #ifdef WITH_XSLT_DEBUG_KEYS
800  "xsl:key : node associated to ('%s', '%s')\n", keyDef->name, str));
801 #endif
802 
803  keylist = xmlHashLookup(table->keys, str);
804  if (keylist == NULL) {
805  keylist = xmlXPathNodeSetCreate(cur);
806  if (keylist == NULL)
807  goto error;
808  xmlHashAddEntry(table->keys, str, keylist);
809  } else {
810  /*
811  * TODO: How do we know if this function failed?
812  */
813  xmlXPathNodeSetAdd(keylist, cur);
814  }
815  switch (cur->type) {
816  case XML_ELEMENT_NODE:
817  case XML_TEXT_NODE:
819  case XML_PI_NODE:
820  case XML_COMMENT_NODE:
821  cur->psvi = keyDef;
822  break;
823  case XML_ATTRIBUTE_NODE:
824  ((xmlAttrPtr) cur)->psvi = keyDef;
825  break;
826  case XML_DOCUMENT_NODE:
828  ((xmlDocPtr) cur)->psvi = keyDef;
829  break;
830  default:
831  break;
832  }
833  xmlFree(str);
834  str = NULL;
835 
836 next_string:
837  k++;
838  if (k >= len)
839  break;
840  str = xmlXPathCastNodeToString(useRes->nodesetval->nodeTab[k]);
841  }
842  }
843 
844 exit:
845 error:
846  ctxt->keyInitLevel--;
847  /*
848  * Restore context state.
849  */
850  xpctxt->doc = oldXPDoc;
851  xpctxt->nsNr = oldXPNsNr;
852  xpctxt->namespaces = oldXPNamespaces;
853  xpctxt->proximityPosition = oldXPPos;
854  xpctxt->contextSize = oldXPSize;
855 
856  ctxt->node = oldContextNode;
857  ctxt->document = oldDocInfo;
858  ctxt->inst = oldInst;
859 
860  if (str)
861  xmlFree(str);
862  if (useRes != NULL)
863  xmlXPathFreeObject(useRes);
864  if (matchRes != NULL)
865  xmlXPathFreeObject(matchRes);
866  return(0);
867 }
void * psvi
Definition: tree.h:505
const WCHAR * name
#define error(str)
Definition: mkdosfs.c:1605
xmlNsPtr * nsList
xsltKeyTable * xsltKeyTablePtr
xmlXPathCompExprPtr usecomp
Definition: tree.h:389
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
XMLPUBFUN int XMLCALL xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata)
Definition: hash.c:387
xmlDocPtr doc
struct _xmlDoc * doc
Definition: tree.h:498
struct _xmlDoc * doc
Definition: tree.h:560
while(1)
Definition: macro.lex.yy.c:740
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
xsltTransformState state
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
xsltDocumentPtr document
xmlXPathContextPtr xpathCtxt
void * xsltGenericDebugContext
Definition: xsltutils.c:549
#define IS_XSLT_REAL_NODE(n)
Definition: xsltutils.h:71
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlChar * match
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
xmlAttr * xmlAttrPtr
Definition: tree.h:433
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlChar * nameURI
xmlElementType type
Definition: tree.h:491
xmlDoc * xmlDocPtr
Definition: tree.h:550
static xsltKeyTablePtr xsltNewKeyTable(const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:111
xmlChar * name
Definition: tree.h:551
FILE * stderr
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:459
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void exit(int exitcode)
Definition: _exit.c:33
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
xmlXPathCompExprPtr comp
int k
Definition: mpi.c:3369
Definition: path.c:35
xmlNodePtr inst

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 }
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#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 6875 of file xslt.c.

6875  {
6876  xmlNodePtr child;
6878  xmlChar *href = NULL;
6879  xmlURIPtr URI;
6880 
6881  xsltInitGlobals();
6882 
6883  if (doc == NULL)
6884  return(NULL);
6885 
6886  /*
6887  * Find the text/xml stylesheet PI id any before the root
6888  */
6889  child = doc->children;
6890  while ((child != NULL) && (child->type != XML_ELEMENT_NODE)) {
6891  if ((child->type == XML_PI_NODE) &&
6892  (xmlStrEqual(child->name, BAD_CAST "xml-stylesheet"))) {
6893  href = xsltParseStylesheetPI(child->content);
6894  if (href != NULL)
6895  break;
6896  }
6897  child = child->next;
6898  }
6899 
6900  /*
6901  * If found check the href to select processing
6902  */
6903  if (href != NULL) {
6904 #ifdef WITH_XSLT_DEBUG_PARSING
6906  "xsltLoadStylesheetPI : found PI href=%s\n", href);
6907 #endif
6908  URI = xmlParseURI((const char *) href);
6909  if (URI == NULL) {
6911  "xml-stylesheet : href %s is not valid\n", href);
6912  xmlFree(href);
6913  return(NULL);
6914  }
6915  if ((URI->fragment != NULL) && (URI->scheme == NULL) &&
6916  (URI->opaque == NULL) && (URI->authority == NULL) &&
6917  (URI->server == NULL) && (URI->user == NULL) &&
6918  (URI->path == NULL) && (URI->query == NULL)) {
6919  xmlAttrPtr ID;
6920 
6921 #ifdef WITH_XSLT_DEBUG_PARSING
6923  "xsltLoadStylesheetPI : Reference to ID %s\n", href);
6924 #endif
6925  if (URI->fragment[0] == '#')
6926  ID = xmlGetID(doc, (const xmlChar *) &(URI->fragment[1]));
6927  else
6928  ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
6929  if (ID == NULL) {
6931  "xml-stylesheet : no ID %s found\n", URI->fragment);
6932  } else {
6933  xmlDocPtr fake;
6934  xmlNodePtr subtree, newtree;
6935  xmlNsPtr ns;
6936 
6937 #ifdef WITH_XSLT_DEBUG
6939  "creating new document from %s for embedded stylesheet\n",
6940  doc->URL);
6941 #endif
6942  /*
6943  * move the subtree in a new document passed to
6944  * the stylesheet analyzer
6945  */
6946  subtree = ID->parent;
6947  fake = xmlNewDoc(NULL);
6948  if (fake != NULL) {
6949  /*
6950  * Should the dictionary still be shared even though
6951  * the nodes are being copied rather than moved?
6952  */
6953  fake->dict = doc->dict;
6954  xmlDictReference(doc->dict);
6955 #ifdef WITH_XSLT_DEBUG
6957  "reusing dictionary from %s for embedded stylesheet\n",
6958  doc->URL);
6959 #endif
6960 
6961  newtree = xmlDocCopyNode(subtree, fake, 1);
6962 
6963  fake->URL = xmlNodeGetBase(doc, subtree->parent);
6964 #ifdef WITH_XSLT_DEBUG
6966  "set base URI for embedded stylesheet as %s\n",
6967  fake->URL);
6968 #endif
6969 
6970  /*
6971  * Add all namespaces in scope of embedded stylesheet to
6972  * root element of newly created stylesheet document
6973  */
6974  while ((subtree = subtree->parent) != (xmlNodePtr)doc) {
6975  for (ns = subtree->ns; ns; ns = ns->next) {
6976  xmlNewNs(newtree, ns->href, ns->prefix);
6977  }
6978  }
6979 
6980  xmlAddChild((xmlNodePtr)fake, newtree);
6981  ret = xsltParseStylesheetDoc(fake);
6982  if (ret == NULL)
6983  xmlFreeDoc(fake);
6984  }
6985  }
6986  } else {
6987  xmlChar *URL, *base;
6988 
6989  /*
6990  * Reference to an external stylesheet
6991  */
6992 
6993  base = xmlNodeGetBase(doc, (xmlNodePtr) doc);
6994  URL = xmlBuildURI(href, base);
6995  if (URL != NULL) {
6996 #ifdef WITH_XSLT_DEBUG_PARSING
6998  "xsltLoadStylesheetPI : fetching %s\n", URL);
6999 #endif
7001  xmlFree(URL);
7002  } else {
7003 #ifdef WITH_XSLT_DEBUG_PARSING
7005  "xsltLoadStylesheetPI : fetching %s\n", href);
7006 #endif
7007  ret = xsltParseStylesheetFile(href);
7008  }
7009  if (base != NULL)
7010  xmlFree(base);
7011  }
7012  xmlFreeURI(URI);
7013  xmlFree(href);
7014  }
7015  return(ret);
7016 }
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:638
const xmlChar * URL
Definition: tree.h:577
Definition: tree.h:389
char * opaque
Definition: uri.h:35
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
Definition: uri.c:932
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
static HWND child
Definition: cursoricon.c:298
XMLPUBFUN xmlAttrPtr XMLCALL xmlGetID(xmlDocPtr doc, const xmlChar *ID)
Definition: valid.c:2803
char * server
Definition: uri.h:37
static xmlChar * xsltParseStylesheetPI(const xmlChar *value)
Definition: xslt.c:6785
char * query
Definition: uri.h:41
GLuint base
Definition: 3dtext.c:35
char * authority
Definition: uri.h:36
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1882
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
struct _xmlNode * parent
Definition: tree.h:495
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
int ret
Definition: mxnamespace.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
xsltStylesheetPtr xsltParseStylesheetFile(const xmlChar *filename)
Definition: xslt.c:6714
#define ID
Definition: ruserpass.c:36
BSTR prefix
Definition: mxnamespace.c:46
XMLPUBFUN xmlNsPtr XMLCALL xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix)
char * path
Definition: uri.h:40
xsltStylesheetPtr xsltParseStylesheetDoc(xmlDocPtr doc)
Definition: xslt.c:6680
Definition: uri.h:33
char * scheme
Definition: uri.h:34
char * user
Definition: uri.h:38
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1379
Definition: tree.h:551
Definition: tree.h:434
XMLPUBFUN xmlNodePtr XMLCALL xmlDocCopyNode(xmlNodePtr node, xmlDocPtr doc, int recursive)
struct _xmlNode * children
Definition: tree.h:555
xmlNs * ns
Definition: tree.h:501
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
void xsltInitGlobals(void)
Definition: extensions.c:2263
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
struct _xmlDict * dict
Definition: tree.h:580
char * fragment
Definition: uri.h:42

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

742  {
744 
746  if (ret == NULL) {
748  "xsltNewStylesheet : malloc failed\n");
749  goto internal_err;
750  }
751  memset(ret, 0, sizeof(xsltStylesheet));
752 
753  ret->omitXmlDeclaration = -1;
754  ret->standalone = -1;
755  ret->decimalFormat = xsltNewDecimalFormat(NULL, NULL);
756  ret->indent = -1;
757  ret->errors = 0;
758  ret->warnings = 0;
759  ret->exclPrefixNr = 0;
760  ret->exclPrefixMax = 0;
761  ret->exclPrefixTab = NULL;
762  ret->extInfos = NULL;
763  ret->extrasNr = 0;
764  ret->internalized = 1;
765  ret->literal_result = 0;
766  ret->forwards_compatible = 0;
767  ret->dict = xmlDictCreate();
768 #ifdef WITH_XSLT_DEBUG
770  "creating dictionary for stylesheet\n");
771 #endif
772 
773  xsltInit();
774 
775  return(ret);
776 
777 internal_err:
778  if (ret != NULL)
780  return(NULL);
781 }
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:934
XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreate(void)
Definition: dict.c:568
static xsltDecimalFormatPtr xsltNewDecimalFormat(const xmlChar *nsUri, xmlChar *name)
Definition: xslt.c:250
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
int ret
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
void xsltInit(void)
Definition: xslt.c:201
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#define memset(x, y, z)
Definition: compat.h:39
xsltStylesheet * xsltStylesheetPtr

Referenced by xsltDocumentElem(), and xsltParseStylesheetImportedDoc().

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

711 {
713  int amount, i;
714  double number;
715  xsltFormat tokens;
716 
717  if (data->format != NULL) {
718  xsltNumberFormatTokenize(data->format, &tokens);
719  }
720  else {
721  xmlChar *format;
722 
723  /* The format needs to be recomputed each time */
724  if (data->has_format == 0)
725  return;
726  format = xsltEvalAttrValueTemplate(ctxt, data->node,
727  (const xmlChar *) "format",
729  if (format == NULL)
730  return;
732  xmlFree(format);
733  }
734 
736  if (output == NULL)
737  goto XSLT_NUMBER_FORMAT_END;
738 
739  /*
740  * Evaluate the XPath expression to find the value(s)
741  */
742  if (data->value) {
743  amount = xsltNumberFormatGetValue(ctxt->xpathCtxt,
744  node,
745  data->value,
746  &number);
747  if (amount == 1) {
749  &number,
750  1,
751  &tokens,
752  output);
753  }
754 
755  } else if (data->level) {
756 
757  if (xmlStrEqual(data->level, (const xmlChar *) "single")) {
758  amount = xsltNumberFormatGetMultipleLevel(ctxt,
759  node,
760  data->countPat,
761  data->fromPat,
762  &number,
763  1);
764  if (amount == 1) {
766  &number,
767  1,
768  &tokens,
769  output);
770  }
771  } else if (xmlStrEqual(data->level, (const xmlChar *) "multiple")) {
772  double numarray[1024];
773  int max = sizeof(numarray)/sizeof(numarray[0]);
774  amount = xsltNumberFormatGetMultipleLevel(ctxt,
775  node,
776  data->countPat,
777  data->fromPat,
778  numarray,
779  max);
780  if (amount > 0) {
782  numarray,
783  amount,
784  &tokens,
785  output);
786  }
787  } else if (xmlStrEqual(data->level, (const xmlChar *) "any")) {
788  amount = xsltNumberFormatGetAnyLevel(ctxt,
789  node,
790  data->countPat,
791  data->fromPat,
792  &number);
793  if (amount > 0) {
795  &number,
796  1,
797  &tokens,
798  output);
799  }
800  }
801  }
802  /* Insert number as text node */
804 
806 
807 XSLT_NUMBER_FORMAT_END:
808  if (tokens.start != NULL)
809  xmlFree(tokens.start);
810  if (tokens.end != NULL)
811  xmlFree(tokens.end);
812  for (i = 0;i < tokens.nTokens;i++) {
813  if (tokens.tokens[i].separator != NULL)
814  xmlFree(tokens.tokens[i].separator);
815  }
816 }
static int xsltNumberFormatGetValue(xmlXPathContextPtr context, xmlNodePtr node, const xmlChar *value, double *number)
Definition: numbers.c:672
#define max(a, b)
Definition: svc.c:63
static void xsltNumberFormatInsertNumbers(xsltNumberDataPtr data, double *numbers, int numbers_max, xsltFormatPtr tokens, xmlBufferPtr buffer)
Definition: numbers.c:416
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
XMLPUBFUN const xmlChar *XMLCALL xmlBufferContent(const xmlBuffer *buf)
xmlChar * separator
Definition: numbers.c:30
XMLPUBFUN void XMLCALL xmlBufferFree(xmlBufferPtr buf)
xmlChar * start
Definition: numbers.c:38
#define XSLT_NAMESPACE
Definition: xslt.h:46
XMLPUBFUN xmlBufferPtr XMLCALL xmlBufferCreate(void)
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:384
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
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
static size_t double number
Definition: printf.c:64
static int xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xsltCompMatchPtr fromPat, double *array, int max)
Definition: numbers.c:623
smooth NULL
Definition: ftsmooth.c:416
xmlNodePtr xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int noescape)
Definition: transform.c:846
xmlXPathContextPtr xpathCtxt
xmlChar * end
Definition: numbers.c:41
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
xsltFormatToken tokens[MAX_TOKENS]
Definition: numbers.c:39
unsigned char xmlChar
Definition: xmlstring.h:28
int nTokens
Definition: numbers.c:40
static void xsltNumberFormatTokenize(const xmlChar *format, xsltFormatPtr tokens)
Definition: numbers.c:310
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
static int xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xsltCompMatchPtr fromPat, double *array)
Definition: numbers.c:569
Definition: dlist.c:348

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

6680  {
6682 
6683  xsltInitGlobals();
6684 
6686  if (ret == NULL)
6687  return(NULL);
6688 
6690 #ifdef XSLT_REFACTORED
6691  /*
6692  * Free the compilation context.
6693  * TODO: Check if it's better to move this cleanup to
6694  * xsltParseStylesheetImportedDoc().
6695  */
6696  if (ret->compCtxt != NULL) {
6697  xsltCompilationCtxtFree(XSLT_CCTXT(ret));
6698  ret->compCtxt = NULL;
6699  }
6700 #endif
6701  return(ret);
6702 }
xsltStylesheetPtr xsltParseStylesheetImportedDoc(xmlDocPtr doc, xsltStylesheetPtr parentStyle)
Definition: xslt.c:6499
smooth NULL
Definition: ftsmooth.c:416
int ret
void xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style)
Definition: attributes.c:670
void xsltInitGlobals(void)
Definition: extensions.c:2263

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

6714  {
6717  xmlDocPtr doc;
6718 
6719  xsltInitGlobals();
6720 
6721  if (filename == NULL)
6722  return(NULL);
6723 
6724 #ifdef WITH_XSLT_DEBUG_PARSING
6726  "xsltParseStylesheetFile : parse %s\n", filename);
6727 #endif
6728 
6729  /*
6730  * Security framework check
6731  */
6733  if (sec != NULL) {
6734  int res;
6735 
6736  res = xsltCheckRead(sec, NULL, filename);
6737  if (res == 0) {
6739  "xsltParseStylesheetFile: read rights for %s denied\n",
6740  filename);
6741  return(NULL);
6742  }
6743  }
6744 
6747  if (doc == NULL) {
6749  "xsltParseStylesheetFile : cannot parse %s\n", filename);
6750  return(NULL);
6751  }
6752  ret = xsltParseStylesheetDoc(doc);
6753  if (ret == NULL) {
6754  xmlFreeDoc(doc);
6755  return(NULL);
6756  }
6757 
6758  return(ret);
6759 }
xsltDocLoaderFunc xsltDocDefaultLoader
Definition: documents.c:93
int xsltCheckRead(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:400
const char * filename
Definition: ioapi.h:135
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
int ret
xsltStylesheetPtr xsltParseStylesheetDoc(xmlDocPtr doc)
Definition: xslt.c:6680
Definition: tree.h:551
GLuint res
Definition: glext.h:9613
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:163
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
void xsltInitGlobals(void)
Definition: extensions.c:2263

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

6500  {
6501  xsltStylesheetPtr retStyle;
6502 
6503  if (doc == NULL)
6504  return(NULL);
6505 
6506  retStyle = xsltNewStylesheet();
6507  if (retStyle == NULL)
6508  return(NULL);
6509  /*
6510  * Set the importing stylesheet module; also used to detect recursion.
6511  */
6512  retStyle->parent = parentStyle;
6513  /*
6514  * Adjust the string dict.
6515  */
6516  if (doc->dict != NULL) {
6517  xmlDictFree(retStyle->dict);
6518  retStyle->dict = doc->dict;
6519 #ifdef WITH_XSLT_DEBUG
6521  "reusing dictionary from %s for stylesheet\n",
6522  doc->URL);
6523 #endif
6524  xmlDictReference(retStyle->dict);
6525  }
6526 
6527  /*
6528  * TODO: Eliminate xsltGatherNamespaces(); we must not restrict
6529  * the stylesheet to containt distinct namespace prefixes.
6530  */
6531  xsltGatherNamespaces(retStyle);
6532 
6533 #ifdef XSLT_REFACTORED
6534  {
6535  xsltCompilerCtxtPtr cctxt;
6536  xsltStylesheetPtr oldCurSheet;
6537 
6538  if (parentStyle == NULL) {
6539  xsltPrincipalStylesheetDataPtr principalData;
6540  /*
6541  * Principal stylesheet
6542  * --------------------
6543  */
6544  retStyle->principal = retStyle;
6545  /*
6546  * Create extra data for the principal stylesheet.
6547  */
6548  principalData = xsltNewPrincipalStylesheetData();
6549  if (principalData == NULL) {
6550  xsltFreeStylesheet(retStyle);
6551  return(NULL);
6552  }
6553  retStyle->principalData = principalData;
6554  /*
6555  * Create the compilation context
6556  * ------------------------------
6557  * (only once; for the principal stylesheet).
6558  * This is currently the only function where the
6559  * compilation context is created.
6560  */
6561  cctxt = xsltCompilationCtxtCreate(retStyle);
6562  if (cctxt == NULL) {
6563  xsltFreeStylesheet(retStyle);
6564  return(NULL);
6565  }
6566  retStyle->compCtxt = (void *) cctxt;
6567  cctxt->style = retStyle;
6568  cctxt->dict = retStyle->dict;
6569  cctxt->psData = principalData;
6570  /*
6571  * Push initial dummy node info.
6572  */
6573  cctxt->depth = -1;
6574  xsltCompilerNodePush(cctxt, (xmlNodePtr) doc);
6575  } else {
6576  /*
6577  * Imported stylesheet.
6578  */
6579  retStyle->principal = parentStyle->principal;
6580  cctxt = parentStyle->compCtxt;
6581  retStyle->compCtxt = cctxt;
6582  }
6583  /*
6584  * Save the old and set the current stylesheet structure in the
6585  * compilation context.
6586  */
6587  oldCurSheet = cctxt->style;
6588  cctxt->style = retStyle;
6589 
6590  retStyle->doc = doc;
6591  xsltParseStylesheetProcess(retStyle, doc);
6592 
6593  cctxt->style = oldCurSheet;
6594  if (parentStyle == NULL) {
6595  /*
6596  * Pop the initial dummy node info.
6597  */
6598  xsltCompilerNodePop(cctxt, (xmlNodePtr) doc);
6599  } else {
6600  /*
6601  * Clear the compilation context of imported
6602  * stylesheets.
6603  * TODO: really?
6604  */
6605  /* retStyle->compCtxt = NULL; */
6606  }
6607  /*
6608  * Free the stylesheet if there were errors.
6609  */
6610  if (retStyle != NULL) {
6611  if (retStyle->errors != 0) {
6612 #ifdef XSLT_REFACTORED_XSLT_NSCOMP
6613  /*
6614  * Restore all changes made to namespace URIs of ns-decls.
6615  */
6616  if (cctxt->psData->nsMap)
6617  xsltRestoreDocumentNamespaces(cctxt->psData->nsMap, doc);
6618 #endif
6619  /*
6620  * Detach the doc from the stylesheet; otherwise the doc
6621  * will be freed in xsltFreeStylesheet().
6622  */
6623  retStyle->doc = NULL;
6624  /*
6625  * Cleanup the doc if its the main stylesheet.
6626  */
6627  if (parentStyle == NULL) {
6629  if (retStyle->compCtxt != NULL) {
6630  xsltCompilationCtxtFree(retStyle->compCtxt);
6631  retStyle->compCtxt = NULL;
6632  }
6633  }
6634 
6635  xsltFreeStylesheet(retStyle);
6636  retStyle = NULL;
6637  }
6638  }
6639  }
6640 
6641 #else /* XSLT_REFACTORED */
6642  /*
6643  * Old behaviour.
6644  */
6645  retStyle->doc = doc;
6646  if (xsltParseStylesheetProcess(retStyle, doc) == NULL) {
6647  retStyle->doc = NULL;
6648  xsltFreeStylesheet(retStyle);
6649  retStyle = NULL;
6650  }
6651  if (retStyle != NULL) {
6652  if (retStyle->errors != 0) {
6653  retStyle->doc = NULL;
6654  if (parentStyle == NULL)
6656  xmlDocGetRootElement(doc));
6657  xsltFreeStylesheet(retStyle);
6658  retStyle = NULL;
6659  }
6660  }
6661 #endif /* else of XSLT_REFACTORED */
6662 
6663  return(retStyle);
6664 }
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:934
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:638
const xmlChar * URL
Definition: tree.h:577
struct _xsltStylesheet * parent
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
static int xsltCleanupStylesheetTree(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr rootElem ATTRIBUTE_UNUSED)
Definition: xslt.c:879
Definition: tree.h:489
XMLPUBFUN void XMLCALL xmlDictFree(xmlDictPtr dict)
Definition: dict.c:793
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
struct _xmlDict * dict
Definition: tree.h:580
xsltStylesheetPtr principal
xsltStylesheetPtr xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc)
Definition: xslt.c:6391
static void xsltGatherNamespaces(xsltStylesheetPtr style)
Definition: xslt.c:3659
xsltStylesheetPtr xsltNewStylesheet(void)
Definition: xslt.c:742

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

1163 {
1164  xmlChar *elements,
1165  *prop;
1166  xmlChar *element,
1167  *end;
1168 
1169  if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
1170  return;
1171 
1172  prop = xmlGetNsProp(cur, (const xmlChar *) "version", NULL);
1173  if (prop != NULL) {
1174  if (style->version != NULL)
1175  xmlFree(style->version);
1176  style->version = prop;
1177  }
1178 
1179  prop = xmlGetNsProp(cur, (const xmlChar *) "encoding", NULL);
1180  if (prop != NULL) {
1181  if (style->encoding != NULL)
1182  xmlFree(style->encoding);
1183  style->encoding = prop;
1184  }
1185 
1186  /* relaxed to support xt:document
1187  * TODO KB: What does "relaxed to support xt:document" mean?
1188  */
1189  prop = xmlGetNsProp(cur, (const xmlChar *) "method", NULL);
1190  if (prop != NULL) {
1191  const xmlChar *URI;
1192 
1193  if (style->method != NULL)
1194  xmlFree(style->method);
1195  style->method = NULL;
1196  if (style->methodURI != NULL)
1197  xmlFree(style->methodURI);
1198  style->methodURI = NULL;
1199 
1200  /*
1201  * TODO: Don't use xsltGetQNameURI().
1202  */
1203  URI = xsltGetQNameURI(cur, &prop);
1204  if (prop == NULL) {
1205  if (style != NULL) style->errors++;
1206  } else if (URI == NULL) {
1207  if ((xmlStrEqual(prop, (const xmlChar *) "xml")) ||
1208  (xmlStrEqual(prop, (const xmlChar *) "html")) ||
1209  (xmlStrEqual(prop, (const xmlChar *) "text"))) {
1210  style->method = prop;
1211  } else {
1213  "invalid value for method: %s\n", prop);
1214  if (style != NULL) style->warnings++;
1215  xmlFree(prop);
1216  }
1217  } else {
1218  style->method = prop;
1219  style->methodURI = xmlStrdup(URI);
1220  }
1221  }
1222 
1223  prop = xmlGetNsProp(cur, (const xmlChar *) "doctype-system", NULL);
1224  if (prop != NULL) {
1225  if (style->doctypeSystem != NULL)
1226  xmlFree(style->doctypeSystem);
1227  style->doctypeSystem = prop;
1228  }
1229 
1230  prop = xmlGetNsProp(cur, (const xmlChar *) "doctype-public", NULL);
1231  if (prop != NULL) {
1232  if (style->doctypePublic != NULL)
1233  xmlFree(style->doctypePublic);
1234  style->doctypePublic = prop;
1235  }
1236 
1237  prop = xmlGetNsProp(cur, (const xmlChar *) "standalone", NULL);
1238  if (prop != NULL) {
1239  if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
1240  style->standalone = 1;
1241  } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
1242  style->standalone = 0;
1243  } else {
1245  "invalid value for standalone: %s\n", prop);
1246  style->errors++;
1247  }
1248  xmlFree(prop);
1249  }
1250 
1251  prop = xmlGetNsProp(cur, (const xmlChar *) "indent", NULL);
1252  if (prop != NULL) {
1253  if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
1254  style->indent = 1;
1255  } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
1256  style->indent = 0;
1257  } else {
1259  "invalid value for indent: %s\n", prop);
1260  style->errors++;
1261  }
1262  xmlFree(prop);
1263  }
1264 
1265  prop = xmlGetNsProp(cur, (const xmlChar *) "omit-xml-declaration", NULL);
1266  if (prop != NULL) {
1267  if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
1268  style->omitXmlDeclaration = 1;
1269  } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
1270  style->omitXmlDeclaration = 0;
1271  } else {
1273  "invalid value for omit-xml-declaration: %s\n",
1274  prop);
1275  style->errors++;
1276  }
1277  xmlFree(prop);
1278  }
1279 
1280  elements = xmlGetNsProp(cur, (const xmlChar *) "cdata-section-elements",
1281  NULL);
1282  if (elements != NULL) {
1283  if (style->cdataSection == NULL)
1284  style->cdataSection = xmlHashCreate(10);
1285  if (style->cdataSection == NULL)
1286  return;
1287 
1288  element = elements;
1289  while (*element != 0) {
1290  while (IS_BLANK(*element))
1291  element++;
1292  if (*element == 0)
1293  break;
1294  end = element;
1295  while ((*end != 0) && (!IS_BLANK(*end)))
1296  end++;
1298  if (element) {
1299 #ifdef WITH_XSLT_DEBUG_PARSING
1301  "add cdata section output element %s\n",
1302  element);
1303 #endif
1304  if (xmlValidateQName(BAD_CAST element, 0) != 0) {
1306  "Attribute 'cdata-section-elements': The value "
1307  "'%s' is not a valid QName.\n", element);
1308  xmlFree(element);
1309  style->errors++;
1310  } else {
1311  const xmlChar *URI;
1312 
1313  /*
1314  * TODO: Don't use xsltGetQNameURI().
1315  */
1316  URI = xsltGetQNameURI(cur, &element);
1317  if (element == NULL) {
1318  /*
1319  * TODO: We'll report additionally an error
1320  * via the stylesheet's error handling.
1321  */
1323  "Attribute 'cdata-section-elements': The value "
1324  "'%s' is not a valid QName.\n", element);
1325  style->errors++;
1326  } else {
1327  xmlNsPtr ns;
1328 
1329  /*
1330  * XSLT-1.0 "Each QName is expanded into an
1331  * expanded-name using the namespace declarations in
1332  * effect on the xsl:output element in which the QName
1333  * occurs; if there is a default namespace, it is used
1334  * for QNames that do not have a prefix"
1335  * NOTE: Fix of bug #339570.
1336  */
1337  if (URI == NULL) {
1338  ns = xmlSearchNs(style->doc, cur, NULL);
1339  if (ns != NULL)
1340  URI = ns->href;
1341  }
1342  xmlHashAddEntry2(style->cdataSection, element, URI,
1343  (void *) "cdata");
1344  xmlFree(element);
1345  }
1346  }
1347  }
1348  element = end;
1349  }
1350  xmlFree(elements);
1351  }
1352 
1353  prop = xmlGetNsProp(cur, (const xmlChar *) "media-type", NULL);
1354  if (prop != NULL) {
1355  if (style->mediaType)
1356  xmlFree(style->mediaType);
1357  style->mediaType = prop;
1358  }
1359  if (cur->children != NULL) {
1361  }
1362 }
Definition: tree.h:389
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:41
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:404
GLuint GLuint end
Definition: gl.h:1545
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlChar *XMLCALL xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreate(int size)
Definition: hash.c:174
Definition: mxnamespace.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
#define IS_BLANK(c)
Definition: xslt.c:79
xmlElementType type
Definition: tree.h:491
struct _xmlNode * children
Definition: tree.h:493
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Arabic default style
Definition: afstyles.h:93
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
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 6391 of file xslt.c.

6391  {
6392  xmlNodePtr cur;
6393 
6394  xsltInitGlobals();
6395 
6396  if (doc == NULL)
6397  return(NULL);
6398  if (ret == NULL)
6399  return(ret);
6400 
6401  /*
6402  * First steps, remove blank nodes,
6403  * locate the xsl:stylesheet element and the
6404  * namespace declaration.
6405  */
6406  cur = xmlDocGetRootElement(doc);
6407  if (cur == NULL) {
6409  "xsltParseStylesheetProcess : empty stylesheet\n");
6410  return(NULL);
6411  }
6412 
6413  if ((IS_XSLT_ELEM(cur)) &&
6414  ((IS_XSLT_NAME(cur, "stylesheet")) ||
6415  (IS_XSLT_NAME(cur, "transform")))) {
6416 #ifdef WITH_XSLT_DEBUG_PARSING
6418  "xsltParseStylesheetProcess : found stylesheet\n");
6419 #endif
6420  ret->literal_result = 0;
6423  } else {
6426  ret->literal_result = 1;
6427  }
6428  if (!ret->nopreproc) {
6430  }
6431  if (ret->literal_result == 0) {
6433  } else {
6434  xmlChar *prop;
6435  xsltTemplatePtr template;
6436 
6437  /*
6438  * the document itself might be the template, check xsl:version
6439  */
6440  prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
6441  if (prop == NULL) {
6442  xsltTransformError(NULL, ret, cur,
6443  "xsltParseStylesheetProcess : document is not a stylesheet\n");
6444  return(NULL);
6445  }
6446 
6447 #ifdef WITH_XSLT_DEBUG_PARSING
6449  "xsltParseStylesheetProcess : document is stylesheet\n");
6450 #endif
6451 
6452  if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
6453  (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
6454  xsltTransformError(NULL, ret, cur,
6455  "xsl:version: only 1.1 features are supported\n");
6456  ret->forwards_compatible = 1;
6457  ret->warnings++;
6458  }
6459  xmlFree(prop);
6460 
6461  /*
6462  * Create and link the template
6463  */
6464  template = xsltNewTemplate();
6465  if (template == NULL) {
6466  return(NULL);
6467  }
6468  template->next = ret->templates;
6469  ret->templates = template;
6470  template->match = xmlStrdup((const xmlChar *)"/");
6471 
6472  /*
6473  * parse the content and register the pattern
6474  */
6476  template->elem = (xmlNodePtr) doc;
6477  template->content = doc->children;
6478  xsltAddTemplate(ret, template, NULL, NULL);
6479  ret->literal_result = 1;
6480  }
6481 
6482  return(ret);
6483 }
int xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, const xmlChar *mode, const xmlChar *modeURI)
Definition: pattern.c:2085
#define XSLT_NAMESPACE
Definition: xslt.h:46
static void xsltPreprocessStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:3450
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
static void xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1580
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlChar *XMLCALL xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
static int xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1716
Definition: tree.h:489
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
static xsltTemplatePtr xsltNewTemplate(void)
Definition: xslt.c:394
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
struct _xmlNode * children
Definition: tree.h:555
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4863
void xsltInitGlobals(void)
Definition: extensions.c:2263
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:63
static void xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top)
Definition: xslt.c:6063
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xsltParseStylesheetImportedDoc(), and xsltParseStylesheetInclude().

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

4863  {
4864  xmlNodePtr cur, delete;
4865 
4866  if ((style == NULL) || (templ == NULL) ||
4867  (templ->type == XML_NAMESPACE_DECL)) return;
4868 
4869  /*
4870  * This content comes from the stylesheet
4871  * For stylesheets, the set of whitespace-preserving
4872  * element names consists of just xsl:text.
4873  */
4874  cur = templ->children;
4875  delete = NULL;
4876  while (cur != NULL) {
4877  if (delete != NULL) {
4878 #ifdef WITH_XSLT_DEBUG_BLANKS
4880  "xsltParseTemplateContent: removing text\n");
4881 #endif
4882  xmlUnlinkNode(delete);
4883  xmlFreeNode(delete);
4884  delete = NULL;
4885  }
4886  if (IS_XSLT_ELEM(cur)) {
4887  xsltStylePreCompute(style, cur);
4888 
4889  if (IS_XSLT_NAME(cur, "text")) {
4890  /*
4891  * TODO: Processing of xsl:text should be moved to
4892  * xsltPreprocessStylesheet(), since otherwise this
4893  * will be performed for every multiply included
4894  * stylesheet; i.e. this here is not skipped with
4895  * the use of the style->nopreproc flag.
4896  */
4897  if (cur->children != NULL) {
4898  xmlChar *prop;
4899  xmlNodePtr text = cur->children, next;
4900  int noesc = 0;
4901 
4902  prop = xmlGetNsProp(cur,
4903  (const xmlChar *)"disable-output-escaping",
4904  NULL);
4905  if (prop != NULL) {
4906 #ifdef WITH_XSLT_DEBUG_PARSING
4908  "Disable escaping: %s\n", text->content);
4909 #endif
4910  if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
4911  noesc = 1;
4912  } else if (!xmlStrEqual(prop,
4913  (const xmlChar *)"no")){
4915  "xsl:text: disable-output-escaping allows only yes or no\n");
4916  style->warnings++;
4917 
4918  }
4919  xmlFree(prop);
4920  }
4921 
4922  while (text != NULL) {
4923  if (text->type == XML_COMMENT_NODE) {
4924  text = text->next;
4925  continue;
4926  }
4927  if ((text->type != XML_TEXT_NODE) &&
4928  (text->type != XML_CDATA_SECTION_NODE)) {
4930  "xsltParseTemplateContent: xslt:text content problem\n");
4931  style->errors++;
4932  break;
4933  }
4934  if ((noesc) && (text->type != XML_CDATA_SECTION_NODE))
4935  text->name = xmlStringTextNoenc;
4936  text = text->next;
4937  }
4938 
4939  /*
4940  * replace xsl:text by the list of childs
4941  */
4942  if (text == NULL) {
4943  text = cur->children;
4944  while (text != NULL) {
4945  if ((style->internalized) &&
4946  (text->content != NULL) &&
4947  (!xmlDictOwns(style->dict, text->content))) {
4948 
4949  /*
4950  * internalize the text string
4951  */
4952  if (text->doc->dict != NULL) {
4953  const xmlChar *tmp;
4954 
4955  tmp = xmlDictLookup(text->doc->dict,
4956  text->content, -1);
4957  if (tmp != text->content) {
4959  text->content = (xmlChar *) tmp;
4960  }
4961  }
4962  }
4963 
4964  next = text->next;
4966  xmlAddPrevSibling(cur, text);
4967  text = next;
4968  }
4969  }
4970  }
4971  delete = cur;
4972  goto skip_children;
4973  }
4974  }
4975  else if ((cur->ns != NULL) && (style->nsDefs != NULL) &&
4976  (xsltCheckExtPrefix(style, cur->ns->prefix)))
4977  {
4978  /*
4979  * okay this is an extension element compile it too
4980  */
4981  xsltStylePreCompute(style, cur);
4982  }
4983  else if (cur->type == XML_ELEMENT_NODE)
4984  {
4985  /*
4986  * This is an element which will be output as part of the
4987  * template exectution, precompile AVT if found.
4988  */
4989  if ((cur->ns == NULL) && (style->defaultAlias != NULL)) {
4990  cur->ns = xmlSearchNsByHref(cur->doc, cur,
4991  style->defaultAlias);
4992  }
4993  if (cur->properties != NULL) {
4994  xmlAttrPtr attr = cur->properties;
4995 
4996  while (attr != NULL) {
4998  attr = attr->next;
4999  }
5000  }
5001  }
5002  /*
5003  * Skip to next node
5004  */
5005  if (cur->children != NULL) {
5006  if (cur->children->type != XML_ENTITY_DECL) {
5007  cur = cur->children;
5008  continue;
5009  }
5010  }
5011 skip_children:
5012  if (cur->next != NULL) {
5013  cur = cur->next;
5014  continue;
5015  }
5016 
5017  do {
5018  cur = cur->parent;
5019  if (cur == NULL)
5020  break;
5021  if (cur == templ) {
5022  cur = NULL;
5023  break;
5024  }
5025  if (cur->next != NULL) {
5026  cur = cur->next;
5027  break;
5028  }
5029  } while (cur != NULL);
5030  }
5031  if (delete != NULL) {
5032 #ifdef WITH_XSLT_DEBUG_PARSING
5034  "xsltParseTemplateContent: removing text\n");
5035 #endif
5036  xmlUnlinkNode(delete);
5037  xmlFreeNode(delete);
5038  delete = NULL;
5039  }
5040 
5041  /*
5042  * Skip the first params
5043  */
5044  cur = templ->children;
5045  while (cur != NULL) {
5046  if ((IS_XSLT_ELEM(cur)) && (!(IS_XSLT_NAME(cur, "param"))))
5047  break;
5048  cur = cur->next;
5049  }
5050 
5051  /*
5052  * Browse the remainder of the template
5053  */
5054  while (cur != NULL) {
5055  if ((IS_XSLT_ELEM(cur)) && (IS_XSLT_NAME(cur, "param"))) {
5056  xmlNodePtr param = cur;
5057 
5059  "xsltParseTemplateContent: ignoring misplaced param element\n");
5060  if (style != NULL) style->warnings++;
5061  cur = cur->next;
5063  xmlFreeNode(param);
5064  } else
5065  break;
5066  }
5067 }
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar *href)
const WCHAR * text
Definition: package.c:1827
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
struct _xmlDoc * doc
Definition: tree.h:498
smooth NULL
Definition: ftsmooth.c:416
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2175
struct _xmlNode * parent
Definition: tree.h:495
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
GLfloat param
Definition: glext.h:5796
int xsltCheckExtPrefix(xsltStylesheetPtr style, const xmlChar *URI)
Definition: extensions.c:1158
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlChar *XMLCALL xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:858
Definition: cookie.c:170
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlAttr * properties
Definition: tree.h:503
xmlElementType type
Definition: tree.h:491
XMLPUBFUN void XMLCALL xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content)
static unsigned __int64 next
Definition: rand_nt.c:6
struct _xmlNode * next
Definition: tree.h:496
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1211
XMLPUBVAR const xmlChar xmlStringTextNoenc[]
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
struct _xmlNode * children
Definition: tree.h:493
Definition: tree.h:434
xmlNs * ns
Definition: tree.h:501
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
const xmlChar * prefix
Definition: tree.h:393
Arabic default style
Definition: afstyles.h:93
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:63
void xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr)
Definition: attrvt.c:159

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 }
#define XSLT_RVT_LOCAL
Definition: variables.h:46
smooth NULL
Definition: ftsmooth.c:416
#define XSLT_VAR_IN_SELECT
Definition: variables.c:26
xmlNode * xmlNodePtr
Definition: tree.h:488
void * psvi
Definition: tree.h:581
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define XSLT_TCTXT_VARIABLE(c)
Definition: variables.c:27
GLbitfield flags
Definition: glext.h:7161
struct _xmlNode * next
Definition: tree.h:558
struct _xmlNode * prev
Definition: tree.h:559

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

398 {
399  if ((ctxt == NULL) || (RVT == NULL)) return(-1);
400 
401  RVT->psvi = XSLT_RVT_GLOBAL;
402  RVT->prev = NULL;
403  RVT->next = (xmlNodePtr) ctxt->persistRVT;
404  if (ctxt->persistRVT != NULL)
405  ctxt->persistRVT->prev = (xmlNodePtr) RVT;
406  ctxt->persistRVT = RVT;
407  return(0);
408 }
#define XSLT_RVT_GLOBAL
Definition: variables.h:62
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
void * psvi
Definition: tree.h:581
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct _xmlNode * next
Definition: tree.h:558
struct _xmlNode * prev
Definition: tree.h:559

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 }
#define XSLT_RVT_LOCAL
Definition: variables.h:46
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
void * psvi
Definition: tree.h:581
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define XSLT_TCTXT_VARIABLE(c)
Definition: variables.c:27
struct _xmlNode * next
Definition: tree.h:558
struct _xmlNode * prev
Definition: tree.h:559

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

327 {
328  if (RVT == NULL)
329  return;
330 
331  if (ctxt && (ctxt->cache->nbRVT < 40)) {
332  /*
333  * Store the Result Tree Fragment.
334  * Free the document info.
335  */
336  if (RVT->_private != NULL) {
338  xmlFree(RVT->_private);
339  RVT->_private = NULL;
340  }
341  /*
342  * Clear the document tree.
343  * REVISIT TODO: Do we expect ID/IDREF tables to be existent?
344  */
345  if (RVT->children != NULL) {
347  RVT->children = NULL;
348  RVT->last = NULL;
349  }
350  if (RVT->ids != NULL) {
352  RVT->ids = NULL;
353  }
354  if (RVT->refs != NULL) {
356  RVT->refs = NULL;
357  }
358 
359  /*
360  * Reset the ownership information.
361  */
362  RVT->psvi = NULL;
363 
364  RVT->next = (xmlNodePtr) ctxt->cache->RVT;
365  ctxt->cache->RVT = RVT;
366 
367  ctxt->cache->nbRVT++;
368 
369 #ifdef XSLT_DEBUG_PROFILE_CACHE
370  ctxt->cache->dbgCachedRVTs++;
371 #endif
372  return;
373  }
374  /*
375  * Free it.
376  */
377  if (RVT->_private != NULL) {
379  xmlFree(RVT->_private);
380  }
381  xmlFreeDoc(RVT);
382 }
xsltTransformCachePtr cache
XMLPUBFUN void XMLCALL xmlFreeIDTable(xmlIDTablePtr table)
Definition: valid.c:2686
XMLPUBFUN void XMLCALL xmlFreeNodeList(xmlNodePtr cur)
void * refs
Definition: tree.h:576
smooth NULL
Definition: ftsmooth.c:416
void * ids
Definition: tree.h:575
xmlNode * xmlNodePtr
Definition: tree.h:488
void * psvi
Definition: tree.h:581
void * _private
Definition: tree.h:552
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
struct _xmlNode * next
Definition: tree.h:558
void xsltFreeDocumentKeys(xsltDocumentPtr idoc)
Definition: keys.c:920
struct _xmlNode * last
Definition: tree.h:556
struct _xmlNode * children
Definition: tree.h:555
XMLPUBFUN void XMLCALL xmlFreeRefTable(xmlRefTablePtr table)
Definition: valid.c:3028

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 }
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlFreeRMutex(xmlRMutexPtr tok)
Definition: threads.c:319
static int initialized
Definition: xslt.c:193

Referenced by xsltCleanupGlobals().