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

Go to the source code of this file.

Classes

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

Macros

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

Typedefs

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

Enumerations

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

Functions

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

Macro Definition Documentation

◆ CHECK_STOPPED

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

CHECK_STOPPED:

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

Definition at line 1793 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 1809 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 1801 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 1831 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
#define NULL
Definition: types.h:112

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
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

XSLT_IS_TEXT_NODE:

check if the argument is a text node

Definition at line 38 of file xsltInternals.h.

◆ XSLT_MARK_RES_TREE_FRAG

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

XSLT_MARK_RES_TREE_FRAG:

internal macro to set up tree fragments

Definition at line 48 of file xsltInternals.h.

◆ XSLT_MAX_SORT

#define XSLT_MAX_SORT   15

XSLT_REFACTORED_PARSING:

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

Max number of specified xsl:sort on an element.

Definition at line 209 of file xsltInternals.h.

◆ XSLT_PAT_NO_PRIORITY

#define XSLT_PAT_NO_PRIORITY   -12345789

XSLT_PAT_NO_PRIORITY:

Specific value for pattern without priority expressed.

Definition at line 216 of file xsltInternals.h.

◆ XSLT_REFACTORED_KEYCOMP

#define XSLT_REFACTORED_KEYCOMP

XSLT_REFACTORED_KEYCOMP:

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

Definition at line 66 of file xsltInternals.h.

◆ XSLT_REFACTORED_VARS

#define XSLT_REFACTORED_VARS

XSLT_REFACTORED:

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

Internal define to enable the refactored variable part of libxslt

Definition at line 89 of file xsltInternals.h.

◆ XSLT_RUNTIME_EXTRA

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

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

Macro used to define extra information stored in the context

Definition at line 257 of file xsltInternals.h.

◆ XSLT_RUNTIME_EXTRA_FREE

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

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

Macro used to free extra information stored in the context

Definition at line 249 of file xsltInternals.h.

◆ XSLT_RUNTIME_EXTRA_LST

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

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

Macro used to access extra information stored in the context

Definition at line 241 of file xsltInternals.h.

Typedef Documentation

◆ xsltDecimalFormat

xsltDecimalFormat:

Data structure of decimal-format.

Definition at line 301 of file xsltInternals.h.

◆ xsltDecimalFormatPtr

Definition at line 302 of file xsltInternals.h.

◆ xsltDocument

xsltDocument:

Data structure associated to a parsed document.

Definition at line 327 of file xsltInternals.h.

◆ xsltDocumentPtr

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

◆ xsltElemPreCompDeallocator

typedef void(* xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp)

xsltElemPreCompDeallocator: @comp: the xsltElemPreComp to free up

Deallocates an xsltElemPreComp structure.

Definition at line 461 of file xsltInternals.h.

◆ xsltElemPreCompPtr

Definition at line 392 of file xsltInternals.h.

◆ xsltKeyDef

xsltKeyDef:

Representation of an xsl:key.

Definition at line 344 of file xsltInternals.h.

◆ xsltKeyDefPtr

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

◆ xsltKeyTablePtr

Definition at line 366 of file xsltInternals.h.

◆ xsltRuntimeExtra

xsltRuntimeExtra:

Extra information added to the transformation context.

Definition at line 223 of file xsltInternals.h.

◆ xsltRuntimeExtraPtr

Definition at line 224 of file xsltInternals.h.

◆ xsltSortFunc

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

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

Signature of the function to use during sorting

Definition at line 417 of file xsltInternals.h.

◆ xsltStackElem

Definition at line 1418 of file xsltInternals.h.

◆ xsltStackElemPtr

Definition at line 1419 of file xsltInternals.h.

◆ xsltStylePreComp

xsltStylePreComp:

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

Definition at line 492 of file xsltInternals.h.

◆ xsltStylePreCompPtr

Definition at line 493 of file xsltInternals.h.

◆ xsltStylesheet

Definition at line 379 of file xsltInternals.h.

◆ xsltStylesheetPtr

Definition at line 380 of file xsltInternals.h.

