Annotation of win32/gnome/libxslt-x.x.x/libxslt/xsltInternals.h, revision 1.1
1.1 ! paf 1: /*
! 2: * xsltInternals.h: internal data structures, constants and functions used
! 3: * by the XSLT engine
! 4: * They are not part of the API or ABI, i.e. they can change
! 5: * without prior notice, use carefully.
! 6: *
! 7: * See Copyright for the status of this software.
! 8: *
! 9: * daniel@veillard.com
! 10: */
! 11:
! 12: #ifndef __XML_XSLT_INTERNALS_H__
! 13: #define __XML_XSLT_INTERNALS_H__
! 14:
! 15: #include <libxml/tree.h>
! 16: #include <libxml/hash.h>
! 17: #include <libxml/xpath.h>
! 18: #include <libxslt/xslt.h>
! 19: #include "numbersInternals.h"
! 20:
! 21: #ifdef __cplusplus
! 22: extern "C" {
! 23: #endif
! 24:
! 25: /**
! 26: * XSLT_MAX_SORT:
! 27: *
! 28: * Max number of specified xsl:sort on an element
! 29: */
! 30: #define XSLT_MAX_SORT 5
! 31:
! 32: /**
! 33: * XSLT_PAT_NO_PRIORITY:
! 34: *
! 35: * specific value for pattern without priority expressed
! 36: */
! 37: #define XSLT_PAT_NO_PRIORITY -12345789
! 38:
! 39: /**
! 40: * xsltTemplate:
! 41: *
! 42: * The in-memory structure corresponding to an XSLT Template
! 43: */
! 44: typedef struct _xsltTemplate xsltTemplate;
! 45: typedef xsltTemplate *xsltTemplatePtr;
! 46: struct _xsltTemplate {
! 47: struct _xsltTemplate *next;/* chained list sorted by priority */
! 48: struct _xsltStylesheet *style;/* the containing stylesheet */
! 49: xmlChar *match; /* the matching string */
! 50: float priority; /* as given from the stylesheet, not computed */
! 51: xmlChar *name; /* the local part of the name QName */
! 52: xmlChar *nameURI; /* the URI part of the name QName */
! 53: xmlChar *mode; /* the local part of the mode QName */
! 54: xmlChar *modeURI; /* the URI part of the mode QName */
! 55: xmlNodePtr content; /* the template replacement value */
! 56: xmlNodePtr elem; /* the source element */
! 57:
! 58: int inheritedNsNr; /* number of inherited namespaces */
! 59: xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
! 60:
! 61: /* Profiling informations */
! 62: int nbCalls; /* the number of time the template was called */
! 63: unsigned long time; /* the time spent in this template */
! 64: };
! 65:
! 66: /**
! 67: * xsltDecimalFormat:
! 68: *
! 69: * Data structure of decimal-format
! 70: */
! 71: typedef struct _xsltDecimalFormat xsltDecimalFormat;
! 72: typedef xsltDecimalFormat *xsltDecimalFormatPtr;
! 73: struct _xsltDecimalFormat {
! 74: struct _xsltDecimalFormat *next; /* chained list */
! 75: xmlChar *name;
! 76: /* Used for interpretation of pattern */
! 77: xmlChar *digit;
! 78: xmlChar *patternSeparator;
! 79: /* May appear in result */
! 80: xmlChar *minusSign;
! 81: xmlChar *infinity;
! 82: xmlChar *noNumber; /* Not-a-number */
! 83: /* Used for interpretation of pattern and may appear in result */
! 84: xmlChar *decimalPoint;
! 85: xmlChar *grouping;
! 86: xmlChar *percent;
! 87: xmlChar *permille;
! 88: xmlChar *zeroDigit;
! 89: };
! 90:
! 91: /**
! 92: * xsltDocument:
! 93: *
! 94: * Data structure associated to a parsed document
! 95: */
! 96:
! 97: typedef struct _xsltDocument xsltDocument;
! 98: typedef xsltDocument *xsltDocumentPtr;
! 99: struct _xsltDocument {
! 100: struct _xsltDocument *next; /* documents are kept in a chained list */
! 101: int main; /* is this the main document */
! 102: xmlDocPtr doc; /* the parsed document */
! 103: void *keys; /* key tables storage */
! 104: };
! 105:
! 106: typedef struct _xsltTransformContext xsltTransformContext;
! 107: typedef xsltTransformContext *xsltTransformContextPtr;
! 108:
! 109: /**
! 110: * xsltElemPreComp:
! 111: *
! 112: * The in-memory structure corresponding to element precomputed data,
! 113: * designed to be extended by extension implementors.
! 114: */
! 115: typedef struct _xsltElemPreComp xsltElemPreComp;
! 116: typedef xsltElemPreComp *xsltElemPreCompPtr;
! 117:
! 118: /**
! 119: * xsltTransformFunction:
! 120: * @ctxt: the XSLT transformation context
! 121: * @node: the input node
! 122: * @inst: the stylesheet node
! 123: * @comp: the compiled information from the stylesheet
! 124: *
! 125: * signature of the function associated to elements part of the
! 126: * stylesheet language like xsl:if or xsl:apply-templates.
! 127: */
! 128: typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
! 129: xmlNodePtr node,
! 130: xmlNodePtr inst,
! 131: xsltElemPreCompPtr comp);
! 132:
! 133: typedef enum {
! 134: XSLT_FUNC_COPY=1,
! 135: XSLT_FUNC_SORT,
! 136: XSLT_FUNC_TEXT,
! 137: XSLT_FUNC_ELEMENT,
! 138: XSLT_FUNC_ATTRIBUTE,
! 139: XSLT_FUNC_COMMENT,
! 140: XSLT_FUNC_PI,
! 141: XSLT_FUNC_COPYOF,
! 142: XSLT_FUNC_VALUEOF,
! 143: XSLT_FUNC_NUMBER,
! 144: XSLT_FUNC_APPLYIMPORTS,
! 145: XSLT_FUNC_CALLTEMPLATE,
! 146: XSLT_FUNC_APPLYTEMPLATES,
! 147: XSLT_FUNC_CHOOSE,
! 148: XSLT_FUNC_IF,
! 149: XSLT_FUNC_FOREACH,
! 150: XSLT_FUNC_DOCUMENT,
! 151: XSLT_FUNC_WITHPARAM,
! 152: XSLT_FUNC_PARAM,
! 153: XSLT_FUNC_VARIABLE,
! 154: XSLT_FUNC_WHEN,
! 155: XSLT_FUNC_EXTENSION
! 156: } xsltStyleType;
! 157:
! 158: /**
! 159: * xsltElemPreCompDeallocator:
! 160: * @comp: the #xsltElemPreComp to free up
! 161: *
! 162: * Deallocates an #xsltElemPreComp structure
! 163: */
! 164: typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
! 165:
! 166: /**
! 167: * xsltElemPreComp:
! 168: *
! 169: * The in-memory structure corresponding to element precomputed data,
! 170: * designed to be extended by extension implementors.
! 171: */
! 172: struct _xsltElemPreComp {
! 173: xsltElemPreCompPtr next; /* chained list */
! 174: xsltStyleType type; /* type of the element */
! 175: xsltTransformFunction func; /* handling function */
! 176: xmlNodePtr inst; /* the instruction */
! 177:
! 178: /* end of common part */
! 179: xsltElemPreCompDeallocator free; /* the deallocator */
! 180: };
! 181:
! 182: /**
! 183: * xsltStylePreComp:
! 184: *
! 185: * The in-memory structure corresponding to XSLT stylesheet constructs
! 186: * precomputed data.
! 187: */
! 188: typedef struct _xsltStylePreComp xsltStylePreComp;
! 189: typedef xsltStylePreComp *xsltStylePreCompPtr;
! 190: struct _xsltStylePreComp {
! 191: xsltElemPreCompPtr next; /* chained list */
! 192: xsltStyleType type; /* type of the element */
! 193: xsltTransformFunction func; /* handling function */
! 194: xmlNodePtr inst; /* the instruction */
! 195:
! 196: /*
! 197: * Pre computed values
! 198: */
! 199:
! 200: xmlChar *stype; /* sort */
! 201: int has_stype; /* sort */
! 202: int number; /* sort */
! 203: xmlChar *order; /* sort */
! 204: int has_order; /* sort */
! 205: int descending; /* sort */
! 206:
! 207: xmlChar *use; /* copy, element */
! 208: int has_use; /* copy, element */
! 209:
! 210: int noescape; /* text */
! 211:
! 212: xmlChar *name; /* element, attribute, pi */
! 213: int has_name; /* element, attribute, pi */
! 214: xmlChar *ns; /* element */
! 215: int has_ns; /* element */
! 216:
! 217: xmlChar *mode; /* apply-templates */
! 218: xmlChar *modeURI; /* apply-templates */
! 219:
! 220: xmlChar *test; /* if */
! 221:
! 222: xsltTemplatePtr templ; /* call-template */
! 223:
! 224: xmlChar *select; /* sort, copy-of, value-of, apply-templates */
! 225:
! 226: int ver11; /* document */
! 227: xmlChar *filename; /* document URL */
! 228: int has_filename; /* document */
! 229:
! 230: xsltNumberData numdata; /* number */
! 231:
! 232: xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
! 233: xmlNsPtr *nsList; /* the namespaces in scope */
! 234: int nsNr; /* the number of namespaces in scope */
! 235: };
! 236:
! 237: /*
! 238: * The in-memory structure corresponding to an XSLT Variable
! 239: * or Param
! 240: */
! 241:
! 242: typedef struct _xsltStackElem xsltStackElem;
! 243: typedef xsltStackElem *xsltStackElemPtr;
! 244: struct _xsltStackElem {
! 245: struct _xsltStackElem *next;/* chained list */
! 246: xsltStylePreCompPtr comp; /* the compiled form */
! 247: int computed; /* was the evaluation done */
! 248: xmlChar *name; /* the local part of the name QName */
! 249: xmlChar *nameURI; /* the URI part of the name QName */
! 250: xmlChar *select; /* the eval string */
! 251: xmlNodePtr tree; /* the tree if no eval string or the location */
! 252: xmlXPathObjectPtr value; /* The value if computed */
! 253: };
! 254:
! 255: /*
! 256: * The in-memory structure corresponding to an XSLT Stylesheet
! 257: * NOTE: most of the content is simply linked from the doc tree
! 258: * structure, no specific allocation is made.
! 259: */
! 260: typedef struct _xsltStylesheet xsltStylesheet;
! 261: typedef xsltStylesheet *xsltStylesheetPtr;
! 262: struct _xsltStylesheet {
! 263: /*
! 264: * The stylesheet import relation is kept as a tree
! 265: */
! 266: struct _xsltStylesheet *parent;
! 267: struct _xsltStylesheet *next;
! 268: struct _xsltStylesheet *imports;
! 269:
! 270: xsltDocumentPtr docList; /* the include document list */
! 271:
! 272: /*
! 273: * General data on the style sheet document
! 274: */
! 275: xmlDocPtr doc; /* the parsed XML stylesheet */
! 276: xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
! 277: preserve space elements */
! 278: int stripAll; /* strip-space * (1) preserve-space * (-1) */
! 279: xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
! 280:
! 281: /*
! 282: * Global variable or parameters
! 283: */
! 284: xsltStackElemPtr variables; /* linked list of param and variables */
! 285:
! 286: /*
! 287: * Template descriptions
! 288: */
! 289: xsltTemplatePtr templates; /* the ordered list of templates */
! 290: void *templatesHash; /* hash table or wherever compiled templates
! 291: informations are stored */
! 292: void *rootMatch; /* template based on / */
! 293: void *keyMatch; /* template based on key() */
! 294: void *elemMatch; /* template based on * */
! 295: void *attrMatch; /* template based on @* */
! 296: void *parentMatch; /* template based on .. */
! 297: void *textMatch; /* template based on text() */
! 298: void *piMatch; /* template based on processing-instruction() */
! 299: void *commentMatch; /* template based on comment() */
! 300:
! 301: /*
! 302: * Namespace aliases
! 303: */
! 304: xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
! 305:
! 306: /*
! 307: * Attribute sets
! 308: */
! 309: xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
! 310:
! 311: /*
! 312: * Namespaces
! 313: */
! 314: xmlHashTablePtr nsHash; /* the set of namespaces in use */
! 315: void *nsDefs; /* the namespaces defined */
! 316:
! 317: /*
! 318: * Key definitions
! 319: */
! 320: void *keys; /* key definitions */
! 321:
! 322: /*
! 323: * Output related stuff.
! 324: */
! 325: xmlChar *method; /* the output method */
! 326: xmlChar *methodURI; /* associated namespace if any */
! 327: xmlChar *version; /* version string */
! 328: xmlChar *encoding; /* encoding string */
! 329: int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */
! 330:
! 331: /* Number formatting */
! 332: xsltDecimalFormatPtr decimalFormat;
! 333: int standalone; /* standalone = "yes" | "no" */
! 334: xmlChar *doctypePublic; /* doctype-public string */
! 335: xmlChar *doctypeSystem; /* doctype-system string */
! 336: int indent; /* should output being indented */
! 337: xmlChar *mediaType; /* media-type string */
! 338:
! 339: /*
! 340: * Precomputed blocks
! 341: */
! 342: xsltElemPreCompPtr preComps;/* list of precomputed blocks */
! 343: int warnings; /* number of warnings found at compilation */
! 344: int errors; /* number of errors found at compilation */
! 345:
! 346: xmlChar *exclPrefix; /* last excluded prefixes */
! 347: xmlChar **exclPrefixTab; /* array of excluded prefixes */
! 348: int exclPrefixNr; /* number of excluded prefixes in scope */
! 349: int exclPrefixMax; /* size of the array */
! 350:
! 351: void *_private; /* user defined data */
! 352:
! 353: /*
! 354: * Extensions
! 355: */
! 356: xmlHashTablePtr extInfos; /* the extension data */
! 357: };
! 358:
! 359: /*
! 360: * The in-memory structure corresponding to an XSLT Transformation
! 361: */
! 362: typedef enum {
! 363: XSLT_OUTPUT_XML = 0,
! 364: XSLT_OUTPUT_HTML,
! 365: XSLT_OUTPUT_TEXT
! 366: } xsltOutputType;
! 367:
! 368: typedef enum {
! 369: XSLT_STATE_OK = 0,
! 370: XSLT_STATE_ERROR,
! 371: XSLT_STATE_STOPPED
! 372: } xsltTransformState;
! 373:
! 374: struct _xsltTransformContext {
! 375: xsltStylesheetPtr style; /* the stylesheet used */
! 376: xsltOutputType type; /* the type of output */
! 377:
! 378: xsltTemplatePtr templ; /* the current template */
! 379: int templNr; /* Nb of templates in the stack */
! 380: int templMax; /* Size of the templtes stack */
! 381: xsltTemplatePtr *templTab; /* the template stack */
! 382:
! 383: xsltStackElemPtr vars; /* the current variable list */
! 384: int varsNr; /* Nb of variable list in the stack */
! 385: int varsMax; /* Size of the variable list stack */
! 386: xsltStackElemPtr *varsTab; /* the variable list stack */
! 387: int varsBase; /* the var base for current templ */
! 388:
! 389: /*
! 390: * Extensions
! 391: */
! 392: xmlHashTablePtr extFunctions; /* the extension functions */
! 393: xmlHashTablePtr extElements; /* the extension elements */
! 394: xmlHashTablePtr extInfos; /* the extension data */
! 395:
! 396: const xmlChar *mode; /* the current mode */
! 397: const xmlChar *modeURI; /* the current mode URI */
! 398:
! 399: xsltDocumentPtr docList; /* the document list */
! 400:
! 401: xsltDocumentPtr document; /* the current document */
! 402: xmlNodePtr node; /* the current node being processed */
! 403: xmlNodeSetPtr nodeList; /* the current node list */
! 404: /* xmlNodePtr current; the node */
! 405:
! 406: xmlDocPtr output; /* the resulting document */
! 407: xmlNodePtr insert; /* the insertion node */
! 408:
! 409: xmlXPathContextPtr xpathCtxt; /* the XPath context */
! 410: xsltTransformState state; /* the current state */
! 411:
! 412: /*
! 413: * Global variables
! 414: */
! 415: xmlHashTablePtr globalVars; /* the global variables and params */
! 416:
! 417: xmlNodePtr inst; /* the instruction in the stylesheet */
! 418:
! 419: int xinclude; /* should XInclude be processed */
! 420:
! 421: const char * outputFile; /* the output URI if known */
! 422:
! 423: int profile; /* is this run profiled */
! 424: long prof; /* the current profiled value */
! 425: int profNr; /* Nb of templates in the stack */
! 426: int profMax; /* Size of the templtaes stack */
! 427: long *profTab; /* the profile template stack */
! 428:
! 429: void *_private; /* user defined data */
! 430: };
! 431:
! 432: /**
! 433: * CHECK_STOPPED:
! 434: *
! 435: * Macro to check if the XSLT processing should be stopped
! 436: * will return from the function
! 437: */
! 438: #define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
! 439:
! 440: /**
! 441: * CHECK_STOPPEDE:
! 442: *
! 443: * Macro to check if the XSLT processing should be stopped
! 444: * will goto the error: label
! 445: */
! 446: #define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
! 447:
! 448: /**
! 449: * CHECK_STOPPED0:
! 450: *
! 451: * Macro to check if the XSLT processing should be stopped
! 452: * will return from the function with a 0 value
! 453: */
! 454: #define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
! 455:
! 456: /*
! 457: * Functions associated to the internal types
! 458: xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
! 459: xmlChar *name);
! 460: */
! 461: xsltStylesheetPtr xsltNewStylesheet (void);
! 462: xsltStylesheetPtr xsltParseStylesheetFile (const xmlChar* filename);
! 463: void xsltFreeStylesheet (xsltStylesheetPtr sheet);
! 464: int xsltIsBlank (xmlChar *str);
! 465: void xsltFreeStackElemList (xsltStackElemPtr elem);
! 466: xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
! 467: xmlChar *name);
! 468:
! 469: xsltStylesheetPtr xsltParseStylesheetProcess(xsltStylesheetPtr ret,
! 470: xmlDocPtr doc);
! 471: void xsltParseStylesheetOutput(xsltStylesheetPtr style,
! 472: xmlNodePtr cur);
! 473: xsltStylesheetPtr xsltParseStylesheetDoc (xmlDocPtr doc);
! 474: xsltStylesheetPtr xsltLoadStylesheetPI (xmlDocPtr doc);
! 475: void xsltNumberFormat (xsltTransformContextPtr ctxt,
! 476: xsltNumberDataPtr data,
! 477: xmlNodePtr node);
! 478: xmlXPathError xsltFormatNumberConversion(xsltDecimalFormatPtr self,
! 479: xmlChar *format,
! 480: double number,
! 481: xmlChar **result);
! 482:
! 483: void xsltParseTemplateContent(xsltStylesheetPtr style,
! 484: xmlNodePtr templ);
! 485:
! 486: #ifdef __cplusplus
! 487: }
! 488: #endif
! 489:
! 490: #endif /* __XML_XSLT_H__ */
! 491:
E-mail: