ReactOS 0.4.16-dev-306-g647d351
xslt.c File Reference
#include "precomp.h"
Include dependency graph for xslt.c:

Go to the source code of this file.

Macros

#define IS_BLANK(c)
 
#define IS_BLANK_NODE(n)    (((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
 

Functions

double xmlXPathStringEvalNumber (const xmlChar *str)
 
static void xsltParseContentError (xsltStylesheetPtr style, xmlNodePtr node)
 
static int exclPrefixPush (xsltStylesheetPtr style, xmlChar *value)
 
static xmlCharexclPrefixPop (xsltStylesheetPtr style)
 
void xsltInit (void)
 
void xsltUninit (void)
 
int xsltIsBlank (xmlChar *str)
 
static xsltDecimalFormatPtr xsltNewDecimalFormat (const xmlChar *nsUri, xmlChar *name)
 
static void xsltFreeDecimalFormat (xsltDecimalFormatPtr self)
 
static void xsltFreeDecimalFormatList (xsltStylesheetPtr self)
 
: the decimal-format name to find

xsltDecimalFormatGetByName: @style: the XSLT stylesheet

Find decimal-format by name

Returns the xsltDecimalFormatPtr

xsltDecimalFormatPtr xsltDecimalFormatGetByName (xsltStylesheetPtr style, xmlChar *name)
 

Variables

const charxsltEngineVersion = LIBXSLT_VERSION_STRING LIBXSLT_VERSION_EXTRA
 
const int xsltLibxsltVersion = LIBXSLT_VERSION
 
const int xsltLibxmlVersion = LIBXML_VERSION
 
static int initialized = 0
 

: the local part of the QName

xsltDecimalFormatGetByQName: @style: the XSLT stylesheet @nsUri: the namespace URI of the QName

Find decimal-format by QName

Returns the xsltDecimalFormatPtr

#define CUR   (*cur)
 
#define SKIP(val)   cur += (val)
 
#define NXT(val)   cur[(val)]
 
#define SKIP_BLANKS    while (IS_BLANK(CUR)) NEXT
 
#define NEXT   ((*cur) ? cur++ : cur)
 
xsltDecimalFormatPtr xsltDecimalFormatGetByQName (xsltStylesheetPtr style, const xmlChar *nsUri, const xmlChar *name)
 
static xsltTemplatePtr xsltNewTemplate (void)
 
static void xsltFreeTemplate (xsltTemplatePtr template)
 
static void xsltFreeTemplateList (xsltTemplatePtr template)
 
static xsltStylesheetPtr xsltNewStylesheetInternal (xsltStylesheetPtr parent)
 
xsltStylesheetPtr xsltNewStylesheet (void)
 
int xsltAllocateExtra (xsltStylesheetPtr style)
 
int xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt)
 
static void xsltFreeStylesheetList (xsltStylesheetPtr style)
 
static int xsltCleanupStylesheetTree (xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr rootElem ATTRIBUTE_UNUSED)
 
void xsltFreeStylesheet (xsltStylesheetPtr style)
 
static int xsltGetInheritedNsList (xsltStylesheetPtr style, xsltTemplatePtr template, xmlNodePtr node)
 
void xsltParseStylesheetOutput (xsltStylesheetPtr style, xmlNodePtr cur)
 
static void xsltParseStylesheetDecimalFormat (xsltStylesheetPtr style, xmlNodePtr cur)
 
static void xsltParseStylesheetPreserveSpace (xsltStylesheetPtr style, xmlNodePtr cur)
 