◆ xsltTemplate

xsltTemplate:

The in-memory structure corresponding to an XSLT Template.

Definition at line 264 of file xsltInternals.h.

◆ xsltTemplatePtr

Definition at line 265 of file xsltInternals.h.

◆ xsltTransformCache

Definition at line 1638 of file xsltInternals.h.

◆ xsltTransformCachePtr

Definition at line 1639 of file xsltInternals.h.

◆ xsltTransformContext

◆ xsltTransformContextPtr

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

Enumeration Type Documentation

◆ xsltOutputType

Enumerator
XSLT_OUTPUT_XML 
XSLT_OUTPUT_HTML 
XSLT_OUTPUT_TEXT 

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

420  {
421  XSLT_FUNC_COPY=1,
427  XSLT_FUNC_PI,
435  XSLT_FUNC_IF,
443 #ifdef XSLT_REFACTORED
444  ,
445  XSLT_FUNC_OTHERWISE,
446  XSLT_FUNC_FALLBACK,
447  XSLT_FUNC_MESSAGE,
448  XSLT_FUNC_INCLUDE,
449  XSLT_FUNC_ATTRSET,
450  XSLT_FUNC_LITERAL_RESULT_ELEMENT,
451  XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
452 #endif
453 } xsltStyleType;
xsltStyleType

◆ xsltTransformState

Enumerator
XSLT_STATE_OK 
XSLT_STATE_ERROR 
XSLT_STATE_STOPPED 

Definition at line 1662 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 809 of file xslt.c.

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

826 {
827  if (ctxt->extrasNr >= ctxt->extrasMax) {
828  int i;
829  if (ctxt->extrasNr == 0) {
830  ctxt->extrasMax = 20;
831  ctxt->extras = (xsltRuntimeExtraPtr)
832  xmlMalloc(ctxt->extrasMax * sizeof(xsltRuntimeExtra));
833  if (ctxt->extras == NULL) {
835  "xsltAllocateExtraCtxt: out of memory\n");
836  return(0);
837  }
838  for (i = 0;i < ctxt->extrasMax;i++) {
839  ctxt->extras[i].info = NULL;
840  ctxt->extras[i].deallocate = NULL;
841  ctxt->extras[i].val.ptr = NULL;
842  }
843 
844  } else {
846 
847  ctxt->extrasMax += 100;
848  tmp = (xsltRuntimeExtraPtr) xmlRealloc(ctxt->extras,
849  ctxt->extrasMax * sizeof(xsltRuntimeExtra));
850  if (tmp == NULL) {
852  "xsltAllocateExtraCtxt: out of memory\n");
853  return(0);
854  }
855  ctxt->extras = tmp;
856  for (i = ctxt->extrasNr;i < ctxt->extrasMax;i++) {
857  ctxt->extras[i].info = NULL;
858  ctxt->extras[i].deallocate = NULL;
859  ctxt->extras[i].val.ptr = NULL;
860  }
861  }
862  }
863  return(ctxt->extrasNr++);
864 }
xsltRuntimeExtraPtr extras
union _xsltRuntimeExtra::@3439 val
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
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
xmlFreeFunc deallocate
#define NULL
Definition: types.h:112
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 attribute value template, and if yes, establish some structures needed to process it at transformation time.

Definition at line 168 of file attrvt.c.

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

◆ 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 }
GLuint64EXT * result
Definition: glext.h:11304
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:251
struct define * next
Definition: compiler.c:65
#define NULL
Definition: types.h:112
Definition: name.c:38
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
Arabic default style
Definition: afstyles.h:93
WCHAR * name
Definition: name.c:42

Referenced by xsltFormatNumberFunction(), and xsltParseStylesheetDecimalFormat().

◆ xsltEvalAVT()

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

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

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

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

Definition at line 356 of file attrvt.c.

