Gnome XSLT Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# xsltInternals

## Name

xsltInternals --

## Synopsis

    #define     XSLT_MAX_SORT
    #define     XSLT_PAT_NO_PRIORITY
    struct      xsltRuntimeExtra;
    typedef     xsltRuntimeExtraPtr;
    #define     XSLT_RUNTIME_EXTRA_LST          (ctxt, nr)
    #define     XSLT_RUNTIME_EXTRA_FREE         (ctxt, nr)
    #define     XSLT_RUNTIME_EXTRA              (ctxt, nr)
    struct      xsltTemplate;
    typedef     xsltTemplatePtr;
    struct      xsltDecimalFormat;
    typedef     xsltDecimalFormatPtr;
    struct      xsltDocument;
    typedef     xsltDocumentPtr;
    struct      xsltTransformContext;
    typedef     xsltTransformContextPtr;
    struct      xsltElemPreComp;
    typedef     xsltElemPreCompPtr;
    void        (*xsltTransformFunction)        (xsltTransformContextPtr ctxt,
                                                 xmlNodePtr node,
                                                 xmlNodePtr inst,
                                                 xsltElemPreCompPtr comp);
    void        (*xsltSortFunc)                 (xsltTransformContextPtr ctxt,
                                                 xmlNodePtr *sorts,
                                                 int nbsorts);
    enum        xsltStyleType;
    void        (*xsltElemPreCompDeallocator)   (xsltElemPreCompPtr comp);
    struct      xsltStylePreComp;
    typedef     xsltStylePreCompPtr;
    struct      xsltStackElem;
    typedef     xsltStackElemPtr;
    struct      xsltStylesheet;
    typedef     xsltStylesheetPtr;
    enum        xsltOutputType;
    enum        xsltTransformState;
    #define     CHECK_STOPPED
    #define     CHECK_STOPPEDE
    #define     CHECK_STOPPED0
    xsltStylesheetPtr xsltNewStylesheet         (void);
    xsltStylesheetPtr xsltParseStylesheetFile   (const xmlChar *filename);
    void        xsltFreeStylesheet              (xsltStylesheetPtr sheet);
    int         xsltIsBlank                     (xmlChar *str);
    void        xsltFreeStackElemList           (xsltStackElemPtr elem);
    xsltDecimalFormatPtr xsltDecimalFormatGetByName
                                                (xsltStylesheetPtr sheet,
                                                 xmlChar *name);
    xsltStylesheetPtr xsltParseStylesheetProcess
                                                (xsltStylesheetPtr ret,
                                                 xmlDocPtr doc);
    void        xsltParseStylesheetOutput       (xsltStylesheetPtr style,
                                                 xmlNodePtr cur);
    xsltStylesheetPtr xsltParseStylesheetDoc    (xmlDocPtr doc);
    xsltStylesheetPtr xsltLoadStylesheetPI      (xmlDocPtr doc);
    void        xsltNumberFormat                (xsltTransformContextPtr ctxt,
                                                 xsltNumberDataPtr data,
                                                 xmlNodePtr node);
    xmlXPathError xsltFormatNumberConversion    (xsltDecimalFormatPtr self,
                                                 xmlChar *format,
                                                 double number,
                                                 xmlChar **result);
    void        xsltParseTemplateContent        (xsltStylesheetPtr style,
                                                 xmlNodePtr templ);
    int         xsltAllocateExtra               (xsltStylesheetPtr style);
    int         xsltAllocateExtraCtxt           (xsltTransformContextPtr ctxt);

## Description

## Details

### XSLT_MAX_SORT

    #define XSLT_MAX_SORT 15

Max number of specified xsl:sort on an element.

### XSLT_PAT_NO_PRIORITY

    #define XSLT_PAT_NO_PRIORITY -12345789

Specific value for pattern without priority expressed.

### struct xsltRuntimeExtra

    struct xsltRuntimeExtra {
        void       *info;		/* pointer to the extra data */
        xmlFreeFunc deallocate;	/* pointer to the deallocation routine */
        void       *val;		/* data not needing deallocation */
    };

Extra information added to the transformation context.

### xsltRuntimeExtraPtr

    typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;

### XSLT_RUNTIME_EXTRA_LST()

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

Macro used to access extra information stored in the context

`ctxt` : | the transformation context
`nr` : | the index

### XSLT_RUNTIME_EXTRA_FREE()

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

Macro used to free extra information stored in the context

`ctxt` : | the transformation context
`nr` : | the index

### XSLT_RUNTIME_EXTRA()

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

Macro used to define extra information stored in the context

`ctxt` : | the transformation context
`nr` : | the index

### struct xsltTemplate

    struct xsltTemplate {
        struct _xsltTemplate *next;/* chained list sorted by priority */
        struct _xsltStylesheet *style;/* the containing stylesheet */
        xmlChar *match;	/* the matching string */
        float priority;	/* as given from the stylesheet, not computed */
        xmlChar *name;	/* the local part of the name QName */
        xmlChar *nameURI;	/* the URI part of the name QName */
        xmlChar *mode;	/* the local part of the mode QName */
        xmlChar *modeURI;	/* the URI part of the mode QName */
        xmlNodePtr content;	/* the template replacement value */
        xmlNodePtr elem;	/* the source element */

        int inheritedNsNr;  /* number of inherited namespaces */
        xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */

        /* Profiling informations */
        int nbCalls;        /* the number of time the template was called */
        unsigned long time; /* the time spent in this template */
    };

The in-memory structure corresponding to an XSLT Template.

### xsltTemplatePtr

    typedef xsltTemplate *xsltTemplatePtr;

### struct xsltDecimalFormat

    struct xsltDecimalFormat {
        struct _xsltDecimalFormat *next; /* chained list */
        xmlChar *name;
        /* Used for interpretation of pattern */
        xmlChar *digit;
        xmlChar *patternSeparator;
        /* May appear in result */
        xmlChar *minusSign;
        xmlChar *infinity;
        xmlChar *noNumber; /* Not-a-number */
        /* Used for interpretation of pattern and may appear in result */
        xmlChar *decimalPoint;
        xmlChar *grouping;
        xmlChar *percent;
        xmlChar *permille;
        xmlChar *zeroDigit;
    };

Data structure of decimal-format.

### xsltDecimalFormatPtr

    typedef xsltDecimalFormat *xsltDecimalFormatPtr;

### struct xsltDocument

    struct xsltDocument {
        struct _xsltDocument *next;	/* documents are kept in a chained list */
        int main;			/* is this the main document */
        xmlDocPtr doc;		/* the parsed document */
        void *keys;			/* key tables storage */
    };

Data structure associated to a parsed document.

### xsltDocumentPtr

    typedef xsltDocument *xsltDocumentPtr;

### struct xsltTransformContext

    struct xsltTransformContext {
        xsltStylesheetPtr style;		/* the stylesheet used */
        xsltOutputType type;		/* the type of output */

        xsltTemplatePtr  templ;		/* the current template */
        int              templNr;		/* Nb of templates in the stack */
        int              templMax;		/* Size of the templtes stack */
        xsltTemplatePtr *templTab;		/* the template stack */

        xsltStackElemPtr  vars;		/* the current variable list */
        int               varsNr;		/* Nb of variable list in the stack */
        int               varsMax;		/* Size of the variable list stack */
        xsltStackElemPtr *varsTab;		/* the variable list stack */
        int               varsBase;		/* the var base for current templ */

        /*
         * Extensions
         */
        xmlHashTablePtr   extFunctions;	/* the extension functions */
        xmlHashTablePtr   extElements;	/* the extension elements */
        xmlHashTablePtr   extInfos;		/* the extension data */

        const xmlChar *mode;		/* the current mode */
        const xmlChar *modeURI;		/* the current mode URI */

        xsltDocumentPtr docList;		/* the document list */

        xsltDocumentPtr document;		/* the current document */
        xmlNodePtr node;			/* the current node being processed */
        xmlNodeSetPtr nodeList;		/* the current node list */
        /* xmlNodePtr current;			the node */

        xmlDocPtr output;			/* the resulting document */
        xmlNodePtr insert;			/* the insertion node */

        xmlXPathContextPtr xpathCtxt;	/* the XPath context */
        xsltTransformState state;		/* the current state */

        /*
         * Global variables
         */
        xmlHashTablePtr   globalVars;	/* the global variables and params */

        xmlNodePtr inst;			/* the instruction in the stylesheet */

        int xinclude;			/* should XInclude be processed */

        const char *      outputFile;	/* the output URI if known */

        int profile;                        /* is this run profiled */
        long             prof;		/* the current profiled value */
        int              profNr;		/* Nb of templates in the stack */
        int              profMax;		/* Size of the templtaes stack */
        long            *profTab;		/* the profile template stack */

        void            *_private;		/* user defined data */

        int              extrasNr;		/* the number of extras used */
        int              extrasMax;		/* the number of extras allocated */
        xsltRuntimeExtraPtr extras;		/* extra per runtime informations */

        xsltDocumentPtr  styleList;		/* the stylesheet docs list */
        void                 * sec;		/* the security preferences if any */

        xmlGenericErrorFunc  error;		/* a specific error handler */
        void              * errctx;		/* context for the error handler */

        xsltSortFunc      sortfunc;		/* a ctxt specific sort routine */
    };