static void xsltParseStylesheetExtPrefix (xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
 
static void xsltParseStylesheetStripSpace (xsltStylesheetPtr style, xmlNodePtr cur)
 
static int xsltParseStylesheetExcludePrefix (xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
 
static void xsltPreprocessStylesheet (xsltStylesheetPtr style, xmlNodePtr cur)
 
static void xsltGatherNamespaces (xsltStylesheetPtr style)
 
void xsltParseTemplateContent (xsltStylesheetPtr style, xmlNodePtr templ)
 
static void xsltParseStylesheetKey (xsltStylesheetPtr style, xmlNodePtr key)
 
static void xsltParseStylesheetTemplate (xsltStylesheetPtr style, xmlNodePtr template)
 
static void xsltParseStylesheetTop (xsltStylesheetPtr style, xmlNodePtr top)
 
xsltStylesheetPtr xsltParseStylesheetProcess (xsltStylesheetPtr ret, xmlDocPtr doc)
 
xsltStylesheetPtr xsltParseStylesheetImportedDoc (xmlDocPtr doc, xsltStylesheetPtr parentStyle)
 
int xsltParseStylesheetUser (xsltStylesheetPtr style, xmlDocPtr doc)
 
xsltStylesheetPtr xsltParseStylesheetDoc (xmlDocPtr doc)
 
xsltStylesheetPtr xsltParseStylesheetFile (const xmlChar *filename)
 
static xmlCharxsltParseStylesheetPI (const xmlChar *value)
 
xsltStylesheetPtr xsltLoadStylesheetPI (xmlDocPtr doc)
 

Macro Definition Documentation

◆ CUR

#define CUR   (*cur)

Definition at line 6765 of file xslt.c.

◆ IS_BLANK

#define IS_BLANK (   c)
Value:
(((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
((c) == 0x0D))
#define c
Definition: ke_i.h:80

Definition at line 79 of file xslt.c.

◆ IS_BLANK_NODE

#define IS_BLANK_NODE (   n)     (((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))

Definition at line 85 of file xslt.c.

◆ NEXT

#define NEXT   ((*cur) ? cur++ : cur)

Definition at line 6770 of file xslt.c.

◆ NXT

#define NXT (   val)    cur[(val)]

Definition at line 6767 of file xslt.c.

◆ SKIP

#define SKIP (   val)    cur += (val)

Definition at line 6766 of file xslt.c.

◆ SKIP_BLANKS

#define SKIP_BLANKS    while (IS_BLANK(CUR)) NEXT

Definition at line 6768 of file xslt.c.

Function Documentation

◆ exclPrefixPop()

static xmlChar * exclPrefixPop ( xsltStylesheetPtr  style)
static

exclPrefixPop: @style: the transformation stylesheet

Pop an excluded prefix value from the stack

Returns the stored excluded prefix value

Definition at line 170 of file xslt.c.

171{
172 xmlChar *ret;
173
174 if (style->exclPrefixNr <= 0)
175 return (0);
176 style->exclPrefixNr--;
177 if (style->exclPrefixNr > 0)
178 style->exclPrefix = style->exclPrefixTab[style->exclPrefixNr - 1];
179 else
180 style->exclPrefix = NULL;
181 ret = style->exclPrefixTab[style->exclPrefixNr];
182 style->exclPrefixTab[style->exclPrefixNr] = 0;
183 return (ret);
184}
Arabic default style
Definition: afstyles.h:94
#define NULL
Definition: types.h:112
int ret
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xsltPreprocessStylesheet().

◆ exclPrefixPush()

static int exclPrefixPush ( xsltStylesheetPtr  style,
xmlChar value 
)
static

exclPrefixPush: @style: the transformation stylesheet @value: the excluded namespace name to push on the stack

Push an excluded namespace name on the stack

Returns the new index in the stack or -1 if already present or in case of error

Definition at line 127 of file xslt.c.

128{
129 int i;
130
131 if (style->exclPrefixMax == 0) {
132 style->exclPrefixMax = 4;
133 style->exclPrefixTab =
134 (xmlChar * *)xmlMalloc(style->exclPrefixMax *
135 sizeof(style->exclPrefixTab[0]));
136 if (style->exclPrefixTab == NULL) {
137 xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
138 return (-1);
139 }
140 }
141 /* do not push duplicates */
142 for (i = 0;i < style->exclPrefixNr;i++) {
143 if (xmlStrEqual(style->exclPrefixTab[i], value))
144 return(-1);
145 }
146 if (style->exclPrefixNr >= style->exclPrefixMax) {
147 style->exclPrefixMax *= 2;
148 style->exclPrefixTab =
149 (xmlChar * *)xmlRealloc(style->exclPrefixTab,
150 style->exclPrefixMax *
151 sizeof(style->exclPrefixTab[0]));
152 if (style->exclPrefixTab == NULL) {
153 xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
154 return (-1);
155 }
156 }
157 style->exclPrefixTab[style->exclPrefixNr] = value;
158 style->exclPrefix = value;
159 return (style->exclPrefixNr++);
160}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
Definition: pdh_main.c:94
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160

Referenced by xsltParseStylesheetExcludePrefix().

◆ xmlXPathStringEvalNumber()

double xmlXPathStringEvalNumber ( const xmlChar str)

◆ xsltAllocateExtra()

int xsltAllocateExtra ( xsltStylesheetPtr  style)

xsltAllocateExtra: @style: an XSLT stylesheet

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

Returns the number of the slot

Definition at line 809 of file xslt.c.

810{
811 return(style->extrasNr++);
812}

Referenced by xsltCompMatchAdd().

◆ xsltAllocateExtraCtxt()

int xsltAllocateExtraCtxt ( xsltTransformContextPtr  ctxt)

xsltAllocateExtraCtxt: @ctxt: an XSLT transformation context

Allocate an extra runtime information slot at run-time and return its number This make sure there is a slot ready in the transformation context

Returns the number of the slot

Definition at line 825 of file xslt.c.

826{
827 if (ctxt->extrasNr >= ctxt->extrasMax) {
828 int i;
829 if (ctxt->extrasNr == 0) {
830 ctxt->extrasMax = 20;
832 xmlMalloc(ctxt->extrasMax * sizeof(xsltRuntimeExtra));
833 if (ctxt->extras == NULL) {
835 "xsltAllocateExtraCtxt: out of memory\n");
836 return(0);
837 }
838 for (i = 0;i < ctxt->extrasMax;i++) {
839 ctxt->extras[i].info = NULL;
840 ctxt->extras[i].deallocate = NULL;
841 ctxt->extras[i].val.ptr = NULL;
842 }
843
844 } else {
846
847 ctxt->extrasMax += 100;
849 ctxt->extrasMax * sizeof(xsltRuntimeExtra));
850 if (tmp == NULL) {
852 "xsltAllocateExtraCtxt: out of memory\n");
853 return(0);
854 }
855 ctxt->extras = tmp;
856 for (i = ctxt->extrasNr;i < ctxt->extrasMax;i++) {
857 ctxt->extras[i].info = NULL;
858 ctxt->extras[i].deallocate = NULL;
859 ctxt->extras[i].val.ptr = NULL;
860 }
861 }
862 }
863 return(ctxt->extrasNr++);
864}
xmlFreeFunc deallocate
union _xsltRuntimeExtra::@3468 val
xsltRuntimeExtraPtr extras
xsltRuntimeExtra * xsltRuntimeExtraPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

Referenced by xsltCompMatchAdd().

◆ xsltCleanupStylesheetTree()

static int xsltCleanupStylesheetTree ( xmlDocPtr doc  ATTRIBUTE_UNUSED,
xmlNodePtr rootElem  ATTRIBUTE_UNUSED 
)
static

xsltCleanupStylesheetTree:

@doc: the document-node @node: the element where the stylesheet is rooted at

Actually @node need not be the document-element, but currently Libxslt does not support embedded stylesheets.

Returns 0 if OK, -1 on API or internal errors.

Definition at line 895 of file xslt.c.

897{
898#if 0 /* TODO: Currently disabled, since probably not needed. */
900
901 if ((doc == NULL) || (rootElem == NULL) ||
902 (rootElem->type != XML_ELEMENT_NODE) ||
903 (doc != rootElem->doc))
904 return(-1);
905
906 /*
907 * Cleanup was suggested by Aleksey Sanin:
908 * Clear the PSVI field to avoid problems if the
909 * node-tree of the stylesheet is intended to be used for
910 * further processing by the user (e.g. for compiling it
911 * once again - although not recommended).
912 */
913
914 cur = rootElem;
915 while (cur != NULL) {
916 if (cur->type == XML_ELEMENT_NODE) {
917 /*
918 * Clear the PSVI field.
919 */
920 cur->psvi = NULL;
921 if (cur->children) {
922 cur = cur->children;
923 continue;
924 }
925 }
926
927leave_node:
928 if (cur == rootElem)
929 break;
930 if (cur->next != NULL)
931 cur = cur->next;
932 else {
933 cur = cur->parent;
934 if (cur == NULL)
935 break;
936 goto leave_node;
937 }
938 }
939#endif /* #if 0 */
940 return(0);
941}
FxCollectionEntry * cur
@ XML_ELEMENT_NODE
Definition: tree.h:160
Definition: tree.h:489

Referenced by xsltFreeStylesheet(), and xsltParseStylesheetUser().

◆ xsltDecimalFormatGetByName()

xsltDecimalFormatPtr xsltDecimalFormatGetByName ( xsltStylesheetPtr  style,
xmlChar name 
)

Definition at line 334 of file xslt.c.

335{
337
338 if (name == NULL)
339 return style->decimalFormat;
340
341 while (style != NULL) {
342 for (result = style->decimalFormat->next;
343 result != NULL;
344 result = result->next) {
345 if ((result->nsUri == NULL) && xmlStrEqual(name, result->name))
346 return result;
347 }
349 }
350 return result;
351}
GLuint64EXT * result
Definition: glext.h:11304
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:251
struct define * next
Definition: compiler.c:65
Definition: name.c:39
WCHAR * name
Definition: name.c:42

◆ xsltDecimalFormatGetByQName()

xsltDecimalFormatPtr xsltDecimalFormatGetByQName ( xsltStylesheetPtr  style,
const xmlChar nsUri,
const xmlChar name 
)

Definition at line 364 of file xslt.c.

366{
368
369 if (name == NULL)
370 return style->decimalFormat;
371
372 while (style != NULL) {
373 for (result = style->decimalFormat->next;
374 result != NULL;
375 result = result->next) {
376 if (xmlStrEqual(nsUri, result->nsUri) &&
378 return result;
379 }
381 }
382 return result;
383}

Referenced by xsltFormatNumberFunction(), and xsltParseStylesheetDecimalFormat().

◆ xsltFreeDecimalFormat()

static void xsltFreeDecimalFormat ( xsltDecimalFormatPtr  self)
static

Definition at line 278 of file xslt.c.

279{
280 if (self != NULL) {
281 if (self->digit)
282 xmlFree(self->digit);
283 if (self->patternSeparator)
285 if (self->decimalPoint)
286 xmlFree(self->decimalPoint);
287 if (self->grouping)
288 xmlFree(self->grouping);
289 if (self->percent)
290 xmlFree(self->percent);
291 if (self->permille)
292 xmlFree(self->permille);
293 if (self->zeroDigit)
294 xmlFree(self->zeroDigit);
295 if (self->minusSign)
296 xmlFree(self->minusSign);
297 if (self->infinity)
298 xmlFree(self->infinity);
299 if (self->noNumber)
300 xmlFree(self->noNumber);
301 if (self->name)
302 xmlFree(self->name);
303 xmlFree(self);
304 }
305}
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
xmlChar * decimalPoint
xmlChar * patternSeparator

Referenced by xsltFreeDecimalFormatList().

◆ xsltFreeDecimalFormatList()

static void xsltFreeDecimalFormatList ( xsltStylesheetPtr  self)
static

Definition at line 308 of file xslt.c.

309{
312
313 if (self == NULL)
314 return;
315
316 iter = self->decimalFormat;
317 while (iter != NULL) {
318 tmp = iter->next;
320 iter = tmp;
321 }
322}
struct _xsltDecimalFormat * next
xsltDecimalFormatPtr decimalFormat
static void xsltFreeDecimalFormat(xsltDecimalFormatPtr self)
Definition: xslt.c:278

Referenced by xsltFreeStylesheet().

◆ xsltFreeStylesheet()

void xsltFreeStylesheet ( xsltStylesheetPtr  style)

xsltFreeStylesheet: @style: an XSLT stylesheet

Free up the memory allocated by @style

Definition at line 950 of file xslt.c.

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

Referenced by xsltDocumentElem(), xsltFreeStylesheetList(), xsltNewStylesheetInternal(), and xsltParseStylesheetImportedDoc().

◆ xsltFreeStylesheetList()

static void xsltFreeStylesheetList ( xsltStylesheetPtr  style)
static

xsltFreeStylesheetList: @style: an XSLT stylesheet list

Free up the memory allocated by the list @style

Definition at line 873 of file xslt.c.

873 {
875
876 while (style != NULL) {
877 next = style->next;
879 style = next;
880 }
881}
static unsigned __int64 next
Definition: rand_nt.c:6
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:950

Referenced by xsltFreeStylesheet().

◆ xsltFreeTemplate()

static void xsltFreeTemplate ( xsltTemplatePtr  template)
static

xsltFreeTemplate: @template: an XSLT template

Free up the memory allocated by @template

Definition at line 415 of file xslt.c.

415 {
416 if (template == NULL)
417 return;
418 if (template->match) xmlFree(template->match);
419/*
420* NOTE: @name and @nameURI are put into the string dict now.
421* if (template->name) xmlFree(template->name);
422* if (template->nameURI) xmlFree(template->nameURI);
423*/
424/*
425 if (template->mode) xmlFree(template->mode);
426 if (template->modeURI) xmlFree(template->modeURI);
427 */
428 if (template->inheritedNs) xmlFree(template->inheritedNs);
429
430 /* free profiling data */
431 if (template->templCalledTab) xmlFree(template->templCalledTab);
432 if (template->templCountTab) xmlFree(template->templCountTab);
433
434 memset(template, -1, sizeof(xsltTemplate));
435 xmlFree(template);
436}
const UINT template
Definition: action.c:7511

Referenced by xsltFreeTemplateList().

◆ xsltFreeTemplateList()

static void xsltFreeTemplateList ( xsltTemplatePtr  template)
static

xsltFreeTemplateList: @template: an XSLT template list

Free up the memory allocated by all the elements of @template

Definition at line 445 of file xslt.c.

445 {
447
448 while (template != NULL) {
449 cur = template;
450 template = template->next;
452 }
453}
static void xsltFreeTemplate(xsltTemplatePtr template)
Definition: xslt.c:415

Referenced by xsltFreeStylesheet().

◆ xsltGatherNamespaces()

static void xsltGatherNamespaces ( xsltStylesheetPtr  style)
static

xsltGatherNamespaces: @style: the XSLT stylesheet

Browse the stylesheet and build the namspace hash table which will be used for XPath interpretation. If needed do a bit of normalization

Definition at line 3674 of file xslt.c.

3674 {
3676 const xmlChar *URI;
3677
3678 if (style == NULL)
3679 return;
3680 /*
3681 * TODO: basically if the stylesheet uses the same prefix for different
3682 * patterns, well they may be in problem, hopefully they will get
3683 * a warning first.
3684 */
3685 /*
3686 * TODO: Eliminate the use of the hash for XPath expressions.
3687 * An expression should be evaluated in the context of the in-scope
3688 * namespaces; eliminate the restriction of an XML document to contain
3689 * no duplicate prefixes for different namespace names.
3690 *
3691 */
3693 while (cur != NULL) {
3694 if (cur->type == XML_ELEMENT_NODE) {
3695 xmlNsPtr ns = cur->nsDef;
3696 while (ns != NULL) {
3697 if (ns->prefix != NULL) {
3698 if (style->nsHash == NULL) {
3699 style->nsHash = xmlHashCreate(10);
3700 if (style->nsHash == NULL) {
3702 "xsltGatherNamespaces: failed to create hash table\n");
3703 style->errors++;
3704 return;
3705 }
3706 }
3707 URI = xmlHashLookup(style->nsHash, ns->prefix);
3708 if ((URI != NULL) && (!xmlStrEqual(URI, ns->href))) {
3710 "Namespaces prefix %s used for multiple namespaces\n",ns->prefix);
3711 style->warnings++;
3712 } else if (URI == NULL) {
3714 (void *) ns->href, NULL);
3715
3716#ifdef WITH_XSLT_DEBUG_PARSING
3718 "Added namespace: %s mapped to %s\n", ns->prefix, ns->href);
3719#endif
3720 }
3721 }
3722 ns = ns->next;
3723 }
3724 }
3725
3726 /*
3727 * Skip to next node
3728 */
3729 if (cur->children != NULL) {
3730 if (cur->children->type != XML_ENTITY_DECL) {
3731 cur = cur->children;
3732 continue;
3733 }
3734 }
3735 if (cur->next != NULL) {
3736 cur = cur->next;
3737 continue;
3738 }
3739
3740 do {
3741 cur = cur->parent;
3742 if (cur == NULL)
3743 break;
3744 if (cur == (xmlNodePtr) style->doc) {
3745 cur = NULL;
3746 break;
3747 }
3748 if (cur->next != NULL) {
3749 cur = cur->next;
3750 break;
3751 }
3752 } while (cur != NULL);
3753 }
3754}
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:461
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreate(int size)
Definition: hash.c:176
XMLPUBFUN int XMLCALL xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata, xmlHashDeallocator f)
Definition: hash.c:425
@ XML_ENTITY_DECL
Definition: tree.h:176
Definition: tree.h:389
Definition: mxnamespace.c:45
BSTR prefix
Definition: mxnamespace.c:46