356  {
357  xmlChar *ret = NULL, *tmp;
358  xmlXPathCompExprPtr comp;
360  int i;
361  int str;
362 
363  if ((ctxt == NULL) || (avt == NULL) || (node == NULL))
364  return(NULL);
365  str = cur->strstart;
366  for (i = 0;i < cur->nb_seg;i++) {
367  if (str) {
368  ret = xmlStrcat(ret, (const xmlChar *) cur->segments[i]);
369  } else {
370  comp = (xmlXPathCompExprPtr) cur->segments[i];
371  tmp = xsltEvalXPathStringNs(ctxt, comp, cur->nsNr, cur->nsList);
372  if (tmp != NULL) {
373  if (ret != NULL) {
374  ret = xmlStrcat(ret, tmp);
375  xmlFree(tmp);
376  } else {
377  ret = tmp;
378  }
379  }
380  }
381  str = !str;
382  }
383  return(ret);
384 }
XMLPUBFUN xmlChar *XMLCALL xmlStrcat(xmlChar *cur, const xmlChar *add)
Definition: xmlstring.c:526
const WCHAR * str
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
xmlChar * xsltEvalXPathStringNs(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp, int nsNr, xmlNsPtr *nsList)
Definition: templates.c:105
xsltAttrVT * xsltAttrVTPtr
Definition: attrvt.c:25
Definition: dlist.c:348

Referenced by xsltAttrListTemplateProcess(), and xsltAttrTemplateProcess().

◆ xsltExtensionInstructionResultFinalize()

XSLTPUBFUN int XSLTCALL xsltExtensionInstructionResultFinalize ( xsltTransformContextPtr ctxt  ATTRIBUTE_UNUSED)

xsltExtensionInstructionResultFinalize: @ctxt: an XSLT transformation context

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

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

This function is unsupported in newer releases of libxslt.

Definition at line 187 of file variables.c.

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

◆ xsltExtensionInstructionResultRegister()

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

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

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

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

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

Definition at line 213 of file variables.c.

216 {
217  return(0);
218 }

◆ xsltFlagRVTs()

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

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

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

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

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

Definition at line 237 of file variables.c.

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

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

119  {
121 
122  while (cur != NULL) {
123  next = cur->next;
125  cur = next;
126  }
127 }
static void xsltFreeAttrVT(xsltAttrVTPtr avt)
Definition: attrvt.c:89
FxCollectionEntry * cur
static unsigned __int64 next
Definition: rand_nt.c:6
#define NULL
Definition: types.h:112
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 421 of file variables.c.

422 {
423  xmlDocPtr cur, next;
424 
425  if (ctxt == NULL)
426  return;
427  /*
428  * Local fragments.
429  */
430  cur = ctxt->localRVT;
431  while (cur != NULL) {
432  next = (xmlDocPtr) cur->next;
433  if (cur->_private != NULL) {
434  xsltFreeDocumentKeys(cur->_private);
435  xmlFree(cur->_private);
436  }
437  xmlFreeDoc(cur);
438  cur = next;
439  }
440  ctxt->localRVT = NULL;
441  /*
442  * User-created per-template fragments.
443  */
444  cur = ctxt->tmpRVT;
445  while (cur != NULL) {
446  next = (xmlDocPtr) cur->next;
447  if (cur->_private != NULL) {
448  xsltFreeDocumentKeys(cur->_private);
449  xmlFree(cur->_private);
450  }
451  xmlFreeDoc(cur);
452  cur = next;
453  }
454  ctxt->tmpRVT = NULL;
455  /*
456  * Global fragments.
457  */
458  cur = ctxt->persistRVT;
459  while (cur != NULL) {
460  next = (xmlDocPtr) cur->next;
461  if (cur->_private != NULL) {
462  xsltFreeDocumentKeys(cur->_private);
463  xmlFree(cur->_private);
464  }
465  xmlFreeDoc(cur);
466  cur = next;
467  }
468  ctxt->persistRVT = NULL;
469 }
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
FxCollectionEntry * cur
void xsltFreeDocumentKeys(xsltDocumentPtr idoc)
Definition: keys.c:925
xmlDoc * xmlDocPtr
Definition: tree.h:550
static unsigned __int64 next
Definition: rand_nt.c:6
#define NULL
Definition: types.h:112
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 608 of file variables.c.