### xsltTransformContextPtr

    typedef xsltTransformContext *xsltTransformContextPtr;

### struct xsltElemPreComp

    struct xsltElemPreComp {
        xsltElemPreCompPtr next;		/* chained list */
        xsltStyleType type;			/* type of the element */
        xsltTransformFunction func; 	/* handling function */
        xmlNodePtr inst;			/* the instruction */

        /* end of common part */
        xsltElemPreCompDeallocator free;	/* the deallocator */
    };

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

### xsltElemPreCompPtr

    typedef xsltElemPreComp *xsltElemPreCompPtr;

### xsltTransformFunction ()

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

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

`ctxt` : | the XSLT transformation context
`node` : | the input node
`inst` : | the stylesheet node
`comp` : | the compiled information from the stylesheet

### xsltSortFunc ()

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

Signature of the function to use during sorting

`ctxt` : | a transformation context
`sorts` : | the node-set to sort
`nbsorts` : | the number of sorts

### enum xsltStyleType

    typedef enum {
        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
    } xsltStyleType;

### xsltElemPreCompDeallocator ()

    void        (*xsltElemPreCompDeallocator)   (xsltElemPreCompPtr comp);

Deallocates an xsltElemPreComp structure.

`comp` : | the xsltElemPreComp to free up

### struct xsltStylePreComp

    struct xsltStylePreComp {
        xsltElemPreCompPtr next;	/* chained list */
        xsltStyleType type;		/* type of the element */
        xsltTransformFunction func; /* handling function */
        xmlNodePtr inst;		/* the instruction */

        /*
         * Pre computed values.
         */

        xmlChar *stype;             /* sort */
        int      has_stype;		/* sort */
        int      number;		/* sort */
        xmlChar *order;             /* sort */
        int      has_order;		/* sort */
        int      descending;	/* sort */
        xmlChar *lang;		/* sort */
        int      has_lang;		/* sort */
        xmlChar *case_order;	/* sort */
        int      lower_first;	/* sort */

        xmlChar *use;		/* copy, element */
        int      has_use;		/* copy, element */

        int      noescape;		/* text */

        xmlChar *name;		/* element, attribute, pi */
        int      has_name;		/* element, attribute, pi */
        xmlChar *ns;		/* element */
        int      has_ns;		/* element */

        xmlChar *mode;		/* apply-templates */
        xmlChar *modeURI;		/* apply-templates */

        xmlChar *test;		/* if */

        xsltTemplatePtr templ;	/* call-template */

        xmlChar *select;		/* sort, copy-of, value-of, apply-templates */

        int      ver11;		/* document */
        xmlChar *filename;		/* document URL */
        int      has_filename;	/* document */

        xsltNumberData numdata;	/* number */

        xmlXPathCompExprPtr comp;	/* a precompiled XPath expression */
        xmlNsPtr *nsList;		/* the namespaces in scope */
        int nsNr;			/* the number of namespaces in scope */
    };

The in-memory structure corresponding to XSLT stylesheet constructs precomputed data.

### xsltStylePreCompPtr

    typedef xsltStylePreComp *xsltStylePreCompPtr;