Referenced by xsltParseStylesheetUser().

◆ xsltGetInheritedNsList()

static int xsltGetInheritedNsList ( xsltStylesheetPtr  style,
xsltTemplatePtr  template,
xmlNodePtr  node 
)
static

xsltGetInheritedNsList: @style: the stylesheet @template: the template @node: the current node

Search all the namespace applying to a given element except the ones from excluded output prefixes currently in scope. Initialize the template inheritedNs list with it.

Returns the number of entries found

Definition at line 1086 of file xslt.c.

1089{
1090 xmlNsPtr cur;
1091 xmlNsPtr *ret = NULL;
1092 int nbns = 0;
1093 int maxns = 10;
1094 int i;
1095
1096 if ((style == NULL) || (template == NULL) || (node == NULL) ||
1097 (template->inheritedNsNr != 0) || (template->inheritedNs != NULL))
1098 return(0);
1099 while (node != NULL) {
1100 if (node->type == XML_ELEMENT_NODE) {
1101 cur = node->nsDef;
1102 while (cur != NULL) {
1103 if (xmlStrEqual(cur->href, XSLT_NAMESPACE))
1104 goto skip_ns;
1105
1106 if ((cur->prefix != NULL) &&
1107 (xsltCheckExtPrefix(style, cur->prefix)))
1108 goto skip_ns;
1109 /*
1110 * Check if this namespace was excluded.
1111 * Note that at this point only the exclusions defined
1112 * on the topmost stylesheet element are in the exclusion-list.
1113 */
1114 for (i = 0;i < style->exclPrefixNr;i++) {
1115 if (xmlStrEqual(cur->href, style->exclPrefixTab[i]))
1116 goto skip_ns;
1117 }
1118 if (ret == NULL) {
1119 ret =
1120 (xmlNsPtr *) xmlMalloc((maxns + 1) *
1121 sizeof(xmlNsPtr));
1122 if (ret == NULL) {
1124 "xsltGetInheritedNsList : out of memory!\n");
1125 return(0);
1126 }
1127 ret[nbns] = NULL;
1128 }
1129 /*
1130 * Skip shadowed namespace bindings.
1131 */
1132 for (i = 0; i < nbns; i++) {
1133 if ((cur->prefix == ret[i]->prefix) ||
1134 (xmlStrEqual(cur->prefix, ret[i]->prefix)))
1135 break;
1136 }
1137 if (i >= nbns) {
1138 if (nbns >= maxns) {
1139 maxns *= 2;
1140 ret = (xmlNsPtr *) xmlRealloc(ret,
1141 (maxns +
1142 1) *
1143 sizeof(xmlNsPtr));
1144 if (ret == NULL) {
1146 "xsltGetInheritedNsList : realloc failed!\n");
1147 return(0);
1148 }
1149 }
1150 ret[nbns++] = cur;
1151 ret[nbns] = NULL;
1152 }
1153skip_ns:
1154 cur = cur->next;
1155 }
1156 }
1157 node = node->parent;
1158 }
1159 if (nbns != 0) {
1160#ifdef WITH_XSLT_DEBUG_PARSING
1162 "template has %d inherited namespaces\n", nbns);
1163#endif
1164 template->inheritedNsNr = nbns;
1165 template->inheritedNs = ret;
1166 }
1167 return (nbns);
1168}
int xsltCheckExtPrefix(xsltStylesheetPtr style, const xmlChar *URI)
Definition: extensions.c:1158
xmlNs * xmlNsPtr
Definition: tree.h:388
Definition: dlist.c:348
#define XSLT_NAMESPACE
Definition: xslt.h:46

Referenced by xsltParseStylesheetTemplate().

◆ xsltInit()

void xsltInit ( void  )

xsltInit:

Initializes the processor (e.g. registers built-in extensions, etc.)

Definition at line 201 of file xslt.c.

201 {
202 if (initialized == 0) {
203 initialized = 1;
204#ifdef XSLT_LOCALE_WINAPI
205 xsltLocaleMutex = xmlNewRMutex();
206#endif
208 }
209}
void xsltRegisterAllExtras(void)
Definition: extra.c:149
XMLPUBFUN xmlRMutexPtr XMLCALL xmlNewRMutex(void)
Definition: threads.c:276
static int initialized
Definition: xslt.c:193

Referenced by xsltNewStylesheetInternal().

◆ xsltIsBlank()

int xsltIsBlank ( xmlChar str)

xsltIsBlank: @str: a string

Check if a string is ignorable

Returns 1 if the string is NULL or made of blanks chars, 0 otherwise

Definition at line 234 of file xslt.c.

234 {
235 if (str == NULL)
236 return(1);
237 while (*str != 0) {
238 if (!(IS_BLANK(*str))) return(0);
239 str++;
240 }
241 return(1);
242}
const WCHAR * str
#define IS_BLANK(c)
Definition: xslt.c:79

Referenced by xsltVariableComp().

◆ xsltLoadStylesheetPI()

xsltStylesheetPtr xsltLoadStylesheetPI ( xmlDocPtr  doc)

xsltLoadStylesheetPI: @doc: a document to process

This function tries to locate the stylesheet PI in the given document If found, and if contained within the document, it will extract that subtree to build the stylesheet to process @doc (doc itself will be modified). If found but referencing an external document it will attempt to load it and generate a stylesheet from it. In both cases, the resulting stylesheet and the document need to be freed once the transformation is done.

Returns a new XSLT stylesheet structure or NULL if not found.

Definition at line 6873 of file xslt.c.

6873 {
6876 xmlChar *href = NULL;
6877 xmlURIPtr URI;
6878
6880
6881 if (doc == NULL)
6882 return(NULL);
6883
6884 /*
6885 * Find the text/xml stylesheet PI id any before the root
6886 */
6887 child = doc->children;
6888 while ((child != NULL) && (child->type != XML_ELEMENT_NODE)) {
6889 if ((child->type == XML_PI_NODE) &&
6890 (xmlStrEqual(child->name, BAD_CAST "xml-stylesheet"))) {
6891 href = xsltParseStylesheetPI(child->content);
6892 if (href != NULL)
6893 break;
6894 }
6895 child = child->next;
6896 }
6897
6898 /*
6899 * If found check the href to select processing
6900 */
6901 if (href != NULL) {
6902#ifdef WITH_XSLT_DEBUG_PARSING
6904 "xsltLoadStylesheetPI : found PI href=%s\n", href);
6905#endif
6906 URI = xmlParseURI((const char *) href);
6907 if (URI == NULL) {
6909 "xml-stylesheet : href %s is not valid\n", href);
6910 xmlFree(href);
6911 return(NULL);
6912 }
6913 if ((URI->fragment != NULL) && (URI->scheme == NULL) &&
6914 (URI->opaque == NULL) && (URI->authority == NULL) &&
6915 (URI->server == NULL) && (URI->user == NULL) &&
6916 (URI->path == NULL) && (URI->query == NULL)) {
6917 xmlAttrPtr ID;
6918
6919#ifdef WITH_XSLT_DEBUG_PARSING
6921 "xsltLoadStylesheetPI : Reference to ID %s\n", href);
6922#endif
6923 if (URI->fragment[0] == '#')
6924 ID = xmlGetID(doc, (const xmlChar *) &(URI->fragment[1]));
6925 else
6926 ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
6927 if (ID == NULL) {
6929 "xml-stylesheet : no ID %s found\n", URI->fragment);
6930 } else {
6931 xmlDocPtr fake;
6932 xmlNodePtr subtree, newtree;
6933 xmlNsPtr ns;
6934
6935#ifdef WITH_XSLT_DEBUG
6937 "creating new document from %s for embedded stylesheet\n",
6938 doc->URL);
6939#endif
6940 /*
6941 * move the subtree in a new document passed to
6942 * the stylesheet analyzer
6943 */
6944 subtree = ID->parent;
6945 fake = xmlNewDoc(NULL);
6946 if (fake != NULL) {
6947 /*
6948 * Should the dictionary still be shared even though
6949 * the nodes are being copied rather than moved?
6950 */
6951 fake->dict = doc->dict;
6952 xmlDictReference(doc->dict);
6953#ifdef WITH_XSLT_DEBUG
6955 "reusing dictionary from %s for embedded stylesheet\n",
6956 doc->URL);
6957#endif
6958
6959 newtree = xmlDocCopyNode(subtree, fake, 1);
6960
6961 fake->URL = xmlNodeGetBase(doc, subtree->parent);
6962#ifdef WITH_XSLT_DEBUG
6964 "set base URI for embedded stylesheet as %s\n",
6965 fake->URL);
6966#endif
6967
6968 /*
6969 * Add all namespaces in scope of embedded stylesheet to
6970 * root element of newly created stylesheet document
6971 */
6972 while ((subtree = subtree->parent) != (xmlNodePtr)doc) {
6973 for (ns = subtree->ns; ns; ns = ns->next) {
6974 xmlNewNs(newtree, ns->href, ns->prefix);
6975 }
6976 }
6977
6978 xmlAddChild((xmlNodePtr)fake, newtree);
6980 if (ret == NULL)
6981 xmlFreeDoc(fake);
6982 }
6983 }
6984 } else {
6985 xmlChar *URL, *base;
6986
6987 /*
6988 * Reference to an external stylesheet
6989 */
6990
6991 base = xmlNodeGetBase(doc, (xmlNodePtr) doc);
6992 URL = xmlBuildURI(href, base);
6993 if (URL != NULL) {
6994#ifdef WITH_XSLT_DEBUG_PARSING
6996 "xsltLoadStylesheetPI : fetching %s\n", URL);
6997#endif
6999 xmlFree(URL);
7000 } else {
7001#ifdef WITH_XSLT_DEBUG_PARSING
7003 "xsltLoadStylesheetPI : fetching %s\n", href);
7004#endif
7006 }
7007 if (base != NULL)
7008 xmlFree(base);
7009 }
7010 xmlFreeURI(URI);
7011 xmlFree(href);
7012 }
7013 return(ret);
7014}
void xsltInitGlobals(void)
Definition: extensions.c:2257
static HWND child
Definition: cursoricon.c:298
#define ID
Definition: ruserpass.c:36
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:647
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
@ XML_PI_NODE
Definition: tree.h:166
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
XMLPUBFUN xmlNsPtr XMLCALL xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix)
XMLPUBFUN xmlNodePtr XMLCALL xmlDocCopyNode(xmlNodePtr node, xmlDocPtr doc, int recursive)
Definition: tree.h:434
Definition: tree.h:551
const xmlChar * URL
Definition: tree.h:577
struct _xmlDict * dict
Definition: tree.h:580
struct _xmlNode * children
Definition: tree.h:555
struct _xmlNode * parent
Definition: tree.h:495
xmlNs * ns
Definition: tree.h:501
Definition: uri.h:33
char * authority
Definition: uri.h:36
char * server
Definition: uri.h:37
char * opaque
Definition: uri.h:35
char * user
Definition: uri.h:38
char * path
Definition: uri.h:40
char * scheme
Definition: uri.h:34
char * query
Definition: uri.h:41
char * fragment
Definition: uri.h:42
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
Definition: uri.c:940
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1387
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1892
XMLPUBFUN xmlAttrPtr XMLCALL xmlGetID(xmlDocPtr doc, const xmlChar *ID)
Definition: valid.c:2874
#define BAD_CAST
Definition: xmlstring.h:35
xsltStylesheetPtr xsltParseStylesheetFile(const xmlChar *filename)
Definition: xslt.c:6711
xsltStylesheetPtr xsltParseStylesheetDoc(xmlDocPtr doc)
Definition: xslt.c:6695
static xmlChar * xsltParseStylesheetPI(const xmlChar *value)
Definition: xslt.c:6783