608  {
610 
611  while (elem != NULL) {
612  next = elem->next;
614  elem = next;
615  }
616 }
static void xsltFreeStackElem(xsltStackElemPtr elem)
Definition: variables.c:547
static size_t elem
Definition: string.c:68
static unsigned __int64 next
Definition: rand_nt.c:6
#define NULL
Definition: types.h:112

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

◆ xsltFreeStylesheet()

XSLTPUBFUN void XSLTCALL xsltFreeStylesheet ( xsltStylesheetPtr  style)

xsltFreeStylesheet: @style: an XSLT stylesheet

Free up the memory allocated by @style

Definition at line 950 of file xslt.c.

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

◆ xsltInitAllDocKeys()

XSLTPUBFUN int XSLTCALL xsltInitAllDocKeys ( xsltTransformContextPtr  ctxt)

xsltInitAllDocKeys: @ctxt: transformation context

INTERNAL ROUTINE ONLY

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

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

Definition at line 535 of file keys.c.

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

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

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

6877  {
6878  xmlNodePtr child;
6880  xmlChar *href = NULL;
6881  xmlURIPtr URI;
6882 
6883  xsltInitGlobals();
6884 
6885  if (doc == NULL)
6886  return(NULL);
6887 
6888  /*
6889  * Find the text/xml stylesheet PI id any before the root
6890  */
6891  child = doc->children;
6892  while ((child != NULL) && (child->type != XML_ELEMENT_NODE)) {
6893  if ((child->type == XML_PI_NODE) &&
6894  (xmlStrEqual(child->name, BAD_CAST "xml-stylesheet"))) {
6895  href = xsltParseStylesheetPI(child->content);
6896  if (href != NULL)
6897  break;
6898  }
6899  child = child->next;
6900  }
6901 
6902  /*
6903  * If found check the href to select processing
6904  */
6905  if (href != NULL) {
6906 #ifdef WITH_XSLT_DEBUG_PARSING
6908  "xsltLoadStylesheetPI : found PI href=%s\n", href);
6909 #endif
6910  URI = xmlParseURI((const char *) href);
6911  if (URI == NULL) {
6913  "xml-stylesheet : href %s is not valid\n", href);
6914  xmlFree(href);
6915  return(NULL);
6916  }
6917  if ((URI->fragment != NULL) && (URI->scheme == NULL) &&
6918  (URI->opaque == NULL) && (URI->authority == NULL) &&
6919  (URI->server == NULL) && (URI->user == NULL) &&
6920  (URI->path == NULL) && (URI->query == NULL)) {
6921  xmlAttrPtr ID;
6922 
6923 #ifdef WITH_XSLT_DEBUG_PARSING
6925  "xsltLoadStylesheetPI : Reference to ID %s\n", href);
6926 #endif
6927  if (URI->fragment[0] == '#')
6928  ID = xmlGetID(doc, (const xmlChar *) &(URI->fragment[1]));
6929  else
6930  ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
6931  if (ID == NULL) {
6933  "xml-stylesheet : no ID %s found\n", URI->fragment);
6934  } else {
6935  xmlDocPtr fake;
6936  xmlNodePtr subtree, newtree;
6937  xmlNsPtr ns;
6938 
6939 #ifdef WITH_XSLT_DEBUG
6941  "creating new document from %s for embedded stylesheet\n",
6942  doc->URL);
6943 #endif
6944  /*
6945  * move the subtree in a new document passed to
6946  * the stylesheet analyzer
6947  */
6948  subtree = ID->parent;
6949  fake = xmlNewDoc(NULL);
6950  if (fake != NULL) {
6951  /*
6952  * Should the dictionary still be shared even though
6953  * the nodes are being copied rather than moved?
6954  */
6955  fake->dict = doc->dict;
6956  xmlDictReference(doc->dict);
6957 #ifdef WITH_XSLT_DEBUG
6959  "reusing dictionary from %s for embedded stylesheet\n",
6960  doc->URL);
6961 #endif
6962 
6963  newtree = xmlDocCopyNode(subtree, fake, 1);
6964 
6965  fake->URL = xmlNodeGetBase(doc, subtree->parent);
6966 #ifdef WITH_XSLT_DEBUG
6968  "set base URI for embedded stylesheet as %s\n",
6969  fake->URL);
6970 #endif
6971 
6972  /*
6973  * Add all namespaces in scope of embedded stylesheet to
6974  * root element of newly created stylesheet document
6975  */
6976  while ((subtree = subtree->parent) != (xmlNodePtr)doc) {
6977  for (ns = subtree->ns; ns; ns = ns->next) {
6978  xmlNewNs(newtree, ns->href, ns->prefix);
6979  }
6980  }
6981 
6982  xmlAddChild((xmlNodePtr)fake, newtree);
6983  ret = xsltParseStylesheetDoc(fake);
6984  if (ret == NULL)
6985  xmlFreeDoc(fake);
6986  }
6987  }
6988  } else {
6989  xmlChar *URL, *base;
6990 
6991  /*
6992  * Reference to an external stylesheet
6993  */
6994 
6995  base = xmlNodeGetBase(doc, (xmlNodePtr) doc);
6996  URL = xmlBuildURI(href, base);
6997  if (URL != NULL) {
6998 #ifdef WITH_XSLT_DEBUG_PARSING
7000  "xsltLoadStylesheetPI : fetching %s\n", URL);
7001 #endif
7003  xmlFree(URL);
7004  } else {
7005 #ifdef WITH_XSLT_DEBUG_PARSING
7007  "xsltLoadStylesheetPI : fetching %s\n", href);
7008 #endif
7009  ret = xsltParseStylesheetFile(href);
7010  }
7011  if (base != NULL)
7012  xmlFree(base);
7013  }
7014  xmlFreeURI(URI);
7015  xmlFree(href);
7016  }
7017  return(ret);
7018 }
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:645
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:934
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:2846
char * server
Definition: uri.h:37
static xmlChar * xsltParseStylesheetPI(const xmlChar *value)
Definition: xslt.c:6787
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:1884
#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:6715
#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:6699
Definition: uri.h:33
char * scheme
Definition: uri.h:34
char * user
Definition: uri.h:38
#define NULL
Definition: types.h:112
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1381
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 795 of file xslt.c.