### struct xsltStackElem

    struct xsltStackElem {
        struct _xsltStackElem *next;/* chained list */
        xsltStylePreCompPtr comp;   /* the compiled form */
        int computed;	/* was the evaluation done */
        xmlChar *name;	/* the local part of the name QName */
        xmlChar *nameURI;	/* the URI part of the name QName */
        xmlChar *select;	/* the eval string */
        xmlNodePtr tree;	/* the tree if no eval string or the location */
        xmlXPathObjectPtr value; /* The value if computed */
    };

### xsltStackElemPtr

    typedef xsltStackElem *xsltStackElemPtr;

### struct xsltStylesheet

    struct xsltStylesheet {
        /*
         * The stylesheet import relation is kept as a tree.
         */
        struct _xsltStylesheet *parent;
        struct _xsltStylesheet *next;
        struct _xsltStylesheet *imports;

        xsltDocumentPtr docList;		/* the include document list */

        /*
         * General data on the style sheet document.
         */
        xmlDocPtr doc;		/* the parsed XML stylesheet */
        xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
    				   preserve space elements */
        int             stripAll;	/* strip-space * (1) preserve-space * (-1) */
        xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */

        /*
         * Global variable or parameters.
         */
        xsltStackElemPtr variables; /* linked list of param and variables */

        /*
         * Template descriptions.
         */
        xsltTemplatePtr templates;	/* the ordered list of templates */
        void *templatesHash;	/* hash table or wherever compiled templates
    				   informations are stored */
        void *rootMatch;		/* template based on / */
        void *keyMatch;		/* template based on key() */
        void *elemMatch;		/* template based on * */
        void *attrMatch;		/* template based on @* */
        void *parentMatch;		/* template based on .. */
        void *textMatch;		/* template based on text() */
        void *piMatch;		/* template based on processing-instruction() */
        void *commentMatch;		/* template based on comment() */

        /*
         * Namespace aliases.
         */
        xmlHashTablePtr nsAliases;	/* the namespace alias hash tables */

        /*
         * Attribute sets.
         */
        xmlHashTablePtr attributeSets;/* the attribute sets hash tables */

        /*
         * Namespaces.
         */
        xmlHashTablePtr nsHash;     /* the set of namespaces in use */
        void           *nsDefs;     /* the namespaces defined */

        /*
         * Key definitions.
         */
        void *keys;				/* key definitions */

        /*
         * Output related stuff.
         */
        xmlChar *method;		/* the output method */
        xmlChar *methodURI;		/* associated namespace if any */
        xmlChar *version;		/* version string */
        xmlChar *encoding;		/* encoding string */
        int omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */

        /*
         * Number formatting.
         */
        xsltDecimalFormatPtr decimalFormat;
        int standalone;             /* standalone = "yes" | "no" */
        xmlChar *doctypePublic;     /* doctype-public string */
        xmlChar *doctypeSystem;     /* doctype-system string */
        int indent;			/* should output being indented */
        xmlChar *mediaType;		/* media-type string */

        /*
         * Precomputed blocks.
         */
        xsltElemPreCompPtr preComps;/* list of precomputed blocks */
        int warnings;		/* number of warnings found at compilation */
        int errors;			/* number of errors found at compilation */

        xmlChar  *exclPrefix;	/* last excluded prefixes */
        xmlChar **exclPrefixTab;	/* array of excluded prefixes */
        int       exclPrefixNr;	/* number of excluded prefixes in scope */
        int       exclPrefixMax;	/* size of the array */

        void     *_private;		/* user defined data */

        /*
         * Extensions.
         */
        xmlHashTablePtr extInfos;	/* the extension data */
        int		    extrasNr;	/* the number of extras required */
    };

### xsltStylesheetPtr

    typedef xsltStylesheet *xsltStylesheetPtr;

### enum xsltOutputType

    typedef enum {
        XSLT_OUTPUT_XML = 0,
        XSLT_OUTPUT_HTML,
        XSLT_OUTPUT_TEXT
    } xsltOutputType;

### enum xsltTransformState

    typedef enum {
        XSLT_STATE_OK = 0,
        XSLT_STATE_ERROR,
        XSLT_STATE_STOPPED
    } xsltTransformState;