◆ xsltNewDecimalFormat()

static xsltDecimalFormatPtr xsltNewDecimalFormat ( const xmlChar nsUri,
xmlChar name 
)
static

Definition at line 250 of file xslt.c.

251{
253 /* UTF-8 for 0x2030 */
254 static const xmlChar permille[4] = {0xe2, 0x80, 0xb0, 0};
255
256 self = xmlMalloc(sizeof(xsltDecimalFormat));
257 if (self != NULL) {
258 self->next = NULL;
259 self->nsUri = nsUri;
260 self->name = name;
261
262 /* Default values */
263 self->digit = xmlStrdup(BAD_CAST("#"));
264 self->patternSeparator = xmlStrdup(BAD_CAST(";"));
265 self->decimalPoint = xmlStrdup(BAD_CAST("."));
266 self->grouping = xmlStrdup(BAD_CAST(","));
267 self->percent = xmlStrdup(BAD_CAST("%"));
268 self->permille = xmlStrdup(BAD_CAST(permille));
269 self->zeroDigit = xmlStrdup(BAD_CAST("0"));
270 self->minusSign = xmlStrdup(BAD_CAST("-"));
271 self->infinity = xmlStrdup(BAD_CAST("Infinity"));
272 self->noNumber = xmlStrdup(BAD_CAST("NaN"));
273 }
274 return self;
275}
const xmlChar * nsUri
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67

Referenced by xsltNewStylesheetInternal(), and xsltParseStylesheetDecimalFormat().

◆ xsltNewStylesheet()

xsltStylesheetPtr xsltNewStylesheet ( void  )

xsltNewStylesheet:

Create a new XSLT Stylesheet

Returns the newly allocated xsltStylesheetPtr or NULL in case of error

Definition at line 795 of file xslt.c.

795 {
797}
static xsltStylesheetPtr xsltNewStylesheetInternal(xsltStylesheetPtr parent)
Definition: xslt.c:730

Referenced by xsltDocumentElem().

◆ xsltNewStylesheetInternal()

static xsltStylesheetPtr xsltNewStylesheetInternal ( xsltStylesheetPtr  parent)
static

xsltNewStylesheetInternal: @parent: the parent stylesheet or NULL

Create a new XSLT Stylesheet

Returns the newly allocated xsltStylesheetPtr or NULL in case of error

Definition at line 730 of file xslt.c.

730 {
732
734 if (ret == NULL) {
736 "xsltNewStylesheet : malloc failed\n");
737 goto internal_err;
738 }
739 memset(ret, 0, sizeof(xsltStylesheet));
740
741 ret->parent = parent;
742 ret->omitXmlDeclaration = -1;
743 ret->standalone = -1;
744 ret->decimalFormat = xsltNewDecimalFormat(NULL, NULL);
745 ret->indent = -1;
746 ret->errors = 0;
747 ret->warnings = 0;
748 ret->exclPrefixNr = 0;
749 ret->exclPrefixMax = 0;
750 ret->exclPrefixTab = NULL;
751 ret->extInfos = NULL;
752 ret->extrasNr = 0;
753 ret->internalized = 1;
754 ret->literal_result = 0;
755 ret->forwards_compatible = 0;
756 ret->dict = xmlDictCreate();
757#ifdef WITH_XSLT_DEBUG
759 "creating dictionary for stylesheet\n");
760#endif
761
762 if (parent == NULL) {
763 ret->principal = ret;
764
765 ret->xpathCtxt = xmlXPathNewContext(NULL);
766 if (ret->xpathCtxt == NULL) {
768 "xsltNewStylesheet: xmlXPathNewContext failed\n");
769 goto internal_err;
770 }
771 if (xmlXPathContextSetCache(ret->xpathCtxt, 1, -1, 0) == -1)
772 goto internal_err;
773 } else {
774 ret->principal = parent->principal;
775 }
776
777 xsltInit();
778
779 return(ret);
780
781internal_err:
782 if (ret != NULL)
784 return(NULL);
785}
r parent
Definition: btrfs.c:3010
XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreate(void)
Definition: dict.c:577
xsltStylesheet * xsltStylesheetPtr
void xsltInit(void)
Definition: xslt.c:201
static xsltDecimalFormatPtr xsltNewDecimalFormat(const xmlChar *nsUri, xmlChar *name)
Definition: xslt.c:250

Referenced by xsltNewStylesheet(), and xsltParseStylesheetImportedDoc().

◆ xsltNewTemplate()

static xsltTemplatePtr xsltNewTemplate ( void  )
static

xsltNewTemplate:

Create a new XSLT Template

Returns the newly allocated xsltTemplatePtr or NULL in case of error

Definition at line 394 of file xslt.c.

394 {
396
398 if (cur == NULL) {
400 "xsltNewTemplate : malloc failed\n");
401 return(NULL);
402 }
403 memset(cur, 0, sizeof(xsltTemplate));
404 cur->priority = XSLT_PAT_NO_PRIORITY;
405 return(cur);
406}
#define XSLT_PAT_NO_PRIORITY
xsltTemplate * xsltTemplatePtr

Referenced by xsltParseStylesheetProcess(), and xsltParseStylesheetTemplate().

◆ xsltParseContentError()

static void xsltParseContentError ( xsltStylesheetPtr  style,
xmlNodePtr  node 
)
static

xsltParseContentError:

@style: the stylesheet @node: the node where the error occured

Compile-time error function.

Definition at line 97 of file xslt.c.

99{
100 if ((style == NULL) || (node == NULL))
101 return;
102
103 if (IS_XSLT_ELEM(node))
105 "The XSLT-element '%s' is not allowed at this position.\n",
106 node->name);
107 else
109 "The element '%s' is not allowed at this position.\n",
110 node->name);
111 style->errors++;
112}
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:51

Referenced by xsltParseStylesheetDecimalFormat(), xsltParseStylesheetKey(), xsltParseStylesheetOutput(), xsltParseStylesheetPreserveSpace(), and xsltParseStylesheetStripSpace().

◆ xsltParseStylesheetDecimalFormat()

static void xsltParseStylesheetDecimalFormat ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)
static

xsltParseStylesheetDecimalFormat: @style: the XSLT stylesheet @cur: the "decimal-format" element

<xsl:decimal-format name = qname, decimal-separator = char, grouping-separator = char, infinity = string, minus-sign = char, NaN = string, percent = char per-mille = char, zero-digit = char, digit = char, pattern-separator = char />

parse an XSLT stylesheet decimal-format element and and record the formatting characteristics

Definition at line 1399 of file xslt.c.

1400{
1401 xmlChar *prop;
1404
1405 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
1406 return;
1407
1408 format = style->decimalFormat;
1409
1410 prop = xmlGetNsProp(cur, BAD_CAST("name"), NULL);
1411 if (prop != NULL) {
1412 const xmlChar *nsUri;
1413
1414 if (xmlValidateQName(prop, 0) != 0) {
1416 "xsl:decimal-format: Invalid QName '%s'.\n", prop);
1417 style->warnings++;
1418 xmlFree(prop);
1419 return;
1420 }
1421 /*
1422 * TODO: Don't use xsltGetQNameURI().
1423 */
1424 nsUri = xsltGetQNameURI(cur, &prop);
1425 if (prop == NULL) {
1426 style->warnings++;
1427 return;
1428 }
1430 if (format != NULL) {
1432 "xsltParseStylestyleDecimalFormat: %s already exists\n", prop);
1433 style->warnings++;
1434 xmlFree(prop);
1435 return;
1436 }
1437 format = xsltNewDecimalFormat(nsUri, prop);
1438 if (format == NULL) {
1440 "xsltParseStylestyleDecimalFormat: failed creating new decimal-format\n");
1441 style->errors++;
1442 xmlFree(prop);
1443 return;
1444 }
1445 /* Append new decimal-format structure */
1446 for (iter = style->decimalFormat; iter->next; iter = iter->next)
1447 ;
1448 if (iter)
1449 iter->next = format;
1450 }
1451
1452 prop = xmlGetNsProp(cur, (const xmlChar *)"decimal-separator", NULL);
1453 if (prop != NULL) {
1454 if (format->decimalPoint != NULL) xmlFree(format->decimalPoint);
1455 format->decimalPoint = prop;
1456 }
1457
1458 prop = xmlGetNsProp(cur, (const xmlChar *)"grouping-separator", NULL);
1459 if (prop != NULL) {
1460 if (format->grouping != NULL) xmlFree(format->grouping);
1461 format->grouping = prop;
1462 }
1463
1464 prop = xmlGetNsProp(cur, (const xmlChar *)"infinity", NULL);
1465 if (prop != NULL) {
1466 if (format->infinity != NULL) xmlFree(format->infinity);
1467 format->infinity = prop;
1468 }
1469
1470 prop = xmlGetNsProp(cur, (const xmlChar *)"minus-sign", NULL);
1471 if (prop != NULL) {
1472 if (format->minusSign != NULL) xmlFree(format->minusSign);
1473 format->minusSign = prop;
1474 }
1475
1476 prop = xmlGetNsProp(cur, (const xmlChar *)"NaN", NULL);
1477 if (prop != NULL) {
1478 if (format->noNumber != NULL) xmlFree(format->noNumber);
1479 format->noNumber = prop;
1480 }
1481
1482 prop = xmlGetNsProp(cur, (const xmlChar *)"percent", NULL);
1483 if (prop != NULL) {
1484 if (format->percent != NULL) xmlFree(format->percent);
1485 format->percent = prop;
1486 }
1487
1488 prop = xmlGetNsProp(cur, (const xmlChar *)"per-mille", NULL);
1489 if (prop != NULL) {
1490 if (format->permille != NULL) xmlFree(format->permille);
1491 format->permille = prop;
1492 }
1493
1494 prop = xmlGetNsProp(cur, (const xmlChar *)"zero-digit", NULL);
1495 if (prop != NULL) {
1496 if (format->zeroDigit != NULL) xmlFree(format->zeroDigit);
1497 format->zeroDigit = prop;
1498 }
1499
1500 prop = xmlGetNsProp(cur, (const xmlChar *)"digit", NULL);
1501 if (prop != NULL) {
1502 if (format->digit != NULL) xmlFree(format->digit);
1503 format->digit = prop;
1504 }
1505
1506 prop = xmlGetNsProp(cur, (const xmlChar *)"pattern-separator", NULL);
1507 if (prop != NULL) {
1508 if (format->patternSeparator != NULL) xmlFree(format->patternSeparator);
1509 format->patternSeparator = prop;
1510 }
1511 if (cur->children != NULL) {
1512 xsltParseContentError(style, cur->children);
1513 }
1514}
XMLPUBFUN xmlChar *XMLCALL xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
Definition: format.c:58
xsltDecimalFormatPtr xsltDecimalFormatGetByQName(xsltStylesheetPtr style, const xmlChar *nsUri, const xmlChar *name)
Definition: xslt.c:364
static void xsltParseContentError(xsltStylesheetPtr style, xmlNodePtr node)
Definition: xslt.c:97
const xmlChar * xsltGetQNameURI(xmlNodePtr node, xmlChar **name)
Definition: xsltutils.c:753

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetDoc()