795  {
797 }
static xsltStylesheetPtr xsltNewStylesheetInternal(xsltStylesheetPtr parent)
Definition: xslt.c:730
#define NULL
Definition: types.h:112

Referenced by xsltDocumentElem().

◆ xsltNumberFormat()

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

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

Convert one number.

Definition at line 722 of file numbers.c.

725 {
727  int amount, i;
728  double number;
729  xsltFormat tokens;
730 
731  if (data->format != NULL) {
732  xsltNumberFormatTokenize(data->format, &tokens);
733  }
734  else {
735  xmlChar *format;
736 
737  /* The format needs to be recomputed each time */
738  if (data->has_format == 0)
739  return;
740  format = xsltEvalAttrValueTemplate(ctxt, data->node,
741  (const xmlChar *) "format",
743  if (format == NULL)
744  return;
746  xmlFree(format);
747  }
748 
750  if (output == NULL)
751  goto XSLT_NUMBER_FORMAT_END;
752 
753  /*
754  * Evaluate the XPath expression to find the value(s)
755  */
756  if (data->value) {
757  amount = xsltNumberFormatGetValue(ctxt->xpathCtxt,
758  node,
759  data->value,
760  &number);
761  if (amount == 1) {
763  &number,
764  1,
765  &tokens,
766  output);
767  }
768 
769  } else if (data->level) {
770 
771  if (xmlStrEqual(data->level, (const xmlChar *) "single")) {
772  amount = xsltNumberFormatGetMultipleLevel(ctxt,
773  node,
774  data->countPat,
775  data->fromPat,
776  &number,
777  1);
778  if (amount == 1) {
780  &number,
781  1,
782  &tokens,
783  output);
784  }
785  } else if (xmlStrEqual(data->level, (const xmlChar *) "multiple")) {
786  double numarray[1024];
787  int max = sizeof(numarray)/sizeof(numarray[0]);
788  amount = xsltNumberFormatGetMultipleLevel(ctxt,
789  node,
790  data->countPat,
791  data->fromPat,
792  numarray,
793  max);
794  if (amount > 0) {
796  numarray,
797  amount,
798  &tokens,
799  output);
800  }
801  } else if (xmlStrEqual(data->level, (const xmlChar *) "any")) {
802  amount = xsltNumberFormatGetAnyLevel(ctxt,
803  node,
804  data->countPat,
805  data->fromPat,
806  &number);
807  if (amount > 0) {
809  &number,
810  1,
811  &tokens,
812  output);
813  }
814  }
815 
816  /*
817  * Unlike `match` patterns, `count` and `from` patterns can contain
818  * variable references, so we have to clear the pattern match
819  * cache if the "direct" matching algorithm was used.
820  */
821  if (data->countPat != NULL)
822  xsltCompMatchClearCache(ctxt, data->countPat);
823  if (data->fromPat != NULL)
824  xsltCompMatchClearCache(ctxt, data->fromPat);
825  }
826  /* Insert number as text node */
828 
830 
831 XSLT_NUMBER_FORMAT_END:
832  if (tokens.start != NULL)
833  xmlFree(tokens.start);
834  if (tokens.end != NULL)
835  xmlFree(tokens.end);
836  for (i = 0;i < tokens.nTokens;i++) {
837  if (tokens.tokens[i].separator != NULL)
838  xmlFree(tokens.tokens[i].separator);
839  }
840 }
static int xsltNumberFormatGetValue(xmlXPathContextPtr context, xmlNodePtr node, const xmlChar *value, double *number)
Definition: numbers.c:686
#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:421
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
static size_t double number
Definition: printf.c:69
static int xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xsltCompMatchPtr fromPat, double *array, int max)
Definition: numbers.c:628
xmlNodePtr xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target, const xmlChar *string, int noescape)
Definition: transform.c:850
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
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
void xsltCompMatchClearCache(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp)
Definition: pattern.c:1235
#define NULL
Definition: types.h:112
int nTokens
Definition: numbers.c:40
static void xsltNumberFormatTokenize(const xmlChar *format, xsltFormatPtr tokens)
Definition: numbers.c:312
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:574
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 6699 of file xslt.c.

