2 * xsltInternals.h: internal data structures, constants and functions used
5 * See Copyright for the status of this software.
7 * Daniel.Veillard@imag.fr
10 #ifndef __XML_XSLT_INTERNALS_H__
11 #define __XML_XSLT_INTERNALS_H__
13 #include <libxml/tree.h>
14 #include <libxml/hash.h>
15 #include <libxml/xpath.h>
16 #include <libxslt/xslt.h>
23 * The in-memory structure corresponding to an XSLT Variable
32 typedef struct _xsltStackElem xsltStackElem;
33 typedef xsltStackElem *xsltStackElemPtr;
34 struct _xsltStackElem {
35 struct _xsltStackElem *next;/* chained list */
36 xsltElem type; /* type of the element */
37 int computed; /* was the evaluation done */
38 xmlChar *name; /* the local part of the name QName */
39 xmlChar *nameURI; /* the URI part of the name QName */
40 xmlChar *select; /* the eval string */
41 xmlNodePtr tree; /* the tree if no eval string */
42 xmlXPathObjectPtr value; /* The value if computed */
46 * The in-memory structure corresponding to an XSLT Template
48 #define XSLT_PAT_NO_PRIORITY -12345789
50 typedef struct _xsltTemplate xsltTemplate;
51 typedef xsltTemplate *xsltTemplatePtr;
52 struct _xsltTemplate {
53 struct _xsltTemplate *next;/* chained list sorted by priority */
54 struct _xsltStylesheet *style;/* the containing stylesheet */
55 xmlChar *match; /* the matching string */
56 float priority; /* as given from the stylesheet, not computed */
57 xmlChar *name; /* the local part of the name QName */
58 xmlChar *nameURI; /* the URI part of the name QName */
59 xmlChar *mode; /* the local part of the mode QName */
60 xmlChar *modeURI; /* the URI part of the mode QName */
61 xmlNodePtr content; /* the template replacement value */
62 xmlNodePtr elem; /* the source element */
66 * Data structure of decimal-format
68 typedef struct _xsltDecimalFormat {
69 struct _xsltDecimalFormat *next; /* chained list */
71 /* Used for interpretation of pattern */
73 xmlChar *patternSeparator;
74 /* May appear in result */
77 xmlChar *noNumber; /* Not-a-number */
78 /* Used for interpretation of pattern and may appear in result */
79 xmlChar *decimalPoint;
84 } xsltDecimalFormat, *xsltDecimalFormatPtr;
87 * Data structure associated to a document
90 typedef struct _xsltDocument xsltDocument;
91 typedef xsltDocument *xsltDocumentPtr;
92 struct _xsltDocument {
93 struct _xsltDocument *next; /* documents are kept in a chained list */
94 int main; /* is this the main document */
95 xmlDocPtr doc; /* the parsed document */
96 void *keys; /* key tables storage */
100 * The in-memory structure corresponding to an XSLT Stylesheet
101 * NOTE: most of the content is simply linked from the doc tree
102 * structure, no specific allocation is made.
104 typedef struct _xsltStylesheet xsltStylesheet;
105 typedef xsltStylesheet *xsltStylesheetPtr;
106 struct _xsltStylesheet {
108 * The stylesheet import relation is kept as a tree
110 struct _xsltStylesheet *parent;
111 struct _xsltStylesheet *next;
112 struct _xsltStylesheet *imports;
114 xsltDocumentPtr docList; /* the include document list */
117 * General data on the style sheet document
119 xmlDocPtr doc; /* the parsed XML stylesheet */
120 xmlHashTablePtr stripSpaces;/* the hash table of the strip-space
121 preserve space and cdata-section elements */
124 * Global variable or parameters
126 xsltStackElemPtr variables; /* linked list of param and variables */
129 * Template descriptions
131 xsltTemplatePtr templates; /* the ordered list of templates */
132 void *templatesHash; /* hash table or wherever compiled templates
133 informations are stored */
134 void *rootMatch; /* template based on / */
135 void *keyMatch; /* template based on key() */
136 void *elemMatch; /* template based on * */
137 void *attrMatch; /* template based on @* */
138 void *parentMatch; /* template based on .. */
139 void *textMatch; /* template based on text() */
140 void *piMatch; /* template based on processing-instruction() */
141 void *commentMatch; /* template based on comment() */
146 xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
151 xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
156 xmlHashTablePtr nsHash; /* the set of namespaces in use */
161 void *keys; /* key definitions */
164 * Output related stuff.
166 xmlChar *method; /* the output method */
167 xmlChar *methodURI; /* associated namespace if any */
168 xmlChar *version; /* version string */
169 xmlChar *encoding; /* encoding string */
170 int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */
172 /* Number formatting */
173 xsltDecimalFormatPtr decimalFormat;
174 int standalone; /* standalone = "yes" | "no" */
175 xmlChar *doctypePublic; /* doctype-public string */
176 xmlChar *doctypeSystem; /* doctype-system string */
177 int indent; /* should output being indented */
178 xmlChar *mediaType; /* media-type string */
183 * The in-memory structure corresponding to an XSLT Transformation
195 } xsltTransformState;
197 typedef struct _xsltTransformContext xsltTransformContext;
198 typedef xsltTransformContext *xsltTransformContextPtr;
199 struct _xsltTransformContext {
200 xsltStylesheetPtr style; /* the stylesheet used */
201 xsltOutputType type; /* the type of output */
203 xsltTemplatePtr templ; /* the current template */
204 int templNr; /* Nb of templates in the stack */
205 int templMax; /* Size of the templtes stack */
206 xsltTemplatePtr *templTab; /* the template stack */
208 xsltStackElemPtr vars; /* the current variable list */
209 int varsNr; /* Nb of variable list in the stack */
210 int varsMax; /* Size of the variable list stack */
211 xsltStackElemPtr *varsTab; /* the variable list stack */
212 int varsComputed; /* switched during param template
218 xmlHashTablePtr extFunctions; /* the extension functions */
219 xmlHashTablePtr extElements; /* the extension elements */
221 const xmlChar *mode; /* the current mode */
222 const xmlChar *modeURI; /* the current mode URI */
224 xsltDocumentPtr docList; /* the document list */
226 xsltDocumentPtr document; /* the current document */
227 xmlNodePtr node; /* the node being processed */
228 xmlNodeSetPtr nodeList; /* the current node list */
229 xmlNodePtr current; /* the current node */
231 xmlDocPtr output; /* the resulting document */
232 xmlNodePtr insert; /* the insertion node */
234 xmlXPathContextPtr xpathCtxt; /* the XPath context */
235 xsltTransformState state; /* the current state */
238 typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
239 xmlNodePtr node, xmlNodePtr inst);
241 #define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
242 #define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
243 #define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
246 * Functions associated to the internal types
247 xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
250 xsltStylesheetPtr xsltParseStylesheetFile (const xmlChar* filename);
251 void xsltFreeStylesheet (xsltStylesheetPtr sheet);
252 int xsltIsBlank (xmlChar *str);
253 void xsltFreeStackElemList (xsltStackElemPtr elem);
254 xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
257 xsltStylesheetPtr xsltParseStylesheetProcess(xsltStylesheetPtr ret,
259 xsltStylesheetPtr xsltParseStylesheetDoc (xmlDocPtr doc);
264 #endif /* __XML_XSLT_H__ */