xsltStylesheetPtr xsltParseStylesheetDoc ( xmlDocPtr  doc)

xsltParseStylesheetDoc: @doc: and xmlDoc parsed XML

parse an XSLT stylesheet, building the associated structures. doc is kept as a reference within the returned stylesheet, so changes to doc after the parsing will be reflected when the stylesheet is applied, and the doc is automatically freed when the stylesheet is closed.

Returns a new XSLT stylesheet structure.

Definition at line 6695 of file xslt.c.

6695 {
6697
6699}
xsltStylesheetPtr xsltParseStylesheetImportedDoc(xmlDocPtr doc, xsltStylesheetPtr parentStyle)
Definition: xslt.c:6514

Referenced by xsltLoadStylesheetPI(), and xsltParseStylesheetFile().

◆ xsltParseStylesheetExcludePrefix()

static int xsltParseStylesheetExcludePrefix ( xsltStylesheetPtr  style,
xmlNodePtr  cur,
int  isXsltElem 
)
static

xsltParseStylesheetExcludePrefix: @style: the XSLT stylesheet @cur: the current point in the stylesheet

parse an XSLT stylesheet exclude prefix and record namespaces needing stripping

Returns the number of Excluded prefixes added at that level

Definition at line 1735 of file xslt.c.

1737{
1738 int nb = 0;
1740 xmlChar *prefix, *end;
1741
1742 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
1743 return(0);
1744
1745 if (isXsltElem)
1747 (const xmlChar *)"exclude-result-prefixes", NULL);
1748 else
1750 (const xmlChar *)"exclude-result-prefixes", XSLT_NAMESPACE);
1751
1752 if (prefixes == NULL) {
1753 return(0);
1754 }
1755
1756 prefix = prefixes;
1757 while (*prefix != 0) {
1758 while (IS_BLANK(*prefix)) prefix++;
1759 if (*prefix == 0)
1760 break;
1761 end = prefix;
1762 while ((*end != 0) && (!IS_BLANK(*end))) end++;
1763 prefix = xmlStrndup(prefix, end - prefix);
1764 if (prefix) {
1765 xmlNsPtr ns;
1766
1767 if (xmlStrEqual(prefix, (const xmlChar *)"#default"))
1768 ns = xmlSearchNs(style->doc, cur, NULL);
1769 else
1770 ns = xmlSearchNs(style->doc, cur, prefix);
1771 if (ns == NULL) {
1773 "xsl:exclude-result-prefixes : undefined namespace %s\n",
1774 prefix);
1775 if (style != NULL) style->warnings++;
1776 } else {
1777 if (exclPrefixPush(style, (xmlChar *) ns->href) >= 0) {
1778#ifdef WITH_XSLT_DEBUG_PARSING
1780 "exclude result prefix %s\n", prefix);
1781#endif
1782 nb++;
1783 }
1784 }
1785 xmlFree(prefix);
1786 }
1787 prefix = end;
1788 }
1790 return(nb);
1791}
GLuint GLuint end
Definition: gl.h:1545
static int prefixes
Definition: i386-dis.c:276
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:42
static int exclPrefixPush(xsltStylesheetPtr style, xmlChar *value)
Definition: xslt.c:127

Referenced by xsltParseStylesheetProcess(), and xsltPreprocessStylesheet().

◆ xsltParseStylesheetExtPrefix()

static void xsltParseStylesheetExtPrefix ( xsltStylesheetPtr  style,
xmlNodePtr  cur,
int  isXsltElem 
)
static

xsltParseStylesheetExtPrefix: @style: the XSLT stylesheet @template: the "extension-element-prefixes" prefix

parse an XSLT stylesheet's "extension-element-prefix" attribute value and register the namespaces of extension instruction. SPEC "A namespace is designated as an extension namespace by using an extension-element-prefixes attribute on: 1) an xsl:stylesheet element 2) an xsl:extension-element-prefixes attribute on a literal result element 3) an extension instruction."

Definition at line 1599 of file xslt.c.

1600 {
1602 xmlChar *prefix, *end;
1603
1604 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
1605 return;
1606
1607 if (isXsltElem) {
1608 /* For xsl:stylesheet/xsl:transform. */
1610 (const xmlChar *)"extension-element-prefixes", NULL);
1611 } else {
1612 /* For literal result elements and extension instructions. */
1614 (const xmlChar *)"extension-element-prefixes", XSLT_NAMESPACE);
1615 }
1616 if (prefixes == NULL) {
1617 return;
1618 }
1619
1620 prefix = prefixes;
1621 while (*prefix != 0) {
1622 while (IS_BLANK(*prefix)) prefix++;
1623 if (*prefix == 0)
1624 break;
1625 end = prefix;
1626 while ((*end != 0) && (!IS_BLANK(*end))) end++;
1627 prefix = xmlStrndup(prefix, end - prefix);
1628 if (prefix) {
1629 xmlNsPtr ns;
1630
1631 if (xmlStrEqual(prefix, (const xmlChar *)"#default"))
1632 ns = xmlSearchNs(style->doc, cur, NULL);
1633 else
1634 ns = xmlSearchNs(style->doc, cur, prefix);
1635 if (ns == NULL) {
1637 "xsl:extension-element-prefix : undefined namespace %s\n",
1638 prefix);
1639 if (style != NULL) style->warnings++;
1640 } else {
1641#ifdef WITH_XSLT_DEBUG_PARSING
1643 "add extension prefix %s\n", prefix);
1644#endif
1645 xsltRegisterExtPrefix(style, prefix, ns->href);
1646 }
1647 xmlFree(prefix);
1648 }
1649 prefix = end;
1650 }
1652}
int xsltRegisterExtPrefix(xsltStylesheetPtr style, const xmlChar *prefix, const xmlChar *URI)
Definition: extensions.c:503

Referenced by xsltParseStylesheetProcess().

◆ xsltParseStylesheetFile()

xsltStylesheetPtr xsltParseStylesheetFile ( const xmlChar filename)

xsltParseStylesheetFile: @filename: the filename/URL to the stylesheet

Load and parse an XSLT stylesheet

Returns a new XSLT stylesheet structure.

Definition at line 6711 of file xslt.c.

6711 {
6714 xmlDocPtr doc;
6715
6717
6718 if (filename == NULL)
6719 return(NULL);
6720
6721#ifdef WITH_XSLT_DEBUG_PARSING
6723 "xsltParseStylesheetFile : parse %s\n", filename);
6724#endif
6725
6726 /*
6727 * Security framework check
6728 */
6730 if (sec != NULL) {
6731 int res;
6732
6733 res = xsltCheckRead(sec, NULL, filename);
6734 if (res <= 0) {
6735 if (res == 0)
6737 "xsltParseStylesheetFile: read rights for %s denied\n",
6738 filename);
6739 return(NULL);
6740 }
6741 }
6742
6745 if (doc == NULL) {
6747 "xsltParseStylesheetFile : cannot parse %s\n", filename);
6748 return(NULL);
6749 }
6751 if (ret == NULL) {
6752 xmlFreeDoc(doc);
6753 return(NULL);
6754 }
6755
6756 return(ret);
6757}
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:163
int xsltCheckRead(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:402
xsltDocLoaderFunc xsltDocDefaultLoader
Definition: documents.c:93
@ XSLT_LOAD_START
Definition: documents.h:54
GLuint res
Definition: glext.h:9613
const char * filename
Definition: ioapi.h:137
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54

Referenced by xsltLoadStylesheetPI().

◆ xsltParseStylesheetImportedDoc()

xsltStylesheetPtr xsltParseStylesheetImportedDoc ( xmlDocPtr  doc,
xsltStylesheetPtr  parentStyle 
)

xsltParseStylesheetImportedDoc: @doc: an xmlDoc parsed XML @parentStyle: pointer to the parent stylesheet (if it exists)

parse an XSLT stylesheet building the associated structures except the processing not needed for imported documents.

Returns a new XSLT stylesheet structure.

Definition at line 6514 of file xslt.c.

6515 {
6516 xsltStylesheetPtr retStyle;
6517
6518 if (doc == NULL)
6519 return(NULL);
6520
6521 retStyle = xsltNewStylesheetInternal(parentStyle);
6522 if (retStyle == NULL)
6523 return(NULL);
6524
6525 if (xsltParseStylesheetUser(retStyle, doc) != 0) {
6526 xsltFreeStylesheet(retStyle);
6527 return(NULL);
6528 }
6529
6530 return(retStyle);
6531}
int xsltParseStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc)
Definition: xslt.c:6543

Referenced by xsltParseStylesheetDoc(), and xsltParseStylesheetImport().