6699  {
6700  xsltInitGlobals();
6701 
6702  return(xsltParseStylesheetImportedDoc(doc, NULL));
6703 }
xsltStylesheetPtr xsltParseStylesheetImportedDoc(xmlDocPtr doc, xsltStylesheetPtr parentStyle)
Definition: xslt.c:6518
#define NULL
Definition: types.h:112
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 6715 of file xslt.c.

6715  {
6718  xmlDocPtr doc;
6719 
6720  xsltInitGlobals();
6721 
6722  if (filename == NULL)
6723  return(NULL);
6724 
6725 #ifdef WITH_XSLT_DEBUG_PARSING
6727  "xsltParseStylesheetFile : parse %s\n", filename);
6728 #endif
6729 
6730  /*
6731  * Security framework check
6732  */
6734  if (sec != NULL) {
6735  int res;
6736 
6737  res = xsltCheckRead(sec, NULL, filename);
6738  if (res <= 0) {
6739  if (res == 0)
6741  "xsltParseStylesheetFile: read rights for %s denied\n",
6742  filename);
6743  return(NULL);
6744  }
6745  }
6746 
6749  if (doc == NULL) {
6751  "xsltParseStylesheetFile : cannot parse %s\n", filename);
6752  return(NULL);
6753  }
6754  ret = xsltParseStylesheetDoc(doc);
6755  if (ret == NULL) {
6756  xmlFreeDoc(doc);
6757  return(NULL);
6758  }
6759 
6760  return(ret);
6761 }
xsltDocLoaderFunc xsltDocDefaultLoader
Definition: documents.c:93
int xsltCheckRead(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:402
const char * filename
Definition: ioapi.h:135
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54
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:6699
#define NULL
Definition: types.h:112
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 6518 of file xslt.c.

6519  {
6520  xsltStylesheetPtr retStyle;
6521 
6522  if (doc == NULL)
6523  return(NULL);
6524 
6525  retStyle = xsltNewStylesheetInternal(parentStyle);
6526  if (retStyle == NULL)
6527  return(NULL);
6528 
6529  if (xsltParseStylesheetUser(retStyle, doc) != 0) {
6530  xsltFreeStylesheet(retStyle);
6531  return(NULL);
6532  }
6533 
6534  return(retStyle);
6535 }
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:950
static xsltStylesheetPtr xsltNewStylesheetInternal(xsltStylesheetPtr parent)
Definition: xslt.c:730
int xsltParseStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc)
Definition: xslt.c:6547
#define NULL
Definition: types.h:112

