xsltInternals.h 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992
  1. /*
  2. * Summary: internal data structures, constants and functions
  3. * Description: Internal data structures, constants and functions used
  4. * by the XSLT engine.
  5. * They are not part of the API or ABI, i.e. they can change
  6. * without prior notice, use carefully.
  7. *
  8. * Copy: See Copyright for the status of this software.
  9. *
  10. * Author: Daniel Veillard
  11. */
  12. #ifndef __XML_XSLT_INTERNALS_H__
  13. #define __XML_XSLT_INTERNALS_H__
  14. #include <libxml/tree.h>
  15. #include <libxml/hash.h>
  16. #include <libxml/xpath.h>
  17. #include <libxml/xmlerror.h>
  18. #include <libxml/dict.h>
  19. #include <libxml/xmlstring.h>
  20. #include <libxslt/xslt.h>
  21. #include "xsltexports.h"
  22. #include "numbersInternals.h"
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* #define XSLT_DEBUG_PROFILE_CACHE */
  27. /**
  28. * XSLT_IS_TEXT_NODE:
  29. *
  30. * check if the argument is a text node
  31. */
  32. #define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \
  33. (((n)->type == XML_TEXT_NODE) || \
  34. ((n)->type == XML_CDATA_SECTION_NODE)))
  35. /**
  36. * XSLT_MARK_RES_TREE_FRAG:
  37. *
  38. * internal macro to set up tree fragments
  39. */
  40. #define XSLT_MARK_RES_TREE_FRAG(n) \
  41. (n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");
  42. /**
  43. * XSLT_IS_RES_TREE_FRAG:
  44. *
  45. * internal macro to test tree fragments
  46. */
  47. #define XSLT_IS_RES_TREE_FRAG(n) \
  48. ((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \
  49. ((n)->name != NULL) && ((n)->name[0] == ' '))
  50. /**
  51. * XSLT_REFACTORED_KEYCOMP:
  52. *
  53. * Internal define to enable on-demand xsl:key computation.
  54. * That's the only mode now but the define is kept for compatibility
  55. */
  56. #define XSLT_REFACTORED_KEYCOMP
  57. /**
  58. * XSLT_FAST_IF:
  59. *
  60. * Internal define to enable usage of xmlXPathCompiledEvalToBoolean()
  61. * for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">
  62. */
  63. #define XSLT_FAST_IF
  64. /**
  65. * XSLT_REFACTORED:
  66. *
  67. * Internal define to enable the refactored parts of Libxslt.
  68. */
  69. /* #define XSLT_REFACTORED */
  70. /* ==================================================================== */
  71. /**
  72. * XSLT_REFACTORED_VARS:
  73. *
  74. * Internal define to enable the refactored variable part of libxslt
  75. */
  76. #define XSLT_REFACTORED_VARS
  77. #ifdef XSLT_REFACTORED
  78. extern const xmlChar *xsltXSLTAttrMarker;
  79. /* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
  80. /* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
  81. /**
  82. * XSLT_REFACTORED_XSLT_NSCOMP
  83. *
  84. * Internal define to enable the pointer-comparison of
  85. * namespaces of XSLT elements.
  86. */
  87. /* #define XSLT_REFACTORED_XSLT_NSCOMP */
  88. #ifdef XSLT_REFACTORED_XSLT_NSCOMP
  89. extern const xmlChar *xsltConstNamespaceNameXSLT;
  90. /**
  91. * IS_XSLT_ELEM_FAST:
  92. *
  93. * quick test to detect XSLT elements
  94. */
  95. #define IS_XSLT_ELEM_FAST(n) \
  96. (((n) != NULL) && ((n)->ns != NULL) && \
  97. ((n)->ns->href == xsltConstNamespaceNameXSLT))
  98. /**
  99. * IS_XSLT_ATTR_FAST:
  100. *
  101. * quick test to detect XSLT attributes
  102. */
  103. #define IS_XSLT_ATTR_FAST(a) \
  104. (((a) != NULL) && ((a)->ns != NULL) && \
  105. ((a)->ns->href == xsltConstNamespaceNameXSLT))
  106. /**
  107. * XSLT_HAS_INTERNAL_NSMAP:
  108. *
  109. * check for namespace mapping
  110. */
  111. #define XSLT_HAS_INTERNAL_NSMAP(s) \
  112. (((s) != NULL) && ((s)->principal) && \
  113. ((s)->principal->principalData) && \
  114. ((s)->principal->principalData->nsMap))
  115. /**
  116. * XSLT_GET_INTERNAL_NSMAP:
  117. *
  118. * get pointer to namespace map
  119. */
  120. #define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
  121. #else /* XSLT_REFACTORED_XSLT_NSCOMP */
  122. /**
  123. * IS_XSLT_ELEM_FAST:
  124. *
  125. * quick check whether this is an xslt element
  126. */
  127. #define IS_XSLT_ELEM_FAST(n) \
  128. (((n) != NULL) && ((n)->ns != NULL) && \
  129. (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
  130. /**
  131. * IS_XSLT_ATTR_FAST:
  132. *
  133. * quick check for xslt namespace attribute
  134. */
  135. #define IS_XSLT_ATTR_FAST(a) \
  136. (((a) != NULL) && ((a)->ns != NULL) && \
  137. (xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
  138. #endif /* XSLT_REFACTORED_XSLT_NSCOMP */
  139. /**
  140. * XSLT_REFACTORED_MANDATORY_VERSION:
  141. *
  142. * TODO: Currently disabled to surpress regression test failures, since
  143. * the old behaviour was that a missing version attribute
  144. * produced a only a warning and not an error, which was incerrect.
  145. * So the regression tests need to be fixed if this is enabled.
  146. */
  147. /* #define XSLT_REFACTORED_MANDATORY_VERSION */
  148. /**
  149. * xsltPointerList:
  150. *
  151. * Pointer-list for various purposes.
  152. */
  153. typedef struct _xsltPointerList xsltPointerList;
  154. typedef xsltPointerList *xsltPointerListPtr;
  155. struct _xsltPointerList {
  156. void **items;
  157. int number;
  158. int size;
  159. };
  160. #endif
  161. /**
  162. * XSLT_REFACTORED_PARSING:
  163. *
  164. * Internal define to enable the refactored parts of Libxslt
  165. * related to parsing.
  166. */
  167. /* #define XSLT_REFACTORED_PARSING */
  168. /**
  169. * XSLT_MAX_SORT:
  170. *
  171. * Max number of specified xsl:sort on an element.
  172. */
  173. #define XSLT_MAX_SORT 15
  174. /**
  175. * XSLT_PAT_NO_PRIORITY:
  176. *
  177. * Specific value for pattern without priority expressed.
  178. */
  179. #define XSLT_PAT_NO_PRIORITY -12345789
  180. /**
  181. * xsltRuntimeExtra:
  182. *
  183. * Extra information added to the transformation context.
  184. */
  185. typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
  186. typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
  187. struct _xsltRuntimeExtra {
  188. void *info; /* pointer to the extra data */
  189. xmlFreeFunc deallocate; /* pointer to the deallocation routine */
  190. union { /* dual-purpose field */
  191. void *ptr; /* data not needing deallocation */
  192. int ival; /* integer value storage */
  193. } val;
  194. };
  195. /**
  196. * XSLT_RUNTIME_EXTRA_LST:
  197. * @ctxt: the transformation context
  198. * @nr: the index
  199. *
  200. * Macro used to access extra information stored in the context
  201. */
  202. #define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
  203. /**
  204. * XSLT_RUNTIME_EXTRA_FREE:
  205. * @ctxt: the transformation context
  206. * @nr: the index
  207. *
  208. * Macro used to free extra information stored in the context
  209. */
  210. #define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
  211. /**
  212. * XSLT_RUNTIME_EXTRA:
  213. * @ctxt: the transformation context
  214. * @nr: the index
  215. *
  216. * Macro used to define extra information stored in the context
  217. */
  218. #define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
  219. /**
  220. * xsltTemplate:
  221. *
  222. * The in-memory structure corresponding to an XSLT Template.
  223. */
  224. typedef struct _xsltTemplate xsltTemplate;
  225. typedef xsltTemplate *xsltTemplatePtr;
  226. struct _xsltTemplate {
  227. struct _xsltTemplate *next;/* chained list sorted by priority */
  228. struct _xsltStylesheet *style;/* the containing stylesheet */
  229. xmlChar *match; /* the matching string */
  230. float priority; /* as given from the stylesheet, not computed */
  231. const xmlChar *name; /* the local part of the name QName */
  232. const xmlChar *nameURI; /* the URI part of the name QName */
  233. const xmlChar *mode;/* the local part of the mode QName */
  234. const xmlChar *modeURI;/* the URI part of the mode QName */
  235. xmlNodePtr content; /* the template replacement value */
  236. xmlNodePtr elem; /* the source element */
  237. /*
  238. * TODO: @inheritedNsNr and @inheritedNs won't be used in the
  239. * refactored code.
  240. */
  241. int inheritedNsNr; /* number of inherited namespaces */
  242. xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
  243. /* Profiling information */
  244. int nbCalls; /* the number of time the template was called */
  245. unsigned long time; /* the time spent in this template */
  246. void *params; /* xsl:param instructions */
  247. int templNr; /* Nb of templates in the stack */
  248. int templMax; /* Size of the templtes stack */
  249. xsltTemplatePtr *templCalledTab; /* templates called */
  250. int *templCountTab; /* .. and how often */
  251. /* Conflict resolution */
  252. int position;
  253. };
  254. /**
  255. * xsltDecimalFormat:
  256. *
  257. * Data structure of decimal-format.
  258. */
  259. typedef struct _xsltDecimalFormat xsltDecimalFormat;
  260. typedef xsltDecimalFormat *xsltDecimalFormatPtr;
  261. struct _xsltDecimalFormat {
  262. struct _xsltDecimalFormat *next; /* chained list */
  263. xmlChar *name;
  264. /* Used for interpretation of pattern */
  265. xmlChar *digit;
  266. xmlChar *patternSeparator;
  267. /* May appear in result */
  268. xmlChar *minusSign;
  269. xmlChar *infinity;
  270. xmlChar *noNumber; /* Not-a-number */
  271. /* Used for interpretation of pattern and may appear in result */
  272. xmlChar *decimalPoint;
  273. xmlChar *grouping;
  274. xmlChar *percent;
  275. xmlChar *permille;
  276. xmlChar *zeroDigit;
  277. const xmlChar *nsUri;
  278. };
  279. /**
  280. * xsltDocument:
  281. *
  282. * Data structure associated to a parsed document.
  283. */
  284. typedef struct _xsltDocument xsltDocument;
  285. typedef xsltDocument *xsltDocumentPtr;
  286. struct _xsltDocument {
  287. struct _xsltDocument *next; /* documents are kept in a chained list */
  288. int main; /* is this the main document */
  289. xmlDocPtr doc; /* the parsed document */
  290. void *keys; /* key tables storage */
  291. struct _xsltDocument *includes; /* subsidiary includes */
  292. int preproc; /* pre-processing already done */
  293. int nbKeysComputed;
  294. };
  295. /**
  296. * xsltKeyDef:
  297. *
  298. * Representation of an xsl:key.
  299. */
  300. typedef struct _xsltKeyDef xsltKeyDef;
  301. typedef xsltKeyDef *xsltKeyDefPtr;
  302. struct _xsltKeyDef {
  303. struct _xsltKeyDef *next;
  304. xmlNodePtr inst;
  305. xmlChar *name;
  306. xmlChar *nameURI;
  307. xmlChar *match;
  308. xmlChar *use;
  309. xmlXPathCompExprPtr comp;
  310. xmlXPathCompExprPtr usecomp;
  311. xmlNsPtr *nsList; /* the namespaces in scope */
  312. int nsNr; /* the number of namespaces in scope */
  313. };
  314. /**
  315. * xsltKeyTable:
  316. *
  317. * Holds the computed keys for key definitions of the same QName.
  318. * Is owned by an xsltDocument.
  319. */
  320. typedef struct _xsltKeyTable xsltKeyTable;
  321. typedef xsltKeyTable *xsltKeyTablePtr;
  322. struct _xsltKeyTable {
  323. struct _xsltKeyTable *next;
  324. xmlChar *name;
  325. xmlChar *nameURI;
  326. xmlHashTablePtr keys;
  327. };
  328. /*
  329. * The in-memory structure corresponding to an XSLT Stylesheet.
  330. * NOTE: most of the content is simply linked from the doc tree
  331. * structure, no specific allocation is made.
  332. */
  333. typedef struct _xsltStylesheet xsltStylesheet;
  334. typedef xsltStylesheet *xsltStylesheetPtr;
  335. typedef struct _xsltTransformContext xsltTransformContext;
  336. typedef xsltTransformContext *xsltTransformContextPtr;
  337. /**
  338. * xsltElemPreComp:
  339. *
  340. * The in-memory structure corresponding to element precomputed data,
  341. * designed to be extended by extension implementors.
  342. */
  343. typedef struct _xsltElemPreComp xsltElemPreComp;
  344. typedef xsltElemPreComp *xsltElemPreCompPtr;
  345. /**
  346. * xsltTransformFunction:
  347. * @ctxt: the XSLT transformation context
  348. * @node: the input node
  349. * @inst: the stylesheet node
  350. * @comp: the compiled information from the stylesheet
  351. *
  352. * Signature of the function associated to elements part of the
  353. * stylesheet language like xsl:if or xsl:apply-templates.
  354. */
  355. typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
  356. xmlNodePtr node,
  357. xmlNodePtr inst,
  358. xsltElemPreCompPtr comp);
  359. /**
  360. * xsltSortFunc:
  361. * @ctxt: a transformation context
  362. * @sorts: the node-set to sort
  363. * @nbsorts: the number of sorts
  364. *
  365. * Signature of the function to use during sorting
  366. */
  367. typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
  368. int nbsorts);
  369. typedef enum {
  370. XSLT_FUNC_COPY=1,
  371. XSLT_FUNC_SORT,
  372. XSLT_FUNC_TEXT,
  373. XSLT_FUNC_ELEMENT,
  374. XSLT_FUNC_ATTRIBUTE,
  375. XSLT_FUNC_COMMENT,
  376. XSLT_FUNC_PI,
  377. XSLT_FUNC_COPYOF,
  378. XSLT_FUNC_VALUEOF,
  379. XSLT_FUNC_NUMBER,
  380. XSLT_FUNC_APPLYIMPORTS,
  381. XSLT_FUNC_CALLTEMPLATE,
  382. XSLT_FUNC_APPLYTEMPLATES,
  383. XSLT_FUNC_CHOOSE,
  384. XSLT_FUNC_IF,
  385. XSLT_FUNC_FOREACH,
  386. XSLT_FUNC_DOCUMENT,
  387. XSLT_FUNC_WITHPARAM,
  388. XSLT_FUNC_PARAM,
  389. XSLT_FUNC_VARIABLE,
  390. XSLT_FUNC_WHEN,
  391. XSLT_FUNC_EXTENSION
  392. #ifdef XSLT_REFACTORED
  393. ,
  394. XSLT_FUNC_OTHERWISE,
  395. XSLT_FUNC_FALLBACK,
  396. XSLT_FUNC_MESSAGE,
  397. XSLT_FUNC_INCLUDE,
  398. XSLT_FUNC_ATTRSET,
  399. XSLT_FUNC_LITERAL_RESULT_ELEMENT,
  400. XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
  401. #endif
  402. } xsltStyleType;
  403. /**
  404. * xsltElemPreCompDeallocator:
  405. * @comp: the #xsltElemPreComp to free up
  406. *
  407. * Deallocates an #xsltElemPreComp structure.
  408. */
  409. typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
  410. /**
  411. * xsltElemPreComp:
  412. *
  413. * The basic structure for compiled items of the AST of the XSLT processor.
  414. * This structure is also intended to be extended by extension implementors.
  415. * TODO: This is somehow not nice, since it has a "free" field, which
  416. * derived stylesheet-structs do not have.
  417. */
  418. struct _xsltElemPreComp {
  419. xsltElemPreCompPtr next; /* next item in the global chained
  420. list held by xsltStylesheet. */
  421. xsltStyleType type; /* type of the element */
  422. xsltTransformFunction func; /* handling function */
  423. xmlNodePtr inst; /* the node in the stylesheet's tree
  424. corresponding to this item */
  425. /* end of common part */
  426. xsltElemPreCompDeallocator free; /* the deallocator */
  427. };
  428. /**
  429. * xsltStylePreComp:
  430. *
  431. * The abstract basic structure for items of the XSLT processor.
  432. * This includes:
  433. * 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)
  434. * 2) compiled forms of literal result elements
  435. * 3) compiled forms of extension elements
  436. */
  437. typedef struct _xsltStylePreComp xsltStylePreComp;
  438. typedef xsltStylePreComp *xsltStylePreCompPtr;
  439. #ifdef XSLT_REFACTORED
  440. /*
  441. * Some pointer-list utility functions.
  442. */
  443. XSLTPUBFUN xsltPointerListPtr XSLTCALL
  444. xsltPointerListCreate (int initialSize);
  445. XSLTPUBFUN void XSLTCALL
  446. xsltPointerListFree (xsltPointerListPtr list);
  447. XSLTPUBFUN void XSLTCALL
  448. xsltPointerListClear (xsltPointerListPtr list);
  449. XSLTPUBFUN int XSLTCALL
  450. xsltPointerListAddSize (xsltPointerListPtr list,
  451. void *item,
  452. int initialSize);
  453. /************************************************************************
  454. * *
  455. * Refactored structures *
  456. * *
  457. ************************************************************************/
  458. typedef struct _xsltNsListContainer xsltNsListContainer;
  459. typedef xsltNsListContainer *xsltNsListContainerPtr;
  460. struct _xsltNsListContainer {
  461. xmlNsPtr *list;
  462. int totalNumber;
  463. int xpathNumber;
  464. };
  465. /**
  466. * XSLT_ITEM_COMPATIBILITY_FIELDS:
  467. *
  468. * Fields for API compatibility to the structure
  469. * _xsltElemPreComp which is used for extension functions.
  470. * Note that @next is used for storage; it does not reflect a next
  471. * sibling in the tree.
  472. * TODO: Evaluate if we really need such a compatibility.
  473. */
  474. #define XSLT_ITEM_COMPATIBILITY_FIELDS \
  475. xsltElemPreCompPtr next;\
  476. xsltStyleType type;\
  477. xsltTransformFunction func;\
  478. xmlNodePtr inst;
  479. /**
  480. * XSLT_ITEM_NAVIGATION_FIELDS:
  481. *
  482. * Currently empty.
  483. * TODO: It is intended to hold navigational fields in the future.
  484. */
  485. #define XSLT_ITEM_NAVIGATION_FIELDS
  486. /*
  487. xsltStylePreCompPtr parent;\
  488. xsltStylePreCompPtr children;\
  489. xsltStylePreCompPtr nextItem;
  490. */
  491. /**
  492. * XSLT_ITEM_NSINSCOPE_FIELDS:
  493. *
  494. * The in-scope namespaces.
  495. */
  496. #define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;
  497. /**
  498. * XSLT_ITEM_COMMON_FIELDS:
  499. *
  500. * Common fields used for all items.
  501. */
  502. #define XSLT_ITEM_COMMON_FIELDS \
  503. XSLT_ITEM_COMPATIBILITY_FIELDS \
  504. XSLT_ITEM_NAVIGATION_FIELDS \
  505. XSLT_ITEM_NSINSCOPE_FIELDS
  506. /**
  507. * _xsltStylePreComp:
  508. *
  509. * The abstract basic structure for items of the XSLT processor.
  510. * This includes:
  511. * 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)
  512. * 2) compiled forms of literal result elements
  513. * 3) various properties for XSLT instructions (e.g. xsl:when,
  514. * xsl:with-param)
  515. *
  516. * REVISIT TODO: Keep this structure equal to the fields
  517. * defined by XSLT_ITEM_COMMON_FIELDS
  518. */
  519. struct _xsltStylePreComp {
  520. xsltElemPreCompPtr next; /* next item in the global chained
  521. list held by xsltStylesheet */
  522. xsltStyleType type; /* type of the item */
  523. xsltTransformFunction func; /* handling function */
  524. xmlNodePtr inst; /* the node in the stylesheet's tree
  525. corresponding to this item. */
  526. /* Currently no navigational fields. */
  527. xsltNsListContainerPtr inScopeNs;
  528. };
  529. /**
  530. * xsltStyleBasicEmptyItem:
  531. *
  532. * Abstract structure only used as a short-cut for
  533. * XSLT items with no extra fields.
  534. * NOTE that it is intended that this structure looks the same as
  535. * _xsltStylePreComp.
  536. */
  537. typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;
  538. typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;
  539. struct _xsltStyleBasicEmptyItem {
  540. XSLT_ITEM_COMMON_FIELDS
  541. };
  542. /**
  543. * xsltStyleBasicExpressionItem:
  544. *
  545. * Abstract structure only used as a short-cut for
  546. * XSLT items with just an expression.
  547. */
  548. typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;
  549. typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;
  550. struct _xsltStyleBasicExpressionItem {
  551. XSLT_ITEM_COMMON_FIELDS
  552. const xmlChar *select; /* TODO: Change this to "expression". */
  553. xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */
  554. };
  555. /************************************************************************
  556. * *
  557. * XSLT-instructions/declarations *
  558. * *
  559. ************************************************************************/
  560. /**
  561. * xsltStyleItemElement:
  562. *
  563. * <!-- Category: instruction -->
  564. * <xsl:element
  565. * name = { qname }
  566. * namespace = { uri-reference }
  567. * use-attribute-sets = qnames>
  568. * <!-- Content: template -->
  569. * </xsl:element>
  570. */
  571. typedef struct _xsltStyleItemElement xsltStyleItemElement;
  572. typedef xsltStyleItemElement *xsltStyleItemElementPtr;
  573. struct _xsltStyleItemElement {
  574. XSLT_ITEM_COMMON_FIELDS
  575. const xmlChar *use;
  576. int has_use;
  577. const xmlChar *name;
  578. int has_name;
  579. const xmlChar *ns;
  580. const xmlChar *nsPrefix;
  581. int has_ns;
  582. };
  583. /**
  584. * xsltStyleItemAttribute:
  585. *
  586. * <!-- Category: instruction -->
  587. * <xsl:attribute
  588. * name = { qname }
  589. * namespace = { uri-reference }>
  590. * <!-- Content: template -->
  591. * </xsl:attribute>
  592. */
  593. typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;
  594. typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;
  595. struct _xsltStyleItemAttribute {
  596. XSLT_ITEM_COMMON_FIELDS
  597. const xmlChar *name;
  598. int has_name;
  599. const xmlChar *ns;
  600. const xmlChar *nsPrefix;
  601. int has_ns;
  602. };
  603. /**
  604. * xsltStyleItemText:
  605. *
  606. * <!-- Category: instruction -->
  607. * <xsl:text
  608. * disable-output-escaping = "yes" | "no">
  609. * <!-- Content: #PCDATA -->
  610. * </xsl:text>
  611. */
  612. typedef struct _xsltStyleItemText xsltStyleItemText;
  613. typedef xsltStyleItemText *xsltStyleItemTextPtr;
  614. struct _xsltStyleItemText {
  615. XSLT_ITEM_COMMON_FIELDS
  616. int noescape; /* text */
  617. };
  618. /**
  619. * xsltStyleItemComment:
  620. *
  621. * <!-- Category: instruction -->
  622. * <xsl:comment>
  623. * <!-- Content: template -->
  624. * </xsl:comment>
  625. */
  626. typedef xsltStyleBasicEmptyItem xsltStyleItemComment;
  627. typedef xsltStyleItemComment *xsltStyleItemCommentPtr;
  628. /**
  629. * xsltStyleItemPI:
  630. *
  631. * <!-- Category: instruction -->
  632. * <xsl:processing-instruction
  633. * name = { ncname }>
  634. * <!-- Content: template -->
  635. * </xsl:processing-instruction>
  636. */
  637. typedef struct _xsltStyleItemPI xsltStyleItemPI;
  638. typedef xsltStyleItemPI *xsltStyleItemPIPtr;
  639. struct _xsltStyleItemPI {
  640. XSLT_ITEM_COMMON_FIELDS
  641. const xmlChar *name;
  642. int has_name;
  643. };
  644. /**
  645. * xsltStyleItemApplyImports:
  646. *
  647. * <!-- Category: instruction -->
  648. * <xsl:apply-imports />
  649. */
  650. typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;
  651. typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;
  652. /**
  653. * xsltStyleItemApplyTemplates:
  654. *
  655. * <!-- Category: instruction -->
  656. * <xsl:apply-templates
  657. * select = node-set-expression
  658. * mode = qname>
  659. * <!-- Content: (xsl:sort | xsl:with-param)* -->
  660. * </xsl:apply-templates>
  661. */
  662. typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;
  663. typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;
  664. struct _xsltStyleItemApplyTemplates {
  665. XSLT_ITEM_COMMON_FIELDS
  666. const xmlChar *mode; /* apply-templates */
  667. const xmlChar *modeURI; /* apply-templates */
  668. const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
  669. xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
  670. /* TODO: with-params */
  671. };
  672. /**
  673. * xsltStyleItemCallTemplate:
  674. *
  675. * <!-- Category: instruction -->
  676. * <xsl:call-template
  677. * name = qname>
  678. * <!-- Content: xsl:with-param* -->
  679. * </xsl:call-template>
  680. */
  681. typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;
  682. typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;
  683. struct _xsltStyleItemCallTemplate {
  684. XSLT_ITEM_COMMON_FIELDS
  685. xsltTemplatePtr templ; /* call-template */
  686. const xmlChar *name; /* element, attribute, pi */
  687. int has_name; /* element, attribute, pi */
  688. const xmlChar *ns; /* element */
  689. int has_ns; /* element */
  690. /* TODO: with-params */
  691. };
  692. /**
  693. * xsltStyleItemCopy:
  694. *
  695. * <!-- Category: instruction -->
  696. * <xsl:copy
  697. * use-attribute-sets = qnames>
  698. * <!-- Content: template -->
  699. * </xsl:copy>
  700. */
  701. typedef struct _xsltStyleItemCopy xsltStyleItemCopy;
  702. typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;
  703. struct _xsltStyleItemCopy {
  704. XSLT_ITEM_COMMON_FIELDS
  705. const xmlChar *use; /* copy, element */
  706. int has_use; /* copy, element */
  707. };
  708. /**
  709. * xsltStyleItemIf:
  710. *
  711. * <!-- Category: instruction -->
  712. * <xsl:if
  713. * test = boolean-expression>
  714. * <!-- Content: template -->
  715. * </xsl:if>
  716. */
  717. typedef struct _xsltStyleItemIf xsltStyleItemIf;
  718. typedef xsltStyleItemIf *xsltStyleItemIfPtr;
  719. struct _xsltStyleItemIf {
  720. XSLT_ITEM_COMMON_FIELDS
  721. const xmlChar *test; /* if */
  722. xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
  723. };
  724. /**
  725. * xsltStyleItemCopyOf:
  726. *
  727. * <!-- Category: instruction -->
  728. * <xsl:copy-of
  729. * select = expression />
  730. */
  731. typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;
  732. typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;
  733. /**
  734. * xsltStyleItemValueOf:
  735. *
  736. * <!-- Category: instruction -->
  737. * <xsl:value-of
  738. * select = string-expression
  739. * disable-output-escaping = "yes" | "no" />
  740. */
  741. typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;
  742. typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;
  743. struct _xsltStyleItemValueOf {
  744. XSLT_ITEM_COMMON_FIELDS
  745. const xmlChar *select;
  746. xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
  747. int noescape;
  748. };
  749. /**
  750. * xsltStyleItemNumber:
  751. *
  752. * <!-- Category: instruction -->
  753. * <xsl:number
  754. * level = "single" | "multiple" | "any"
  755. * count = pattern
  756. * from = pattern
  757. * value = number-expression
  758. * format = { string }
  759. * lang = { nmtoken }
  760. * letter-value = { "alphabetic" | "traditional" }
  761. * grouping-separator = { char }
  762. * grouping-size = { number } />
  763. */
  764. typedef struct _xsltStyleItemNumber xsltStyleItemNumber;
  765. typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;
  766. struct _xsltStyleItemNumber {
  767. XSLT_ITEM_COMMON_FIELDS
  768. xsltNumberData numdata; /* number */
  769. };
  770. /**
  771. * xsltStyleItemChoose:
  772. *
  773. * <!-- Category: instruction -->
  774. * <xsl:choose>
  775. * <!-- Content: (xsl:when+, xsl:otherwise?) -->
  776. * </xsl:choose>
  777. */
  778. typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;
  779. typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;
  780. /**
  781. * xsltStyleItemFallback:
  782. *
  783. * <!-- Category: instruction -->
  784. * <xsl:fallback>
  785. * <!-- Content: template -->
  786. * </xsl:fallback>
  787. */
  788. typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;
  789. typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;
  790. /**
  791. * xsltStyleItemForEach:
  792. *
  793. * <!-- Category: instruction -->
  794. * <xsl:for-each
  795. * select = node-set-expression>
  796. * <!-- Content: (xsl:sort*, template) -->
  797. * </xsl:for-each>
  798. */
  799. typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;
  800. typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;
  801. /**
  802. * xsltStyleItemMessage:
  803. *
  804. * <!-- Category: instruction -->
  805. * <xsl:message
  806. * terminate = "yes" | "no">
  807. * <!-- Content: template -->
  808. * </xsl:message>
  809. */
  810. typedef struct _xsltStyleItemMessage xsltStyleItemMessage;
  811. typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;
  812. struct _xsltStyleItemMessage {
  813. XSLT_ITEM_COMMON_FIELDS
  814. int terminate;
  815. };
  816. /**
  817. * xsltStyleItemDocument:
  818. *
  819. * NOTE: This is not an instruction of XSLT 1.0.
  820. */
  821. typedef struct _xsltStyleItemDocument xsltStyleItemDocument;
  822. typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;
  823. struct _xsltStyleItemDocument {
  824. XSLT_ITEM_COMMON_FIELDS
  825. int ver11; /* assigned: in xsltDocumentComp;
  826. read: nowhere;
  827. TODO: Check if we need. */
  828. const xmlChar *filename; /* document URL */
  829. int has_filename;
  830. };
  831. /************************************************************************
  832. * *
  833. * Non-instructions (actually properties of instructions/declarations) *
  834. * *
  835. ************************************************************************/
  836. /**
  837. * xsltStyleBasicItemVariable:
  838. *
  839. * Basic struct for xsl:variable, xsl:param and xsl:with-param.
  840. * It's currently important to have equal fields, since
  841. * xsltParseStylesheetCallerParam() is used with xsl:with-param from
  842. * the xslt side and with xsl:param from the exslt side (in
  843. * exsltFuncFunctionFunction()).
  844. *
  845. * FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param
  846. * have additional different fields.
  847. */
  848. typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;
  849. typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;
  850. struct _xsltStyleBasicItemVariable {
  851. XSLT_ITEM_COMMON_FIELDS
  852. const xmlChar *select;
  853. xmlXPathCompExprPtr comp;
  854. const xmlChar *name;
  855. int has_name;
  856. const xmlChar *ns;
  857. int has_ns;
  858. };
  859. /**
  860. * xsltStyleItemVariable:
  861. *
  862. * <!-- Category: top-level-element -->
  863. * <xsl:param
  864. * name = qname
  865. * select = expression>
  866. * <!-- Content: template -->
  867. * </xsl:param>
  868. */
  869. typedef xsltStyleBasicItemVariable xsltStyleItemVariable;
  870. typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;
  871. /**
  872. * xsltStyleItemParam:
  873. *
  874. * <!-- Category: top-level-element -->
  875. * <xsl:param
  876. * name = qname
  877. * select = expression>
  878. * <!-- Content: template -->
  879. * </xsl:param>
  880. */
  881. typedef struct _xsltStyleItemParam xsltStyleItemParam;
  882. typedef xsltStyleItemParam *xsltStyleItemParamPtr;
  883. struct _xsltStyleItemParam {
  884. XSLT_ITEM_COMMON_FIELDS
  885. const xmlChar *select;
  886. xmlXPathCompExprPtr comp;
  887. const xmlChar *name;
  888. int has_name;
  889. const xmlChar *ns;
  890. int has_ns;
  891. };
  892. /**
  893. * xsltStyleItemWithParam:
  894. *
  895. * <xsl:with-param
  896. * name = qname
  897. * select = expression>
  898. * <!-- Content: template -->
  899. * </xsl:with-param>
  900. */
  901. typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;
  902. typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;
  903. /**
  904. * xsltStyleItemSort:
  905. *
  906. * Reflects the XSLT xsl:sort item.
  907. * Allowed parents: xsl:apply-templates, xsl:for-each
  908. * <xsl:sort
  909. * select = string-expression
  910. * lang = { nmtoken }
  911. * data-type = { "text" | "number" | qname-but-not-ncname }
  912. * order = { "ascending" | "descending" }
  913. * case-order = { "upper-first" | "lower-first" } />
  914. */
  915. typedef struct _xsltStyleItemSort xsltStyleItemSort;
  916. typedef xsltStyleItemSort *xsltStyleItemSortPtr;
  917. struct _xsltStyleItemSort {
  918. XSLT_ITEM_COMMON_FIELDS
  919. const xmlChar *stype; /* sort */
  920. int has_stype; /* sort */
  921. int number; /* sort */
  922. const xmlChar *order; /* sort */
  923. int has_order; /* sort */
  924. int descending; /* sort */
  925. const xmlChar *lang; /* sort */
  926. int has_lang; /* sort */
  927. const xmlChar *case_order; /* sort */
  928. int lower_first; /* sort */
  929. const xmlChar *use;
  930. int has_use;
  931. const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
  932. xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
  933. };
  934. /**
  935. * xsltStyleItemWhen:
  936. *
  937. * <xsl:when
  938. * test = boolean-expression>
  939. * <!-- Content: template -->
  940. * </xsl:when>
  941. * Allowed parent: xsl:choose
  942. */
  943. typedef struct _xsltStyleItemWhen xsltStyleItemWhen;
  944. typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;
  945. struct _xsltStyleItemWhen {
  946. XSLT_ITEM_COMMON_FIELDS
  947. const xmlChar *test;
  948. xmlXPathCompExprPtr comp;
  949. };
  950. /**
  951. * xsltStyleItemOtherwise:
  952. *
  953. * Allowed parent: xsl:choose
  954. * <xsl:otherwise>
  955. * <!-- Content: template -->
  956. * </xsl:otherwise>
  957. */
  958. typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;
  959. typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;
  960. struct _xsltStyleItemOtherwise {
  961. XSLT_ITEM_COMMON_FIELDS
  962. };
  963. typedef struct _xsltStyleItemInclude xsltStyleItemInclude;
  964. typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;
  965. struct _xsltStyleItemInclude {
  966. XSLT_ITEM_COMMON_FIELDS
  967. xsltDocumentPtr include;
  968. };
  969. /************************************************************************
  970. * *
  971. * XSLT elements in forwards-compatible mode *
  972. * *
  973. ************************************************************************/
  974. typedef struct _xsltStyleItemUknown xsltStyleItemUknown;
  975. typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;
  976. struct _xsltStyleItemUknown {
  977. XSLT_ITEM_COMMON_FIELDS
  978. };
  979. /************************************************************************
  980. * *
  981. * Extension elements *
  982. * *
  983. ************************************************************************/
  984. /*
  985. * xsltStyleItemExtElement:
  986. *
  987. * Reflects extension elements.
  988. *
  989. * NOTE: Due to the fact that the structure xsltElemPreComp is most
  990. * probably already heavily in use out there by users, so we cannot
  991. * easily change it, we'll create an intermediate structure which will
  992. * hold an xsltElemPreCompPtr.
  993. * BIG NOTE: The only problem I see here is that the user processes the
  994. * content of the stylesheet tree, possibly he'll lookup the node->psvi
  995. * fields in order to find subsequent extension functions.
  996. * In this case, the user's code will break, since the node->psvi
  997. * field will hold now the xsltStyleItemExtElementPtr and not
  998. * the xsltElemPreCompPtr.
  999. * However the place where the structure is anchored in the node-tree,
  1000. * namely node->psvi, has beed already once been moved from node->_private
  1001. * to node->psvi, so we have a precedent here, which, I think, should allow
  1002. * us to change such semantics without headaches.
  1003. */
  1004. typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;
  1005. typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;
  1006. struct _xsltStyleItemExtElement {
  1007. XSLT_ITEM_COMMON_FIELDS
  1008. xsltElemPreCompPtr item;
  1009. };
  1010. /************************************************************************
  1011. * *
  1012. * Literal result elements *
  1013. * *
  1014. ************************************************************************/
  1015. typedef struct _xsltEffectiveNs xsltEffectiveNs;
  1016. typedef xsltEffectiveNs *xsltEffectiveNsPtr;
  1017. struct _xsltEffectiveNs {
  1018. xsltEffectiveNsPtr nextInStore; /* storage next */
  1019. xsltEffectiveNsPtr next; /* next item in the list */
  1020. const xmlChar *prefix;
  1021. const xmlChar *nsName;
  1022. /*
  1023. * Indicates if eclared on the literal result element; dunno if really
  1024. * needed.
  1025. */
  1026. int holdByElem;
  1027. };
  1028. /*
  1029. * Info for literal result elements.
  1030. * This will be set on the elem->psvi field and will be
  1031. * shared by literal result elements, which have the same
  1032. * excluded result namespaces; i.e., this *won't* be created uniquely
  1033. * for every literal result element.
  1034. */
  1035. typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;
  1036. typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;
  1037. struct _xsltStyleItemLRElementInfo {
  1038. XSLT_ITEM_COMMON_FIELDS
  1039. /*
  1040. * @effectiveNs is the set of effective ns-nodes
  1041. * on the literal result element, which will be added to the result
  1042. * element if not already existing in the result tree.
  1043. * This means that excluded namespaces (via exclude-result-prefixes,
  1044. * extension-element-prefixes and the XSLT namespace) not added
  1045. * to the set.
  1046. * Namespace-aliasing was applied on the @effectiveNs.
  1047. */
  1048. xsltEffectiveNsPtr effectiveNs;
  1049. };
  1050. #ifdef XSLT_REFACTORED
  1051. typedef struct _xsltNsAlias xsltNsAlias;
  1052. typedef xsltNsAlias *xsltNsAliasPtr;
  1053. struct _xsltNsAlias {
  1054. xsltNsAliasPtr next; /* next in the list */
  1055. xmlNsPtr literalNs;
  1056. xmlNsPtr targetNs;
  1057. xmlDocPtr docOfTargetNs;
  1058. };
  1059. #endif
  1060. #ifdef XSLT_REFACTORED_XSLT_NSCOMP
  1061. typedef struct _xsltNsMap xsltNsMap;
  1062. typedef xsltNsMap *xsltNsMapPtr;
  1063. struct _xsltNsMap {
  1064. xsltNsMapPtr next; /* next in the list */
  1065. xmlDocPtr doc;
  1066. xmlNodePtr elem; /* the element holding the ns-decl */
  1067. xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */
  1068. const xmlChar *origNsName; /* the original XML namespace name */
  1069. const xmlChar *newNsName; /* the mapped XML namespace name */
  1070. };
  1071. #endif
  1072. /************************************************************************
  1073. * *
  1074. * Compile-time structures for *internal* use only *
  1075. * *
  1076. ************************************************************************/
  1077. typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;
  1078. typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;
  1079. typedef struct _xsltNsList xsltNsList;
  1080. typedef xsltNsList *xsltNsListPtr;
  1081. struct _xsltNsList {
  1082. xsltNsListPtr next; /* next in the list */
  1083. xmlNsPtr ns;
  1084. };
  1085. /*
  1086. * xsltVarInfo:
  1087. *
  1088. * Used at compilation time for parameters and variables.
  1089. */
  1090. typedef struct _xsltVarInfo xsltVarInfo;
  1091. typedef xsltVarInfo *xsltVarInfoPtr;
  1092. struct _xsltVarInfo {
  1093. xsltVarInfoPtr next; /* next in the list */
  1094. xsltVarInfoPtr prev;
  1095. int depth; /* the depth in the tree */
  1096. const xmlChar *name;
  1097. const xmlChar *nsName;
  1098. };
  1099. /**
  1100. * xsltCompilerNodeInfo:
  1101. *
  1102. * Per-node information during compile-time.
  1103. */
  1104. typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;
  1105. typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;
  1106. struct _xsltCompilerNodeInfo {
  1107. xsltCompilerNodeInfoPtr next;
  1108. xsltCompilerNodeInfoPtr prev;
  1109. xmlNodePtr node;
  1110. int depth;
  1111. xsltTemplatePtr templ; /* The owning template */
  1112. int category; /* XSLT element, LR-element or
  1113. extension element */
  1114. xsltStyleType type;
  1115. xsltElemPreCompPtr item; /* The compiled information */
  1116. /* The current in-scope namespaces */
  1117. xsltNsListContainerPtr inScopeNs;
  1118. /* The current excluded result namespaces */
  1119. xsltPointerListPtr exclResultNs;
  1120. /* The current extension instruction namespaces */
  1121. xsltPointerListPtr extElemNs;
  1122. /* The current info for literal result elements. */
  1123. xsltStyleItemLRElementInfoPtr litResElemInfo;
  1124. /*
  1125. * Set to 1 if in-scope namespaces changed,
  1126. * or excluded result namespaces changed,
  1127. * or extension element namespaces changed.
  1128. * This will trigger creation of new infos
  1129. * for literal result elements.
  1130. */
  1131. int nsChanged;
  1132. int preserveWhitespace;
  1133. int stripWhitespace;
  1134. int isRoot; /* whether this is the stylesheet's root node */
  1135. int forwardsCompat; /* whether forwards-compatible mode is enabled */
  1136. /* whether the content of an extension element was processed */
  1137. int extContentHandled;
  1138. /* the type of the current child */
  1139. xsltStyleType curChildType;
  1140. };
  1141. /**
  1142. * XSLT_CCTXT:
  1143. *
  1144. * get pointer to compiler context
  1145. */
  1146. #define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt)
  1147. typedef enum {
  1148. XSLT_ERROR_SEVERITY_ERROR = 0,
  1149. XSLT_ERROR_SEVERITY_WARNING
  1150. } xsltErrorSeverityType;
  1151. typedef struct _xsltCompilerCtxt xsltCompilerCtxt;
  1152. typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;
  1153. struct _xsltCompilerCtxt {
  1154. void *errorCtxt; /* user specific error context */
  1155. /*
  1156. * used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */
  1157. xsltErrorSeverityType errSeverity;
  1158. int warnings; /* TODO: number of warnings found at
  1159. compilation */
  1160. int errors; /* TODO: number of errors found at
  1161. compilation */
  1162. xmlDictPtr dict;
  1163. xsltStylesheetPtr style;
  1164. int simplified; /* whether this is a simplified stylesheet */
  1165. /* TODO: structured/unstructured error contexts. */
  1166. int depth; /* Current depth of processing */
  1167. xsltCompilerNodeInfoPtr inode;
  1168. xsltCompilerNodeInfoPtr inodeList;
  1169. xsltCompilerNodeInfoPtr inodeLast;
  1170. xsltPointerListPtr tmpList; /* Used for various purposes */
  1171. /*
  1172. * The XSLT version as specified by the stylesheet's root element.
  1173. */
  1174. int isInclude;
  1175. int hasForwardsCompat; /* whether forwards-compatible mode was used
  1176. in a parsing episode */
  1177. int maxNodeInfos; /* TEMP TODO: just for the interest */
  1178. int maxLREs; /* TEMP TODO: just for the interest */
  1179. /*
  1180. * In order to keep the old behaviour, applying strict rules of
  1181. * the spec can be turned off. This has effect only on special
  1182. * mechanisms like whitespace-stripping in the stylesheet.
  1183. */
  1184. int strict;
  1185. xsltPrincipalStylesheetDataPtr psData;
  1186. xsltStyleItemUknownPtr unknownItem;
  1187. int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */
  1188. xsltNsAliasPtr nsAliases;
  1189. xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */
  1190. xsltVarInfoPtr ivar; /* topmost local variable/param. */
  1191. };
  1192. #else /* XSLT_REFACTORED */
  1193. /*
  1194. * The old structures before refactoring.
  1195. */
  1196. /**
  1197. * _xsltStylePreComp:
  1198. *
  1199. * The in-memory structure corresponding to XSLT stylesheet constructs
  1200. * precomputed data.
  1201. */
  1202. struct _xsltStylePreComp {
  1203. xsltElemPreCompPtr next; /* chained list */
  1204. xsltStyleType type; /* type of the element */
  1205. xsltTransformFunction func; /* handling function */
  1206. xmlNodePtr inst; /* the instruction */
  1207. /*
  1208. * Pre computed values.
  1209. */
  1210. const xmlChar *stype; /* sort */
  1211. int has_stype; /* sort */
  1212. int number; /* sort */
  1213. const xmlChar *order; /* sort */
  1214. int has_order; /* sort */
  1215. int descending; /* sort */
  1216. const xmlChar *lang; /* sort */
  1217. int has_lang; /* sort */
  1218. const xmlChar *case_order; /* sort */
  1219. int lower_first; /* sort */
  1220. const xmlChar *use; /* copy, element */
  1221. int has_use; /* copy, element */
  1222. int noescape; /* text */
  1223. const xmlChar *name; /* element, attribute, pi */
  1224. int has_name; /* element, attribute, pi */
  1225. const xmlChar *ns; /* element */
  1226. int has_ns; /* element */
  1227. const xmlChar *mode; /* apply-templates */
  1228. const xmlChar *modeURI; /* apply-templates */
  1229. const xmlChar *test; /* if */
  1230. xsltTemplatePtr templ; /* call-template */
  1231. const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
  1232. int ver11; /* document */
  1233. const xmlChar *filename; /* document URL */
  1234. int has_filename; /* document */
  1235. xsltNumberData numdata; /* number */
  1236. xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
  1237. xmlNsPtr *nsList; /* the namespaces in scope */
  1238. int nsNr; /* the number of namespaces in scope */
  1239. };
  1240. #endif /* XSLT_REFACTORED */
  1241. /*
  1242. * The in-memory structure corresponding to an XSLT Variable
  1243. * or Param.
  1244. */
  1245. typedef struct _xsltStackElem xsltStackElem;
  1246. typedef xsltStackElem *xsltStackElemPtr;
  1247. struct _xsltStackElem {
  1248. struct _xsltStackElem *next;/* chained list */
  1249. xsltStylePreCompPtr comp; /* the compiled form */
  1250. int computed; /* was the evaluation done */
  1251. const xmlChar *name; /* the local part of the name QName */
  1252. const xmlChar *nameURI; /* the URI part of the name QName */
  1253. const xmlChar *select; /* the eval string */
  1254. xmlNodePtr tree; /* the sequence constructor if no eval
  1255. string or the location */
  1256. xmlXPathObjectPtr value; /* The value if computed */
  1257. xmlDocPtr fragment; /* The Result Tree Fragments (needed for XSLT 1.0)
  1258. which are bound to the variable's lifetime. */
  1259. int level; /* the depth in the tree;
  1260. -1 if persistent (e.g. a given xsl:with-param) */
  1261. xsltTransformContextPtr context; /* The transformation context; needed to cache
  1262. the variables */
  1263. int flags;
  1264. };
  1265. #ifdef XSLT_REFACTORED
  1266. struct _xsltPrincipalStylesheetData {
  1267. /*
  1268. * Namespace dictionary for ns-prefixes and ns-names:
  1269. * TODO: Shared between stylesheets, and XPath mechanisms.
  1270. * Not used yet.
  1271. */
  1272. xmlDictPtr namespaceDict;
  1273. /*
  1274. * Global list of in-scope namespaces.
  1275. */
  1276. xsltPointerListPtr inScopeNamespaces;
  1277. /*
  1278. * Global list of information for [xsl:]excluded-result-prefixes.
  1279. */
  1280. xsltPointerListPtr exclResultNamespaces;
  1281. /*
  1282. * Global list of information for [xsl:]extension-element-prefixes.
  1283. */
  1284. xsltPointerListPtr extElemNamespaces;
  1285. xsltEffectiveNsPtr effectiveNs;
  1286. #ifdef XSLT_REFACTORED_XSLT_NSCOMP
  1287. /*
  1288. * Namespace name map to get rid of string comparison of namespace names.
  1289. */
  1290. xsltNsMapPtr nsMap;
  1291. #endif
  1292. };
  1293. #endif
  1294. /*
  1295. * Note that we added a @compCtxt field to anchor an stylesheet compilation
  1296. * context, since, due to historical reasons, various compile-time function
  1297. * take only the stylesheet as argument and not a compilation context.
  1298. */
  1299. struct _xsltStylesheet {
  1300. /*
  1301. * The stylesheet import relation is kept as a tree.
  1302. */
  1303. struct _xsltStylesheet *parent;
  1304. struct _xsltStylesheet *next;
  1305. struct _xsltStylesheet *imports;
  1306. xsltDocumentPtr docList; /* the include document list */
  1307. /*
  1308. * General data on the style sheet document.
  1309. */
  1310. xmlDocPtr doc; /* the parsed XML stylesheet */
  1311. xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
  1312. preserve space elements */
  1313. int stripAll; /* strip-space * (1) preserve-space * (-1) */
  1314. xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
  1315. /*
  1316. * Global variable or parameters.
  1317. */
  1318. xsltStackElemPtr variables; /* linked list of param and variables */
  1319. /*
  1320. * Template descriptions.
  1321. */
  1322. xsltTemplatePtr templates; /* the ordered list of templates */
  1323. xmlHashTablePtr templatesHash; /* hash table or wherever compiled
  1324. templates information is stored */
  1325. struct _xsltCompMatch *rootMatch; /* template based on / */
  1326. struct _xsltCompMatch *keyMatch; /* template based on key() */
  1327. struct _xsltCompMatch *elemMatch; /* template based on * */
  1328. struct _xsltCompMatch *attrMatch; /* template based on @* */
  1329. struct _xsltCompMatch *parentMatch; /* template based on .. */
  1330. struct _xsltCompMatch *textMatch; /* template based on text() */
  1331. struct _xsltCompMatch *piMatch; /* template based on
  1332. processing-instruction() */
  1333. struct _xsltCompMatch *commentMatch; /* template based on comment() */
  1334. /*
  1335. * Namespace aliases.
  1336. * NOTE: Not used in the refactored code.
  1337. */
  1338. xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
  1339. /*
  1340. * Attribute sets.
  1341. */
  1342. xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
  1343. /*
  1344. * Namespaces.
  1345. * TODO: Eliminate this.
  1346. */
  1347. xmlHashTablePtr nsHash; /* the set of namespaces in use:
  1348. ATTENTION: This is used for
  1349. execution of XPath expressions; unfortunately
  1350. it restricts the stylesheet to have distinct
  1351. prefixes.
  1352. TODO: We need to get rid of this.
  1353. */
  1354. void *nsDefs; /* ATTENTION TODO: This is currently used to store
  1355. xsltExtDefPtr (in extensions.c) and
  1356. *not* xmlNsPtr.
  1357. */
  1358. /*
  1359. * Key definitions.
  1360. */
  1361. void *keys; /* key definitions */
  1362. /*
  1363. * Output related stuff.
  1364. */
  1365. xmlChar *method; /* the output method */
  1366. xmlChar *methodURI; /* associated namespace if any */
  1367. xmlChar *version; /* version string */
  1368. xmlChar *encoding; /* encoding string */
  1369. int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */
  1370. /*
  1371. * Number formatting.
  1372. */
  1373. xsltDecimalFormatPtr decimalFormat;
  1374. int standalone; /* standalone = "yes" | "no" */
  1375. xmlChar *doctypePublic; /* doctype-public string */
  1376. xmlChar *doctypeSystem; /* doctype-system string */
  1377. int indent; /* should output being indented */
  1378. xmlChar *mediaType; /* media-type string */
  1379. /*
  1380. * Precomputed blocks.
  1381. */
  1382. xsltElemPreCompPtr preComps;/* list of precomputed blocks */
  1383. int warnings; /* number of warnings found at compilation */
  1384. int errors; /* number of errors found at compilation */
  1385. xmlChar *exclPrefix; /* last excluded prefixes */
  1386. xmlChar **exclPrefixTab; /* array of excluded prefixes */
  1387. int exclPrefixNr; /* number of excluded prefixes in scope */
  1388. int exclPrefixMax; /* size of the array */
  1389. void *_private; /* user defined data */
  1390. /*
  1391. * Extensions.
  1392. */
  1393. xmlHashTablePtr extInfos; /* the extension data */
  1394. int extrasNr; /* the number of extras required */
  1395. /*
  1396. * For keeping track of nested includes
  1397. */
  1398. xsltDocumentPtr includes; /* points to last nested include */
  1399. /*
  1400. * dictionary: shared between stylesheet, context and documents.
  1401. */
  1402. xmlDictPtr dict;
  1403. /*
  1404. * precompiled attribute value templates.
  1405. */
  1406. void *attVTs;
  1407. /*
  1408. * if namespace-alias has an alias for the default stylesheet prefix
  1409. * NOTE: Not used in the refactored code.
  1410. */
  1411. const xmlChar *defaultAlias;
  1412. /*
  1413. * bypass pre-processing (already done) (used in imports)
  1414. */
  1415. int nopreproc;
  1416. /*
  1417. * all document text strings were internalized
  1418. */
  1419. int internalized;
  1420. /*
  1421. * Literal Result Element as Stylesheet c.f. section 2.3
  1422. */
  1423. int literal_result;
  1424. /*
  1425. * The principal stylesheet
  1426. */
  1427. xsltStylesheetPtr principal;
  1428. #ifdef XSLT_REFACTORED
  1429. /*
  1430. * Compilation context used during compile-time.
  1431. */
  1432. xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */
  1433. xsltPrincipalStylesheetDataPtr principalData;
  1434. #endif
  1435. /*
  1436. * Forwards-compatible processing
  1437. */
  1438. int forwards_compatible;
  1439. xmlHashTablePtr namedTemplates; /* hash table of named templates */
  1440. xmlXPathContextPtr xpathCtxt;
  1441. };
  1442. typedef struct _xsltTransformCache xsltTransformCache;
  1443. typedef xsltTransformCache *xsltTransformCachePtr;
  1444. struct _xsltTransformCache {
  1445. xmlDocPtr RVT;
  1446. int nbRVT;
  1447. xsltStackElemPtr stackItems;
  1448. int nbStackItems;
  1449. #ifdef XSLT_DEBUG_PROFILE_CACHE
  1450. int dbgCachedRVTs;
  1451. int dbgReusedRVTs;
  1452. int dbgCachedVars;
  1453. int dbgReusedVars;
  1454. #endif
  1455. };
  1456. /*
  1457. * The in-memory structure corresponding to an XSLT Transformation.
  1458. */
  1459. typedef enum {
  1460. XSLT_OUTPUT_XML = 0,
  1461. XSLT_OUTPUT_HTML,
  1462. XSLT_OUTPUT_TEXT
  1463. } xsltOutputType;
  1464. typedef void *
  1465. (*xsltNewLocaleFunc)(const xmlChar *lang, int lowerFirst);
  1466. typedef void
  1467. (*xsltFreeLocaleFunc)(void *locale);
  1468. typedef xmlChar *
  1469. (*xsltGenSortKeyFunc)(void *locale, const xmlChar *lang);
  1470. typedef enum {
  1471. XSLT_STATE_OK = 0,
  1472. XSLT_STATE_ERROR,
  1473. XSLT_STATE_STOPPED
  1474. } xsltTransformState;
  1475. struct _xsltTransformContext {
  1476. xsltStylesheetPtr style; /* the stylesheet used */
  1477. xsltOutputType type; /* the type of output */
  1478. xsltTemplatePtr templ; /* the current template */
  1479. int templNr; /* Nb of templates in the stack */
  1480. int templMax; /* Size of the templtes stack */
  1481. xsltTemplatePtr *templTab; /* the template stack */
  1482. xsltStackElemPtr vars; /* the current variable list */
  1483. int varsNr; /* Nb of variable list in the stack */
  1484. int varsMax; /* Size of the variable list stack */
  1485. xsltStackElemPtr *varsTab; /* the variable list stack */
  1486. int varsBase; /* the var base for current templ */
  1487. /*
  1488. * Extensions
  1489. */
  1490. xmlHashTablePtr extFunctions; /* the extension functions */
  1491. xmlHashTablePtr extElements; /* the extension elements */
  1492. xmlHashTablePtr extInfos; /* the extension data */
  1493. const xmlChar *mode; /* the current mode */
  1494. const xmlChar *modeURI; /* the current mode URI */
  1495. xsltDocumentPtr docList; /* the document list */
  1496. xsltDocumentPtr document; /* the current source document; can be NULL if an RTF */
  1497. xmlNodePtr node; /* the current node being processed */
  1498. xmlNodeSetPtr nodeList; /* the current node list */
  1499. /* xmlNodePtr current; the node */
  1500. xmlDocPtr output; /* the resulting document */
  1501. xmlNodePtr insert; /* the insertion node */
  1502. xmlXPathContextPtr xpathCtxt; /* the XPath context */
  1503. xsltTransformState state; /* the current state */
  1504. /*
  1505. * Global variables
  1506. */
  1507. xmlHashTablePtr globalVars; /* the global variables and params */
  1508. xmlNodePtr inst; /* the instruction in the stylesheet */
  1509. int xinclude; /* should XInclude be processed */
  1510. const char * outputFile; /* the output URI if known */
  1511. int profile; /* is this run profiled */
  1512. long prof; /* the current profiled value */
  1513. int profNr; /* Nb of templates in the stack */
  1514. int profMax; /* Size of the templtaes stack */
  1515. long *profTab; /* the profile template stack */
  1516. void *_private; /* user defined data */
  1517. int extrasNr; /* the number of extras used */
  1518. int extrasMax; /* the number of extras allocated */
  1519. xsltRuntimeExtraPtr extras; /* extra per runtime information */
  1520. xsltDocumentPtr styleList; /* the stylesheet docs list */
  1521. void * sec; /* the security preferences if any */
  1522. xmlGenericErrorFunc error; /* a specific error handler */
  1523. void * errctx; /* context for the error handler */
  1524. xsltSortFunc sortfunc; /* a ctxt specific sort routine */
  1525. /*
  1526. * handling of temporary Result Value Tree
  1527. * (XSLT 1.0 term: "Result Tree Fragment")
  1528. */
  1529. xmlDocPtr tmpRVT; /* list of RVT without persistance */
  1530. xmlDocPtr persistRVT; /* list of persistant RVTs */
  1531. int ctxtflags; /* context processing flags */
  1532. /*
  1533. * Speed optimization when coalescing text nodes
  1534. */
  1535. const xmlChar *lasttext; /* last text node content */
  1536. int lasttsize; /* last text node size */
  1537. int lasttuse; /* last text node use */
  1538. /*
  1539. * Per Context Debugging
  1540. */
  1541. int debugStatus; /* the context level debug status */
  1542. unsigned long* traceCode; /* pointer to the variable holding the mask */
  1543. int parserOptions; /* parser options xmlParserOption */
  1544. /*
  1545. * dictionary: shared between stylesheet, context and documents.
  1546. */
  1547. xmlDictPtr dict;
  1548. xmlDocPtr tmpDoc; /* Obsolete; not used in the library. */
  1549. /*
  1550. * all document text strings are internalized
  1551. */
  1552. int internalized;
  1553. int nbKeys;
  1554. int hasTemplKeyPatterns;
  1555. xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */
  1556. xmlNodePtr initialContextNode;
  1557. xmlDocPtr initialContextDoc;
  1558. xsltTransformCachePtr cache;
  1559. void *contextVariable; /* the current variable item */
  1560. xmlDocPtr localRVT; /* list of local tree fragments; will be freed when
  1561. the instruction which created the fragment
  1562. exits */
  1563. xmlDocPtr localRVTBase; /* Obsolete */
  1564. int keyInitLevel; /* Needed to catch recursive keys issues */
  1565. int depth; /* Needed to catch recursions */
  1566. int maxTemplateDepth;
  1567. int maxTemplateVars;
  1568. unsigned long opLimit;
  1569. unsigned long opCount;
  1570. int sourceDocDirty;
  1571. unsigned long currentId; /* For generate-id() */
  1572. xsltNewLocaleFunc newLocale;
  1573. xsltFreeLocaleFunc freeLocale;
  1574. xsltGenSortKeyFunc genSortKey;
  1575. };
  1576. /**
  1577. * CHECK_STOPPED:
  1578. *
  1579. * Macro to check if the XSLT processing should be stopped.
  1580. * Will return from the function.
  1581. */
  1582. #define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
  1583. /**
  1584. * CHECK_STOPPEDE:
  1585. *
  1586. * Macro to check if the XSLT processing should be stopped.
  1587. * Will goto the error: label.
  1588. */
  1589. #define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
  1590. /**
  1591. * CHECK_STOPPED0:
  1592. *
  1593. * Macro to check if the XSLT processing should be stopped.
  1594. * Will return from the function with a 0 value.
  1595. */
  1596. #define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
  1597. /*
  1598. * The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
  1599. * possible incompatibilities between function pointers and object
  1600. * pointers. It is defined in libxml/hash.h within recent versions
  1601. * of libxml2, but is put here for compatibility.
  1602. */
  1603. #ifndef XML_CAST_FPTR
  1604. /**
  1605. * XML_CAST_FPTR:
  1606. * @fptr: pointer to a function
  1607. *
  1608. * Macro to do a casting from an object pointer to a
  1609. * function pointer without encountering a warning from
  1610. * gcc
  1611. *
  1612. * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
  1613. * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
  1614. * so it is disabled now
  1615. */
  1616. #define XML_CAST_FPTR(fptr) fptr
  1617. #endif
  1618. /*
  1619. * Functions associated to the internal types
  1620. xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
  1621. xmlChar *name);
  1622. */
  1623. XSLTPUBFUN xsltStylesheetPtr XSLTCALL
  1624. xsltNewStylesheet (void);
  1625. XSLTPUBFUN xsltStylesheetPtr XSLTCALL
  1626. xsltParseStylesheetFile (const xmlChar* filename);
  1627. XSLTPUBFUN void XSLTCALL
  1628. xsltFreeStylesheet (xsltStylesheetPtr style);
  1629. XSLTPUBFUN int XSLTCALL
  1630. xsltIsBlank (xmlChar *str);
  1631. XSLTPUBFUN void XSLTCALL
  1632. xsltFreeStackElemList (xsltStackElemPtr elem);
  1633. XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
  1634. xsltDecimalFormatGetByName(xsltStylesheetPtr style,
  1635. xmlChar *name);
  1636. XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
  1637. xsltDecimalFormatGetByQName(xsltStylesheetPtr style,
  1638. const xmlChar *nsUri,
  1639. const xmlChar *name);
  1640. XSLTPUBFUN xsltStylesheetPtr XSLTCALL
  1641. xsltParseStylesheetProcess(xsltStylesheetPtr ret,
  1642. xmlDocPtr doc);
  1643. XSLTPUBFUN void XSLTCALL
  1644. xsltParseStylesheetOutput(xsltStylesheetPtr style,
  1645. xmlNodePtr cur);
  1646. XSLTPUBFUN xsltStylesheetPtr XSLTCALL
  1647. xsltParseStylesheetDoc (xmlDocPtr doc);
  1648. XSLTPUBFUN xsltStylesheetPtr XSLTCALL
  1649. xsltParseStylesheetImportedDoc(xmlDocPtr doc,
  1650. xsltStylesheetPtr style);
  1651. XSLTPUBFUN int XSLTCALL
  1652. xsltParseStylesheetUser(xsltStylesheetPtr style,
  1653. xmlDocPtr doc);
  1654. XSLTPUBFUN xsltStylesheetPtr XSLTCALL
  1655. xsltLoadStylesheetPI (xmlDocPtr doc);
  1656. XSLTPUBFUN void XSLTCALL
  1657. xsltNumberFormat (xsltTransformContextPtr ctxt,
  1658. xsltNumberDataPtr data,
  1659. xmlNodePtr node);
  1660. XSLTPUBFUN xmlXPathError XSLTCALL
  1661. xsltFormatNumberConversion(xsltDecimalFormatPtr self,
  1662. xmlChar *format,
  1663. double number,
  1664. xmlChar **result);
  1665. XSLTPUBFUN void XSLTCALL
  1666. xsltParseTemplateContent(xsltStylesheetPtr style,
  1667. xmlNodePtr templ);
  1668. XSLTPUBFUN int XSLTCALL
  1669. xsltAllocateExtra (xsltStylesheetPtr style);
  1670. XSLTPUBFUN int XSLTCALL
  1671. xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt);
  1672. /*
  1673. * Extra functions for Result Value Trees
  1674. */
  1675. XSLTPUBFUN xmlDocPtr XSLTCALL
  1676. xsltCreateRVT (xsltTransformContextPtr ctxt);
  1677. XSLTPUBFUN int XSLTCALL
  1678. xsltRegisterTmpRVT (xsltTransformContextPtr ctxt,
  1679. xmlDocPtr RVT);
  1680. XSLTPUBFUN int XSLTCALL
  1681. xsltRegisterLocalRVT (xsltTransformContextPtr ctxt,
  1682. xmlDocPtr RVT);
  1683. XSLTPUBFUN int XSLTCALL
  1684. xsltRegisterPersistRVT (xsltTransformContextPtr ctxt,
  1685. xmlDocPtr RVT);
  1686. XSLTPUBFUN int XSLTCALL
  1687. xsltExtensionInstructionResultRegister(
  1688. xsltTransformContextPtr ctxt,
  1689. xmlXPathObjectPtr obj);
  1690. XSLTPUBFUN int XSLTCALL
  1691. xsltExtensionInstructionResultFinalize(
  1692. xsltTransformContextPtr ctxt);
  1693. XSLTPUBFUN int XSLTCALL
  1694. xsltFlagRVTs(
  1695. xsltTransformContextPtr ctxt,
  1696. xmlXPathObjectPtr obj,
  1697. int val);
  1698. XSLTPUBFUN void XSLTCALL
  1699. xsltFreeRVTs (xsltTransformContextPtr ctxt);
  1700. XSLTPUBFUN void XSLTCALL
  1701. xsltReleaseRVT (xsltTransformContextPtr ctxt,
  1702. xmlDocPtr RVT);
  1703. /*
  1704. * Extra functions for Attribute Value Templates
  1705. */
  1706. XSLTPUBFUN void XSLTCALL
  1707. xsltCompileAttr (xsltStylesheetPtr style,
  1708. xmlAttrPtr attr);
  1709. XSLTPUBFUN xmlChar * XSLTCALL
  1710. xsltEvalAVT (xsltTransformContextPtr ctxt,
  1711. void *avt,
  1712. xmlNodePtr node);
  1713. XSLTPUBFUN void XSLTCALL
  1714. xsltFreeAVTList (void *avt);
  1715. /*
  1716. * Extra function for successful xsltCleanupGlobals / xsltInit sequence.
  1717. */
  1718. XSLTPUBFUN void XSLTCALL
  1719. xsltUninit (void);
  1720. /************************************************************************
  1721. * *
  1722. * Compile-time functions for *internal* use only *
  1723. * *
  1724. ************************************************************************/
  1725. #ifdef XSLT_REFACTORED
  1726. XSLTPUBFUN void XSLTCALL
  1727. xsltParseSequenceConstructor(
  1728. xsltCompilerCtxtPtr cctxt,
  1729. xmlNodePtr start);
  1730. XSLTPUBFUN int XSLTCALL
  1731. xsltParseAnyXSLTElem (xsltCompilerCtxtPtr cctxt,
  1732. xmlNodePtr elem);
  1733. #ifdef XSLT_REFACTORED_XSLT_NSCOMP
  1734. XSLTPUBFUN int XSLTCALL
  1735. xsltRestoreDocumentNamespaces(
  1736. xsltNsMapPtr ns,
  1737. xmlDocPtr doc);
  1738. #endif
  1739. #endif /* XSLT_REFACTORED */
  1740. /************************************************************************
  1741. * *
  1742. * Transformation-time functions for *internal* use only *
  1743. * *
  1744. ************************************************************************/
  1745. XSLTPUBFUN int XSLTCALL
  1746. xsltInitCtxtKey (xsltTransformContextPtr ctxt,
  1747. xsltDocumentPtr doc,
  1748. xsltKeyDefPtr keyd);
  1749. XSLTPUBFUN int XSLTCALL
  1750. xsltInitAllDocKeys (xsltTransformContextPtr ctxt);
  1751. #ifdef __cplusplus
  1752. }
  1753. #endif
  1754. #endif /* __XML_XSLT_H__ */