◆ xsltParseStylesheetKey()

static void xsltParseStylesheetKey ( xsltStylesheetPtr  style,
xmlNodePtr  key 
)
static

xsltParseStylesheetKey: @style: the XSLT stylesheet @key: the "key" element

<xsl:key name = qname, match = pattern, use = expression />

parse an XSLT stylesheet key definition and register it

Definition at line 5098 of file xslt.c.

5098 {
5099 xmlChar *prop = NULL;
5100 xmlChar *use = NULL;
5101 xmlChar *match = NULL;
5102 xmlChar *name = NULL;
5103 xmlChar *nameURI = NULL;
5104
5105 if ((style == NULL) || (key == NULL) || (key->type != XML_ELEMENT_NODE))
5106 return;
5107
5108 /*
5109 * Get arguments
5110 */
5111 prop = xmlGetNsProp(key, (const xmlChar *)"name", NULL);
5112 if (prop != NULL) {
5113 const xmlChar *URI;
5114
5115 /*
5116 * TODO: Don't use xsltGetQNameURI().
5117 */
5118 URI = xsltGetQNameURI(key, &prop);
5119 if (prop == NULL) {
5120 if (style != NULL) style->errors++;
5121 goto error;
5122 } else {
5123 name = prop;
5124 if (URI != NULL)
5125 nameURI = xmlStrdup(URI);
5126 }
5127#ifdef WITH_XSLT_DEBUG_PARSING
5129 "xsltParseStylesheetKey: name %s\n", name);
5130#endif
5131 } else {
5133 "xsl:key : error missing name\n");
5134 if (style != NULL) style->errors++;
5135 goto error;
5136 }
5137
5138 match = xmlGetNsProp(key, (const xmlChar *)"match", NULL);
5139 if (match == NULL) {
5141 "xsl:key : error missing match\n");
5142 if (style != NULL) style->errors++;
5143 goto error;
5144 }
5145
5146 use = xmlGetNsProp(key, (const xmlChar *)"use", NULL);
5147 if (use == NULL) {
5149 "xsl:key : error missing use\n");
5150 if (style != NULL) style->errors++;
5151 goto error;
5152 }
5153
5154 /*
5155 * register the keys
5156 */
5157 xsltAddKey(style, name, nameURI, match, use, key);
5158
5159
5160error:
5161 if (use != NULL)
5162 xmlFree(use);
5163 if (match != NULL)
5164 xmlFree(match);
5165 if (name != NULL)
5166 xmlFree(name);
5167 if (nameURI != NULL)
5168 xmlFree(nameURI);
5169
5170 if (key->children != NULL) {
5171 xsltParseContentError(style, key->children);
5172 }
5173}
int xsltAddKey(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *nameURI, const xmlChar *match, const xmlChar *use, xmlNodePtr inst)
Definition: keys.c:263
#define error(str)
Definition: mkdosfs.c:1605
Definition: copy.c:22
Definition: match.c:28

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetOutput()

void xsltParseStylesheetOutput ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)

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

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

Definition at line 1181 of file xslt.c.

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

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetPI()

static xmlChar * xsltParseStylesheetPI ( const xmlChar value)
static

xsltParseStylesheetPI: @value: the value of the PI

This function checks that the type is text/xml and extracts the URI-Reference for the stylesheet

Returns the URI-Reference for the stylesheet or NULL (it need to be freed by the caller)

Definition at line 6783 of file xslt.c.

6783 {
6784 const xmlChar *cur;
6785 const xmlChar *start;
6786 xmlChar *val;
6787 xmlChar tmp;
6788 xmlChar *href = NULL;
6789 int isXml = 0;
6790
6791 if (value == NULL)
6792 return(NULL);
6793
6794 cur = value;
6795 while (CUR != 0) {
6797 if ((CUR == 't') && (NXT(1) == 'y') && (NXT(2) == 'p') &&
6798 (NXT(3) == 'e')) {
6799 SKIP(4);
6801 if (CUR != '=')
6802 continue;
6803 NEXT;
6804 if ((CUR != '\'') && (CUR != '"'))
6805 continue;
6806 tmp = CUR;
6807 NEXT;
6808 start = cur;
6809 while ((CUR != 0) && (CUR != tmp))
6810 NEXT;
6811 if (CUR != tmp)
6812 continue;
6814 NEXT;
6815 if (val == NULL)
6816 return(NULL);
6817 if ((xmlStrcasecmp(val, BAD_CAST "text/xml")) &&
6818 (xmlStrcasecmp(val, BAD_CAST "text/xsl"))) {
6819 xmlFree(val);
6820 break;
6821 }
6822 isXml = 1;
6823 xmlFree(val);
6824 } else if ((CUR == 'h') && (NXT(1) == 'r') && (NXT(2) == 'e') &&
6825 (NXT(3) == 'f')) {
6826 SKIP(4);
6828 if (CUR != '=')
6829 continue;
6830 NEXT;
6831 if ((CUR != '\'') && (CUR != '"'))
6832 continue;
6833 tmp = CUR;
6834 NEXT;
6835 start = cur;
6836 while ((CUR != 0) && (CUR != tmp))
6837 NEXT;
6838 if (CUR != tmp)
6839 continue;
6840 if (href == NULL)
6841 href = xmlStrndup(start, cur - start);
6842 NEXT;
6843 } else {
6844 while ((CUR != 0) && (!IS_BLANK(CUR)))
6845 NEXT;
6846 }
6847
6848 }
6849
6850 if (!isXml) {
6851 if (href != NULL)
6852 xmlFree(href);
6853 href = NULL;
6854 }
6855 return(href);
6856}
GLuint start
Definition: gl.h:1545
GLuint GLfloat * val
Definition: glext.h:7180
XMLPUBFUN int XMLCALL xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:275
#define NEXT
Definition: xslt.c:6770
#define SKIP_BLANKS
Definition: xslt.c:6768
#define SKIP(val)
Definition: xslt.c:6766
#define NXT(val)
Definition: xslt.c:6767
#define CUR
Definition: xslt.c:6765

Referenced by xsltLoadStylesheetPI().

◆ xsltParseStylesheetPreserveSpace()

static void xsltParseStylesheetPreserveSpace ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)
static

xsltParseStylesheetPreserveSpace: @style: the XSLT stylesheet @cur: the "preserve-space" element

parse an XSLT stylesheet preserve-space element and record elements needing preserving

Definition at line 1526 of file xslt.c.

1526 {
1527 xmlChar *elements;
1528 xmlChar *element, *end;
1529
1530 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
1531 return;
1532
1533 elements = xmlGetNsProp(cur, (const xmlChar *)"elements", NULL);
1534 if (elements == NULL) {
1536 "xsltParseStylesheetPreserveSpace: missing elements attribute\n");
1537 if (style != NULL) style->warnings++;
1538 return;
1539 }
1540
1541 if (style->stripSpaces == NULL)
1542 style->stripSpaces = xmlHashCreate(10);
1543 if (style->stripSpaces == NULL)
1544 return;
1545
1546 element = elements;
1547 while (*element != 0) {
1548 while (IS_BLANK(*element)) element++;
1549 if (*element == 0)
1550 break;
1551 end = element;
1552 while ((*end != 0) && (!IS_BLANK(*end))) end++;
1554 if (element) {
1555#ifdef WITH_XSLT_DEBUG_PARSING
1557 "add preserved space element %s\n", element);
1558#endif
1559 if (xmlStrEqual(element, (const xmlChar *)"*")) {
1560 style->stripAll = -1;
1561 } else {
1562 const xmlChar *URI;
1563
1564 /*
1565 * TODO: Don't use xsltGetQNameURI().
1566 */
1567 URI = xsltGetQNameURI(cur, &element);
1568
1569 xmlHashAddEntry2(style->stripSpaces, element, URI,
1570 (xmlChar *) "preserve");
1571 }
1573 }
1574 element = end;
1575 }
1576 xmlFree(elements);
1577 if (cur->children != NULL) {
1578 xsltParseContentError(style, cur->children);
1579 }
1580}

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetProcess()

xsltStylesheetPtr xsltParseStylesheetProcess ( xsltStylesheetPtr  ret,
xmlDocPtr  doc 
)

xsltParseStylesheetProcess: @ret: the XSLT stylesheet (the current stylesheet-level) @doc: and xmlDoc parsed XML

Parses an XSLT stylesheet, adding the associated structures. Called by: xsltParseStylesheetImportedDoc() (xslt.c) xsltParseStylesheetInclude() (imports.c)

Returns the value of the @style parameter if everything went right, NULL if something went amiss.

Definition at line 6406 of file xslt.c.

6406 {
6408
6410
6411 if (doc == NULL)
6412 return(NULL);
6413 if (ret == NULL)
6414 return(ret);
6415
6416 /*
6417 * First steps, remove blank nodes,
6418 * locate the xsl:stylesheet element and the
6419 * namespace declaration.
6420 */
6422 if (cur == NULL) {
6424 "xsltParseStylesheetProcess : empty stylesheet\n");
6425 return(NULL);
6426 }
6427
6428 if ((IS_XSLT_ELEM(cur)) &&
6429 ((IS_XSLT_NAME(cur, "stylesheet")) ||
6430 (IS_XSLT_NAME(cur, "transform")))) {
6431#ifdef WITH_XSLT_DEBUG_PARSING
6433 "xsltParseStylesheetProcess : found stylesheet\n");
6434#endif
6435 ret->literal_result = 0;
6438 } else {
6441 ret->literal_result = 1;
6442 }
6443 if (!ret->nopreproc) {
6445 }
6446 if (ret->literal_result == 0) {
6448 } else {
6449 xmlChar *prop;
6450 xsltTemplatePtr template;
6451
6452 /*
6453 * the document itself might be the template, check xsl:version
6454 */
6455 prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
6456 if (prop == NULL) {
6458 "xsltParseStylesheetProcess : document is not a stylesheet\n");
6459 return(NULL);
6460 }
6461
6462#ifdef WITH_XSLT_DEBUG_PARSING
6464 "xsltParseStylesheetProcess : document is stylesheet\n");
6465#endif
6466
6467 if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
6468 (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
6470 "xsl:version: only 1.1 features are supported\n");
6471 ret->forwards_compatible = 1;
6472 ret->warnings++;
6473 }
6474 xmlFree(prop);
6475
6476 /*
6477 * Create and link the template
6478 */
6479 template = xsltNewTemplate();
6480 if (template == NULL) {
6481 return(NULL);
6482 }
6483 template->next = ret->templates;
6484 ret->templates = template;
6485 template->match = xmlStrdup((const xmlChar *)"/");
6486
6487 /*
6488 * parse the content and register the pattern
6489 */
6491 template->elem = (xmlNodePtr) doc;
6492 template->content = doc->children;
6493 xsltAddTemplate(ret, template, NULL, NULL);
6494 ret->literal_result = 1;
6495 }
6496
6497 return(ret);
6498}
int xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, const xmlChar *mode, const xmlChar *modeURI)
Definition: pattern.c:2016
xmlNode * xmlNodePtr
Definition: tree.h:488
static void xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top)
Definition: xslt.c:6078
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4878
static void xsltPreprocessStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:3469
static int xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1735
static void xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1599
static xsltTemplatePtr xsltNewTemplate(void)
Definition: xslt.c:394
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:60