Referenced by xsltParseStylesheetDoc(), and xsltParseStylesheetImport().

◆ xsltParseStylesheetOutput()

XSLTPUBFUN void XSLTCALL xsltParseStylesheetOutput ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)

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

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

Definition at line 1181 of file xslt.c.

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

6410  {
6411  xmlNodePtr cur;
6412 
6413  xsltInitGlobals();
6414 
6415  if (doc == NULL)
6416  return(NULL);
6417  if (ret == NULL)
6418  return(ret);
6419 
6420  /*
6421  * First steps, remove blank nodes,
6422  * locate the xsl:stylesheet element and the
6423  * namespace declaration.
6424  */
6425  cur = xmlDocGetRootElement(doc);
6426  if (cur == NULL) {
6428  "xsltParseStylesheetProcess : empty stylesheet\n");
6429  return(NULL);
6430  }
6431 
6432  if ((IS_XSLT_ELEM(cur)) &&
6433  ((IS_XSLT_NAME(cur, "stylesheet")) ||
6434  (IS_XSLT_NAME(cur, "transform")))) {
6435 #ifdef WITH_XSLT_DEBUG_PARSING
6437  "xsltParseStylesheetProcess : found stylesheet\n");
6438 #endif
6439  ret->literal_result = 0;
6442  } else {
6445  ret->literal_result = 1;
6446  }
6447  if (!ret->nopreproc) {
6449  }
6450  if (ret->literal_result == 0) {
6452  } else {
6453  xmlChar *prop;
6454  xsltTemplatePtr template;
6455 
6456  /*
6457  * the document itself might be the template, check xsl:version
6458  */
6459  prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
6460  if (prop == NULL) {
6462  "xsltParseStylesheetProcess : document is not a stylesheet\n");
6463  return(NULL);
6464  }
6465 
6466 #ifdef WITH_XSLT_DEBUG_PARSING
6468  "xsltParseStylesheetProcess : document is stylesheet\n");
6469 #endif
6470 
6471  if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
6472  (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
6474  "xsl:version: only 1.1 features are supported\n");
6475  ret->forwards_compatible = 1;
6476  ret->warnings++;
6477  }
6478  xmlFree(prop);
6479 
6480  /*
6481  * Create and link the template
6482  */
6483  template = xsltNewTemplate();
6484  if (template == NULL) {
6485  return(NULL);
6486  }
6487  template->next = ret->templates;
6488  ret->templates = template;
6489  template->match = xmlStrdup((const xmlChar *)"/");
6490 
6491  /*
6492  * parse the content and register the pattern
6493  */
6495  template->elem = (xmlNodePtr) doc;
6496  template->content = doc->children;
6497  xsltAddTemplate(ret, template, NULL, NULL);
6498  ret->literal_result = 1;
6499  }
6500 
6501  return(ret);
6502 }
int xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, const xmlChar *mode, const xmlChar *modeURI)
Definition: pattern.c:2104
#define XSLT_NAMESPACE
Definition: xslt.h:46
static void xsltPreprocessStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:3469
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:54
xmlNode * xmlNodePtr
Definition: tree.h:488
static void xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1599
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:1735
Definition: tree.h:489
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
#define NULL
Definition: types.h:112
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:4882
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:6082
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xsltParseStylesheetInclude(), and xsltParseStylesheetUser().