### CHECK_STOPPED

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

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

### CHECK_STOPPEDE

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

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

### CHECK_STOPPED0

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

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

### xsltNewStylesheet ()

    xsltStylesheetPtr xsltNewStylesheet         (void);

Create a new XSLT Stylesheet

Returns : | the newly allocated xsltStylesheetPtr or NULL in case of error

### xsltParseStylesheetFile ()

    xsltStylesheetPtr xsltParseStylesheetFile   (const xmlChar *filename);

Load and parse an XSLT stylesheet

`filename` : | the filename/URL to the stylesheet
Returns : | a new XSLT stylesheet structure.

### xsltFreeStylesheet ()

    void        xsltFreeStylesheet              (xsltStylesheetPtr sheet);

Free up the memory allocated by `sheet`

`sheet` : | an XSLT stylesheet

### xsltIsBlank ()

    int         xsltIsBlank                     (xmlChar *str);

Check if a string is ignorable

`str` : | a string
Returns : | 1 if the string is NULL or made of blanks chars, 0 otherwise

### xsltFreeStackElemList ()

    void        xsltFreeStackElemList           (xsltStackElemPtr elem);

Free up the memory allocated by `elem`

`elem` : | an XSLT stack element

### xsltDecimalFormatGetByName ()

    xsltDecimalFormatPtr xsltDecimalFormatGetByName
                                                (xsltStylesheetPtr sheet,
                                                 xmlChar *name);

Find decimal-format by name

`sheet` : | the XSLT stylesheet
`name` : | the decimal-format name to find
Returns : | the xsltDecimalFormatPtr

### xsltParseStylesheetProcess ()

    xsltStylesheetPtr xsltParseStylesheetProcess
                                                (xsltStylesheetPtr ret,
                                                 xmlDocPtr doc);

parse an XSLT stylesheet adding the associated structures

`ret` : | the XSLT stylesheet
`doc` : | and xmlDoc parsed XML
Returns : | the value of the 'ret' parameter if everything went right, NULL if something went amiss.

### xsltParseStylesheetOutput ()

    void        xsltParseStylesheetOutput       (xsltStylesheetPtr style,
                                                 xmlNodePtr cur);

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

`style` : | the XSLT stylesheet
`cur` : | the "output" element

### xsltParseStylesheetDoc ()

    xsltStylesheetPtr xsltParseStylesheetDoc    (xmlDocPtr doc);

parse an XSLT stylesheet building the associated structures

`doc` : | and xmlDoc parsed XML
Returns : | a new XSLT stylesheet structure.

### xsltLoadStylesheetPI ()

    xsltStylesheetPtr xsltLoadStylesheetPI      (xmlDocPtr doc);

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.

`doc` : | a document to process
Returns : | a new XSLT stylesheet structure or NULL if not found.

### xsltNumberFormat ()

    void        xsltNumberFormat                (xsltTransformContextPtr ctxt,
                                                 xsltNumberDataPtr data,
                                                 xmlNodePtr node);

Convert one number.

`ctxt` : | the XSLT transformation context
`data` : | the formatting informations
`node` : | the data to format

### xsltFormatNumberConversion ()

    xmlXPathError xsltFormatNumberConversion    (xsltDecimalFormatPtr self,
                                                 xmlChar *format,
                                                 double number,
                                                 xmlChar **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.

`self` : | the decimal format
`format` : | the format requested
`number` : | the value to format
`result` : | the place to ouput the result
Returns : | a possible XPath error

### xsltParseTemplateContent ()

    void        xsltParseTemplateContent        (xsltStylesheetPtr style,
                                                 xmlNodePtr templ);

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

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

### xsltAllocateExtra ()

    int         xsltAllocateExtra               (xsltStylesheetPtr style);

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

`style` : | an XSLT stylesheet
Returns : | the number of the slot

### xsltAllocateExtraCtxt ()

    int         xsltAllocateExtraCtxt           (xsltTransformContextPtr ctxt);

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

`ctxt` : | an XSLT transformation context
Returns : | the number of the slot

<<< Previous Page | Home | Up | Next Page >>>
keys | numbersInternals