Referenced by xsltParseStylesheetInclude(), and xsltParseStylesheetUser().

◆ xsltParseStylesheetStripSpace()

static void xsltParseStylesheetStripSpace ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)
static

xsltParseStylesheetStripSpace: @style: the XSLT stylesheet @cur: the "strip-space" element

parse an XSLT stylesheet's strip-space element and record the elements needing stripping

Definition at line 1665 of file xslt.c.

1665 {
1666 xmlChar *elements;
1667 xmlChar *element, *end;
1668
1669 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
1670 return;
1671
1672 elements = xmlGetNsProp(cur, (const xmlChar *)"elements", NULL);
1673 if (elements == NULL) {
1675 "xsltParseStylesheetStripSpace: missing elements attribute\n");
1676 if (style != NULL) style->warnings++;
1677 return;
1678 }
1679
1680 if (style->stripSpaces == NULL)
1681 style->stripSpaces = xmlHashCreate(10);
1682 if (style->stripSpaces == NULL)
1683 return;
1684
1685 element = elements;
1686 while (*element != 0) {
1687 while (IS_BLANK(*element)) element++;
1688 if (*element == 0)
1689 break;
1690 end = element;
1691 while ((*end != 0) && (!IS_BLANK(*end))) end++;
1693 if (element) {
1694#ifdef WITH_XSLT_DEBUG_PARSING
1696 "add stripped space element %s\n", element);
1697#endif
1698 if (xmlStrEqual(element, (const xmlChar *)"*")) {
1699 style->stripAll = 1;
1700 } else {
1701 const xmlChar *URI;
1702
1703 /*
1704 * TODO: Don't use xsltGetQNameURI().
1705 */
1706 URI = xsltGetQNameURI(cur, &element);
1707
1708 xmlHashAddEntry2(style->stripSpaces, element, URI,
1709 (xmlChar *) "strip");
1710 }
1712 }
1713 element = end;
1714 }
1715 xmlFree(elements);
1716 if (cur->children != NULL) {
1717 xsltParseContentError(style, cur->children);
1718 }
1719}

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetTemplate()

static void xsltParseStylesheetTemplate ( xsltStylesheetPtr  style,
xmlNodePtr  template 
)
static

xsltParseStylesheetTemplate: @style: the XSLT stylesheet @template: the "template" element

parse an XSLT stylesheet template building the associated structures

Definition at line 5350 of file xslt.c.

5350 {
5352 xmlChar *prop;
5353 xmlChar *mode = NULL;
5354 xmlChar *modeURI = NULL;
5355 double priority;
5356
5357 if ((style == NULL) || (template == NULL) ||
5358 (template->type != XML_ELEMENT_NODE))
5359 return;
5360
5361 /*
5362 * Create and link the structure
5363 */
5364 ret = xsltNewTemplate();
5365 if (ret == NULL)
5366 return;
5367 ret->next = style->templates;
5368 style->templates = ret;
5369 ret->style = style;
5370
5371 /*
5372 * Get inherited namespaces
5373 */
5374 /*
5375 * TODO: Apply the optimized in-scope-namespace mechanism
5376 * as for the other XSLT instructions.
5377 */
5378 xsltGetInheritedNsList(style, ret, template);
5379
5380 /*
5381 * Get arguments
5382 */
5383 prop = xmlGetNsProp(template, (const xmlChar *)"mode", NULL);
5384 if (prop != NULL) {
5385 const xmlChar *URI;
5386
5387 /*
5388 * TODO: Don't use xsltGetQNameURI().
5389 */
5390 URI = xsltGetQNameURI(template, &prop);
5391 if (prop == NULL) {
5392 if (style != NULL) style->errors++;
5393 goto error;
5394 } else {
5395 mode = prop;
5396 if (URI != NULL)
5397 modeURI = xmlStrdup(URI);
5398 }
5399 ret->mode = xmlDictLookup(style->dict, mode, -1);
5400 ret->modeURI = xmlDictLookup(style->dict, modeURI, -1);
5401#ifdef WITH_XSLT_DEBUG_PARSING
5403 "xsltParseStylesheetTemplate: mode %s\n", mode);
5404#endif
5405 if (mode != NULL) xmlFree(mode);
5406 if (modeURI != NULL) xmlFree(modeURI);
5407 }
5408 prop = xmlGetNsProp(template, (const xmlChar *)"match", NULL);
5409 if (prop != NULL) {
5410 if (ret->match != NULL) xmlFree(ret->match);
5411 ret->match = prop;
5412 }
5413
5414 prop = xmlGetNsProp(template, (const xmlChar *)"priority", NULL);
5415 if (prop != NULL) {
5417 ret->priority = (float) priority;
5418 xmlFree(prop);
5419 }
5420
5421 prop = xmlGetNsProp(template, (const xmlChar *)"name", NULL);
5422 if (prop != NULL) {
5423 const xmlChar *URI;
5424
5425 /*
5426 * TODO: Don't use xsltGetQNameURI().
5427 */
5428 URI = xsltGetQNameURI(template, &prop);
5429 if (prop == NULL) {
5430 if (style != NULL) style->errors++;
5431 goto error;
5432 } else {
5433 if (xmlValidateNCName(prop,0)) {
5434 xsltTransformError(NULL, style, template,
5435 "xsl:template : error invalid name '%s'\n", prop);
5436 if (style != NULL) style->errors++;
5437 xmlFree(prop);
5438 goto error;
5439 }
5440 ret->name = xmlDictLookup(style->dict, BAD_CAST prop, -1);
5441 xmlFree(prop);
5442 prop = NULL;
5443 if (URI != NULL)
5444 ret->nameURI = xmlDictLookup(style->dict, BAD_CAST URI, -1);
5445 else
5446 ret->nameURI = NULL;
5447 }
5448 }
5449
5450 /*
5451 * parse the content and register the pattern
5452 */
5454 ret->elem = template;
5455 ret->content = template->children;
5456 xsltAddTemplate(style, ret, ret->mode, ret->modeURI);
5457
5458error:
5459 return;
5460}
GLenum mode
Definition: glext.h:6217
static float(__cdecl *square_half_float)(float x
static int priority
Definition: timer.c:163
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
static int xsltGetInheritedNsList(xsltStylesheetPtr style, xsltTemplatePtr template, xmlNodePtr node)
Definition: xslt.c:1086
double xmlXPathStringEvalNumber(const xmlChar *str)

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetTop()

static void xsltParseStylesheetTop ( xsltStylesheetPtr  style,
xmlNodePtr  top 
)
static

xsltParseStylesheetTop: @style: the XSLT stylesheet @top: the top level "stylesheet" or "transform" element

scan the top level elements of an XSL stylesheet

Definition at line 6078 of file xslt.c.

6078 {
6080 xmlChar *prop;
6081#ifdef WITH_XSLT_DEBUG_PARSING
6082 int templates = 0;
6083#endif
6084
6085 if ((top == NULL) || (top->type != XML_ELEMENT_NODE))
6086 return;
6087
6088 prop = xmlGetNsProp(top, (const xmlChar *)"version", NULL);
6089 if (prop == NULL) {
6091 "xsl:version is missing: document may not be a stylesheet\n");
6092 if (style != NULL) style->warnings++;
6093 } else {
6094 if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
6095 (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
6097 "xsl:version: only 1.1 features are supported\n");
6098 if (style != NULL) {
6099 style->forwards_compatible = 1;
6100 style->warnings++;
6101 }
6102 }
6103 xmlFree(prop);
6104 }
6105
6106 /*
6107 * process xsl:import elements
6108 */
6109 cur = top->children;
6110 while (cur != NULL) {
6111 if (IS_BLANK_NODE(cur)) {
6112 cur = cur->next;
6113 continue;
6114 }
6115 if (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "import")) {
6117 if (style != NULL) style->errors++;
6118 } else
6119 break;
6120 cur = cur->next;
6121 }
6122
6123 /*
6124 * process other top-level elements
6125 */
6126 while (cur != NULL) {
6127 if (IS_BLANK_NODE(cur)) {
6128 cur = cur->next;
6129 continue;
6130 }
6131 if (cur->type == XML_TEXT_NODE) {
6132 if (cur->content != NULL) {
6134 "misplaced text node: '%s'\n", cur->content);
6135 }
6136 if (style != NULL) style->errors++;
6137 cur = cur->next;
6138 continue;
6139 }
6140 if ((cur->type == XML_ELEMENT_NODE) && (cur->ns == NULL)) {
6142 "Found a top-level element %s with null namespace URI\n",
6143 cur->name);
6144 if (style != NULL) style->errors++;
6145 cur = cur->next;
6146 continue;
6147 }
6148 if ((cur->type == XML_ELEMENT_NODE) && (!(IS_XSLT_ELEM(cur)))) {
6149 xsltTopLevelFunction function;
6150
6151 function = xsltExtModuleTopLevelLookup(cur->name,
6152 cur->ns->href);
6153 if (function != NULL)
6154 function(style, cur);
6155
6156#ifdef WITH_XSLT_DEBUG_PARSING
6158 "xsltParseStylesheetTop : found foreign element %s\n",
6159 cur->name);
6160#endif
6161 cur = cur->next;
6162 continue;
6163 }
6164 if (IS_XSLT_NAME(cur, "import")) {
6166 "xsltParseStylesheetTop: ignoring misplaced import element\n");
6167 if (style != NULL) style->errors++;
6168 } else if (IS_XSLT_NAME(cur, "include")) {
6170 if (style != NULL) style->errors++;
6171 } else if (IS_XSLT_NAME(cur, "strip-space")) {
6173 } else if (IS_XSLT_NAME(cur, "preserve-space")) {
6175 } else if (IS_XSLT_NAME(cur, "output")) {
6177 } else if (IS_XSLT_NAME(cur, "key")) {
6179 } else if (IS_XSLT_NAME(cur, "decimal-format")) {
6181 } else if (IS_XSLT_NAME(cur, "attribute-set")) {
6183 } else if (IS_XSLT_NAME(cur, "variable")) {
6185 } else if (IS_XSLT_NAME(cur, "param")) {
6187 } else if (IS_XSLT_NAME(cur, "template")) {
6188#ifdef WITH_XSLT_DEBUG_PARSING
6189 templates++;
6190#endif
6192 } else if (IS_XSLT_NAME(cur, "namespace-alias")) {
6194 } else {
6195 if ((style != NULL) && (style->forwards_compatible == 0)) {
6197 "xsltParseStylesheetTop: unknown %s element\n",
6198 cur->name);
6199 if (style != NULL) style->errors++;
6200 }
6201 }
6202 cur = cur->next;
6203 }
6204#ifdef WITH_XSLT_DEBUG_PARSING
6206 "parsed %d templates\n", templates);
6207#endif
6208}
xsltTopLevelFunction xsltExtModuleTopLevelLookup(const xmlChar *name, const xmlChar *URI)
Definition: extensions.c:1856
void xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: attributes.c:348
void(* xsltTopLevelFunction)(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: extensions.h:183
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
int xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: imports.c:49
int xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: imports.c:147
char templates[]
Definition: meshbuilder.c:39
void xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node)
Definition: namespaces.c:55
@ XML_TEXT_NODE
Definition: tree.h:162
void xsltParseGlobalVariable(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: variables.c:2024
void xsltParseGlobalParam(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: variables.c:2087
static void xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:1665
static void xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key)
Definition: xslt.c:5098
void xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:1181
static void xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:1526
static void xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:1399
#define IS_BLANK_NODE(n)
Definition: xslt.c:85
static void xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template)
Definition: xslt.c:5350
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:502
void * xsltGenericErrorContext
Definition: xsltutils.c:503