◆ xsltParseStylesheetUser()

XSLTPUBFUN int XSLTCALL xsltParseStylesheetUser ( xsltStylesheetPtr  style,
xmlDocPtr  doc 
)

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

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

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

Definition at line 6547 of file xslt.c.

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

Referenced by xsltParseStylesheetImportedDoc().

◆ xsltParseTemplateContent()

XSLTPUBFUN void XSLTCALL xsltParseTemplateContent ( xsltStylesheetPtr  style,
xmlNodePtr  templ 
)

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

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

Definition at line 4882 of file xslt.c.

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

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
#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
#define NULL
Definition: types.h:112

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

400 {
401  if ((ctxt == NULL) || (RVT == NULL)) return(-1);
402 
403  RVT->psvi = XSLT_RVT_GLOBAL;
404  RVT->prev = NULL;
405  RVT->next = (xmlNodePtr) ctxt->persistRVT;
406  if (ctxt->persistRVT != NULL)
407  ctxt->persistRVT->prev = (xmlNodePtr) RVT;
408  ctxt->persistRVT = RVT;
409  return(0);
410 }
#define XSLT_RVT_GLOBAL
Definition: variables.h:62
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
#define NULL
Definition: types.h:112

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
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
#define NULL
Definition: types.h:112

◆ xsltReleaseRVT()

XSLTPUBFUN void XSLTCALL xsltReleaseRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

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

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

Definition at line 328 of file variables.c.

329 {
330  if (RVT == NULL)
331  return;
332 
333  if (ctxt && (ctxt->cache->nbRVT < 40)) {
334  /*
335  * Store the Result Tree Fragment.
336  * Free the document info.
337  */
338  if (RVT->_private != NULL) {
340  xmlFree(RVT->_private);
341  RVT->_private = NULL;
342  }
343  /*
344  * Clear the document tree.
345  * REVISIT TODO: Do we expect ID/IDREF tables to be existent?
346  */
347  if (RVT->children != NULL) {
349  RVT->children = NULL;
350  RVT->last = NULL;
351  }
352  if (RVT->ids != NULL) {
354  RVT->ids = NULL;
355  }
356  if (RVT->refs != NULL) {
358  RVT->refs = NULL;
359  }
360 
361  /*
362  * Reset the ownership information.
363  */
364  RVT->psvi = NULL;
365 
366  RVT->next = (xmlNodePtr) ctxt->cache->RVT;
367  ctxt->cache->RVT = RVT;
368 
369  ctxt->cache->nbRVT++;
370 
371 #ifdef XSLT_DEBUG_PROFILE_CACHE
372  ctxt->cache->dbgCachedRVTs++;
373 #endif
374  return;
375  }
376  /*
377  * Free it.
378  */
379  if (RVT->_private != NULL) {
381  xmlFree(RVT->_private);
382  }
383  xmlFreeDoc(RVT);
384 }
xsltTransformCachePtr cache
XMLPUBFUN void XMLCALL xmlFreeIDTable(xmlIDTablePtr table)
Definition: valid.c:2729
XMLPUBFUN void XMLCALL xmlFreeNodeList(xmlNodePtr cur)
void * refs
Definition: tree.h:576
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:925
#define NULL
Definition: types.h:112
struct _xmlNode * last
Definition: tree.h:556
struct _xmlNode * children
Definition: tree.h:555
XMLPUBFUN void XMLCALL xmlFreeRefTable(xmlRefTablePtr table)
Definition: valid.c:3071

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 }
#define NULL
Definition: types.h:112
XMLPUBFUN void XMLCALL xmlFreeRMutex(xmlRMutexPtr tok)
Definition: threads.c:319
static int initialized
Definition: xslt.c:193

Referenced by xsltCleanupGlobals().