Referenced by xsltParseStylesheetProcess().

◆ xsltParseStylesheetUser()

int xsltParseStylesheetUser ( xsltStylesheetPtr  style,
xmlDocPtr  doc 
)

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

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

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

Definition at line 6543 of file xslt.c.

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

Referenced by xsltParseStylesheetImportedDoc().

◆ xsltParseTemplateContent()

void xsltParseTemplateContent ( xsltStylesheetPtr  style,
xmlNodePtr  templ 
)

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

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

Definition at line 4878 of file xslt.c.

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

Referenced by xsltParseGlobalParam(), xsltParseGlobalVariable(), xsltParseStylesheetAttributeSet(), xsltParseStylesheetProcess(), and xsltParseStylesheetTemplate().

◆ xsltPreprocessStylesheet()

static void xsltPreprocessStylesheet ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)
static

Definition at line 3469 of file xslt.c.

3470{
3471 xmlNodePtr deleteNode, styleelem;
3472 int internalize = 0;
3473
3474 if ((style == NULL) || (cur == NULL))
3475 return;
3476
3477 if ((cur->doc != NULL) && (style->dict != NULL) &&
3478 (cur->doc->dict == style->dict))
3479 internalize = 1;
3480 else
3481 style->internalized = 0;
3482
3483 if ((cur != NULL) && (IS_XSLT_ELEM(cur)) &&
3484 (IS_XSLT_NAME(cur, "stylesheet"))) {
3485 styleelem = cur;
3486 } else {
3487 styleelem = NULL;
3488 }
3489
3490 /*
3491 * This content comes from the stylesheet
3492 * For stylesheets, the set of whitespace-preserving
3493 * element names consists of just xsl:text.
3494 */
3495 deleteNode = NULL;
3496 while (cur != NULL) {
3497 if (deleteNode != NULL) {
3498#ifdef WITH_XSLT_DEBUG_BLANKS
3500 "xsltPreprocessStylesheet: removing ignorable blank node\n");
3501#endif
3502 xmlUnlinkNode(deleteNode);
3503 xmlFreeNode(deleteNode);
3504 deleteNode = NULL;
3505 }
3506 if (cur->type == XML_ELEMENT_NODE) {
3507 int exclPrefixes;
3508 /*
3509 * Internalize attributes values.
3510 */
3511 if ((internalize) && (cur->properties != NULL)) {
3512 xmlAttrPtr attr = cur->properties;
3513 xmlNodePtr txt;
3514
3515 while (attr != NULL) {
3516 txt = attr->children;
3517 if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
3518 (txt->content != NULL) &&
3519 (!xmlDictOwns(style->dict, txt->content)))
3520 {
3521 xmlChar *tmp;
3522
3523 /*
3524 * internalize the text string, goal is to speed
3525 * up operations and minimize used space by compiled
3526 * stylesheets.
3527 */
3528 tmp = (xmlChar *) xmlDictLookup(style->dict,
3529 txt->content, -1);
3530 if (tmp != txt->content) {
3531 xmlNodeSetContent(txt, NULL);
3532 txt->content = tmp;
3533 }
3534 }
3535 attr = attr->next;
3536 }
3537 }
3538 if (IS_XSLT_ELEM(cur)) {
3539 exclPrefixes = 0;
3540 if (IS_XSLT_NAME(cur, "text")) {
3541 for (;exclPrefixes > 0;exclPrefixes--)
3543 goto skip_children;
3544 }
3545 } else {
3546 exclPrefixes = xsltParseStylesheetExcludePrefix(style, cur, 0);
3547 }
3548
3549 if ((cur->nsDef != NULL) && (style->exclPrefixNr > 0)) {
3550 xmlNsPtr ns = cur->nsDef, prev = NULL, next;
3552 int i, moved;
3553
3555 if ((root != NULL) && (root != cur)) {
3556 while (ns != NULL) {
3557 moved = 0;
3558 next = ns->next;
3559 for (i = 0;i < style->exclPrefixNr;i++) {
3560 if ((ns->prefix != NULL) &&
3561 (xmlStrEqual(ns->href,
3562 style->exclPrefixTab[i]))) {
3563 /*
3564 * Move the namespace definition on the root
3565 * element to avoid duplicating it without
3566 * loosing it.
3567 */
3568 if (prev == NULL) {
3569 cur->nsDef = ns->next;
3570 } else {
3571 prev->next = ns->next;
3572 }
3573 ns->next = root->nsDef;
3574 root->nsDef = ns;
3575 moved = 1;
3576 break;
3577 }
3578 }
3579 if (moved == 0)
3580 prev = ns;
3581 ns = next;
3582 }
3583 }
3584 }
3585 /*
3586 * If we have prefixes locally, recurse and pop them up when
3587 * going back
3588 */
3589 if (exclPrefixes > 0) {
3591 for (;exclPrefixes > 0;exclPrefixes--)
3593 goto skip_children;
3594 }
3595 } else if (cur->type == XML_TEXT_NODE) {
3596 if (IS_BLANK_NODE(cur)) {
3597 if (xmlNodeGetSpacePreserve(cur->parent) != 1) {
3598 deleteNode = cur;
3599 }
3600 } else if ((cur->content != NULL) && (internalize) &&
3601 (!xmlDictOwns(style->dict, cur->content))) {
3602 xmlChar *tmp;
3603
3604 /*
3605 * internalize the text string, goal is to speed
3606 * up operations and minimize used space by compiled
3607 * stylesheets.
3608 */
3609 tmp = (xmlChar *) xmlDictLookup(style->dict, cur->content, -1);
3611 cur->content = tmp;
3612 }
3613 } else if ((cur->type != XML_ELEMENT_NODE) &&
3614 (cur->type != XML_CDATA_SECTION_NODE)) {
3615 deleteNode = cur;
3616 goto skip_children;
3617 }
3618
3619 /*
3620 * Skip to next node. In case of a namespaced element children of
3621 * the stylesheet and not in the XSLT namespace and not an extension
3622 * element, ignore its content.
3623 */
3624 if ((cur->type == XML_ELEMENT_NODE) && (cur->ns != NULL) &&
3625 (styleelem != NULL) && (cur->parent == styleelem) &&
3626 (!xmlStrEqual(cur->ns->href, XSLT_NAMESPACE)) &&
3627 (!xsltCheckExtURI(style, cur->ns->href))) {
3628 goto skip_children;
3629 } else if (cur->children != NULL) {
3630 cur = cur->children;
3631 continue;
3632 }
3633
3634skip_children:
3635 if (cur->next != NULL) {
3636 cur = cur->next;
3637 continue;
3638 }
3639 do {
3640
3641 cur = cur->parent;
3642 if (cur == NULL)
3643 break;
3644 if (cur == (xmlNodePtr) style->doc) {
3645 cur = NULL;
3646 break;
3647 }
3648 if (cur->next != NULL) {
3649 cur = cur->next;
3650 break;
3651 }
3652 } while (cur != NULL);
3653 }
3654 if (deleteNode != NULL) {
3655#ifdef WITH_XSLT_DEBUG_PARSING
3657 "xsltPreprocessStylesheet: removing ignorable blank node\n");
3658#endif
3659 xmlUnlinkNode(deleteNode);
3660 xmlFreeNode(deleteNode);
3661 }
3662}
int xsltCheckExtURI(xsltStylesheetPtr style, const xmlChar *URI)
Definition: extensions.c:1218
XMLPUBFUN int XMLCALL xmlNodeGetSpacePreserve(const xmlNode *cur)
xmlChar * content
Definition: tree.h:502
static xmlChar * exclPrefixPop(xsltStylesheetPtr style)
Definition: xslt.c:170

Referenced by xsltParseStylesheetProcess(), and xsltPreprocessStylesheet().

◆ xsltUninit()

void xsltUninit ( void  )

xsltUninit:

Uninitializes the processor.

Definition at line 217 of file xslt.c.

217 {
218#ifdef XSLT_LOCALE_WINAPI
219 xmlFreeRMutex(xsltLocaleMutex);
220 xsltLocaleMutex = NULL;
221#endif
222 initialized = 0;
223}
XMLPUBFUN void XMLCALL xmlFreeRMutex(xmlRMutexPtr tok)
Definition: threads.c:309

Referenced by xsltCleanupGlobals().

Variable Documentation

◆ initialized

int initialized = 0
static

Definition at line 193 of file xslt.c.

Referenced by xsltInit(), and xsltUninit().

◆ xsltEngineVersion

Definition at line 23 of file xslt.c.

◆ xsltLibxmlVersion

const int xsltLibxmlVersion = LIBXML_VERSION

Definition at line 25 of file xslt.c.

◆ xsltLibxsltVersion

const int xsltLibxsltVersion = LIBXSLT_VERSION

Definition at line 24 of file xslt.c.