ReactOS 0.4.16-dev-2208-g6350669
xslt.c File Reference
#include "libxslt.h"
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/valid.h>
#include <libxml/hash.h>
#include <libxml/uri.h>
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
#include <libxml/xpathInternals.h>
#include <libxml/xpath.h>
#include "xslt.h"
#include "xsltInternals.h"
#include "pattern.h"
#include "variables.h"
#include "namespaces.h"
#include "attributes.h"
#include "xsltutils.h"
#include "imports.h"
#include "keys.h"
#include "documents.h"
#include "extensions.h"
#include "preproc.h"
#include "extra.h"
#include "security.h"
#include "xsltlocale.h"
Include dependency graph for xslt.c:

Go to the source code of this file.

Macros

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

Functions

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 6806 of file xslt.c.

◆ IN_LIBXSLT

#define IN_LIBXSLT

Definition at line 16 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 102 of file xslt.c.

◆ IS_BLANK_NODE

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

Definition at line 108 of file xslt.c.

◆ NEXT

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

Definition at line 6811 of file xslt.c.

◆ NXT

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

Definition at line 6808 of file xslt.c.

◆ SKIP

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

Definition at line 6807 of file xslt.c.

◆ SKIP_BLANKS

#define SKIP_BLANKS    while (IS_BLANK(CUR)) NEXT

Definition at line 6809 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 185 of file xslt.c.

186{
187 xmlChar *ret;
188
189 if (style->exclPrefixNr <= 0)
190 return (0);
191 style->exclPrefixNr--;
192 if (style->exclPrefixNr > 0)
193 style->exclPrefix = style->exclPrefixTab[style->exclPrefixNr - 1];
194 else
195 style->exclPrefix = NULL;
196 ret = style->exclPrefixTab[style->exclPrefixNr];
197 style->exclPrefixTab[style->exclPrefixNr] = 0;
198 return (ret);
199}
Arabic default style
Definition: afstyles.h:94
#define NULL
Definition: types.h:112
return ret
Definition: mutex.c:146
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 150 of file xslt.c.

151{
152 int i;
153
154 /* do not push duplicates */
155 for (i = 0;i < style->exclPrefixNr;i++) {
156 if (xmlStrEqual(style->exclPrefixTab[i], value))
157 return(-1);
158 }
159 if (style->exclPrefixNr >= style->exclPrefixMax) {
160 xmlChar **tmp;
161 size_t max = style->exclPrefixMax ? style->exclPrefixMax * 2 : 4;
162
163 tmp = xmlRealloc(style->exclPrefixTab,
164 max * sizeof(style->exclPrefixTab[0]));
165 if (tmp == NULL) {
166 xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
167 return (-1);
168 }
169 style->exclPrefixTab = tmp;
170 style->exclPrefixMax = max;
171 }
172 style->exclPrefixTab[style->exclPrefixNr] = value;
173 style->exclPrefix = value;
174 return (style->exclPrefixNr++);
175}
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
void * xmlGenericErrorContext
Definition: globals.c:410
xmlReallocFunc xmlRealloc
Definition: globals.c:214
xmlGenericErrorFunc xmlGenericError
Definition: globals.c:396
#define max(a, b)
Definition: svc.c:63
Definition: pdh_main.c:96
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162

Referenced by xsltParseStylesheetExcludePrefix().

◆ 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 824 of file xslt.c.

825{
826 return(style->extrasNr++);
827}

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 840 of file xslt.c.

841{
842 if (ctxt->extrasNr >= ctxt->extrasMax) {
843 int i;
844 if (ctxt->extrasNr == 0) {
845 ctxt->extrasMax = 20;
847 xmlMalloc(ctxt->extrasMax * sizeof(xsltRuntimeExtra));
848 if (ctxt->extras == NULL) {
850 "xsltAllocateExtraCtxt: out of memory\n");
851 return(0);
852 }
853 for (i = 0;i < ctxt->extrasMax;i++) {
854 ctxt->extras[i].info = NULL;
855 ctxt->extras[i].deallocate = NULL;
856 ctxt->extras[i].val.ptr = NULL;
857 }
858
859 } else {
861
862 ctxt->extrasMax += 100;
864 ctxt->extrasMax * sizeof(xsltRuntimeExtra));
865 if (tmp == NULL) {
867 "xsltAllocateExtraCtxt: out of memory\n");
868 return(0);
869 }
870 ctxt->extras = tmp;
871 for (i = ctxt->extrasNr;i < ctxt->extrasMax;i++) {
872 ctxt->extras[i].info = NULL;
873 ctxt->extras[i].deallocate = NULL;
874 ctxt->extras[i].val.ptr = NULL;
875 }
876 }
877 }
878 return(ctxt->extrasNr++);
879}
xmlMallocFunc xmlMalloc
Definition: globals.c:193
xmlFreeFunc deallocate
union _xsltRuntimeExtra::@3691 val
xsltRuntimeExtraPtr extras
xsltRuntimeExtra * xsltRuntimeExtraPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762

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 910 of file xslt.c.

912{
913#if 0 /* TODO: Currently disabled, since probably not needed. */
914 xmlNodePtr cur;
915
916 if ((doc == NULL) || (rootElem == NULL) ||
917 (rootElem->type != XML_ELEMENT_NODE) ||
918 (doc != rootElem->doc))
919 return(-1);
920
921 /*
922 * Cleanup was suggested by Aleksey Sanin:
923 * Clear the PSVI field to avoid problems if the
924 * node-tree of the stylesheet is intended to be used for
925 * further processing by the user (e.g. for compiling it
926 * once again - although not recommended).
927 */
928
929 cur = rootElem;
930 while (cur != NULL) {
931 if (cur->type == XML_ELEMENT_NODE) {
932 /*
933 * Clear the PSVI field.
934 */
935 cur->psvi = NULL;
936 if (cur->children) {
937 cur = cur->children;
938 continue;
939 }
940 }
941
942leave_node:
943 if (cur == rootElem)
944 break;
945 if (cur->next != NULL)
946 cur = cur->next;
947 else {
948 cur = cur->parent;
949 if (cur == NULL)
950 break;
951 goto leave_node;
952 }
953 }
954#endif /* #if 0 */
955 return(0);
956}
FxCollectionEntry * cur

Referenced by xsltFreeStylesheet(), and xsltParseStylesheetUser().

◆ xsltDecimalFormatGetByName()

xsltDecimalFormatPtr xsltDecimalFormatGetByName ( xsltStylesheetPtr  style,
xmlChar name 
)

Definition at line 349 of file xslt.c.

350{
352
353 if (name == NULL)
354 return style->decimalFormat;
355
356 while (style != NULL) {
357 for (result = style->decimalFormat->next;
358 result != NULL;
359 result = result->next) {
360 if ((result->nsUri == NULL) && xmlStrEqual(name, result->name))
361 return result;
362 }
364 }
365 return result;
366}
GLuint64EXT * result
Definition: glext.h:11304
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:297
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 379 of file xslt.c.

381{
383
384 if (name == NULL)
385 return style->decimalFormat;
386
387 while (style != NULL) {
388 for (result = style->decimalFormat->next;
389 result != NULL;
390 result = result->next) {
391 if (xmlStrEqual(nsUri, result->nsUri) &&
393 return result;
394 }
396 }
397 return result;
398}

Referenced by xsltFormatNumberFunction(), and xsltParseStylesheetDecimalFormat().

◆ xsltFreeDecimalFormat()

static void xsltFreeDecimalFormat ( xsltDecimalFormatPtr  self)
static

Definition at line 293 of file xslt.c.

294{
295 if (self != NULL) {
296 if (self->digit)
297 xmlFree(self->digit);
298 if (self->patternSeparator)
300 if (self->decimalPoint)
301 xmlFree(self->decimalPoint);
302 if (self->grouping)
303 xmlFree(self->grouping);
304 if (self->percent)
305 xmlFree(self->percent);
306 if (self->permille)
307 xmlFree(self->permille);
308 if (self->zeroDigit)
309 xmlFree(self->zeroDigit);
310 if (self->minusSign)
311 xmlFree(self->minusSign);
312 if (self->infinity)
313 xmlFree(self->infinity);
314 if (self->noNumber)
315 xmlFree(self->noNumber);
316 if (self->name)
317 xmlFree(self->name);
318 xmlFree(self);
319 }
320}
xmlFreeFunc xmlFree
Definition: globals.c:184
xmlChar * decimalPoint
xmlChar * patternSeparator

Referenced by xsltFreeDecimalFormatList().

◆ xsltFreeDecimalFormatList()

static void xsltFreeDecimalFormatList ( xsltStylesheetPtr  self)
static

Definition at line 323 of file xslt.c.

324{
327
328 if (self == NULL)
329 return;
330
331 iter = self->decimalFormat;
332 while (iter != NULL) {
333 tmp = iter->next;
335 iter = tmp;
336 }
337}
struct _xsltDecimalFormat * next
xsltDecimalFormatPtr decimalFormat
static void xsltFreeDecimalFormat(xsltDecimalFormatPtr self)
Definition: xslt.c:293

Referenced by xsltFreeStylesheet().

◆ xsltFreeStylesheet()

void xsltFreeStylesheet ( xsltStylesheetPtr  style)

xsltFreeStylesheet: @style: an XSLT stylesheet

Free up the memory allocated by @style

Definition at line 965 of file xslt.c.

966{
967 if (style == NULL)
968 return;
969
970#ifdef XSLT_REFACTORED
971 /*
972 * Start with a cleanup of the main stylesheet's doc.
973 */
974 if ((style->principal == style) && (style->doc))
976 xmlDocGetRootElement(style->doc));
977#ifdef XSLT_REFACTORED_XSLT_NSCOMP
978 /*
979 * Restore changed ns-decls before freeing the document.
980 */
981 if ((style->doc != NULL) &&
982 XSLT_HAS_INTERNAL_NSMAP(style))
983 {
984 xsltRestoreDocumentNamespaces(XSLT_GET_INTERNAL_NSMAP(style),
985 style->doc);
986 }
987#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
988#else
989 /*
990 * Start with a cleanup of the main stylesheet's doc.
991 */
992 if ((style->parent == NULL) && (style->doc))
994 xmlDocGetRootElement(style->doc));
995#endif /* XSLT_REFACTORED */
996
1001 xsltFreeTemplateList(style->templates);
1005 /*
1006 * Free documents of all included stylsheet modules of this
1007 * stylesheet level.
1008 */
1010 /*
1011 * TODO: Best time to shutdown extension stuff?
1012 */
1014
1015 if (style->variables != NULL)
1016 xsltFreeStackElemList(style->variables);
1017 if (style->cdataSection != NULL)
1018 xmlHashFree(style->cdataSection, NULL);
1019 if (style->stripSpaces != NULL)
1020 xmlHashFree(style->stripSpaces, NULL);
1021 if (style->nsHash != NULL)
1022 xmlHashFree(style->nsHash, NULL);
1023 if (style->exclPrefixTab != NULL)
1024 xmlFree(style->exclPrefixTab);
1025 if (style->method != NULL)
1026 xmlFree(style->method);
1027 if (style->methodURI != NULL)
1028 xmlFree(style->methodURI);
1029 if (style->version != NULL)
1030 xmlFree(style->version);
1031 if (style->encoding != NULL)
1032 xmlFree(style->encoding);
1033 if (style->doctypePublic != NULL)
1034 xmlFree(style->doctypePublic);
1035 if (style->doctypeSystem != NULL)
1036 xmlFree(style->doctypeSystem);
1037 if (style->mediaType != NULL)
1038 xmlFree(style->mediaType);
1039 if (style->attVTs)
1040 xsltFreeAVTList(style->attVTs);
1041 if (style->imports != NULL)
1042 xsltFreeStylesheetList(style->imports);
1043
1044#ifdef XSLT_REFACTORED
1045 /*
1046 * If this is the principal stylesheet, then
1047 * free its internal data.
1048 */
1049 if (style->principal == style) {
1050 if (style->principalData) {
1051 xsltFreePrincipalStylesheetData(style->principalData);
1052 style->principalData = NULL;
1053 }
1054 }
1055#endif
1056 /*
1057 * Better to free the main document of this stylesheet level
1058 * at the end - so here.
1059 */
1060 if (style->doc != NULL) {
1061 xmlFreeDoc(style->doc);
1062 }
1063
1064#ifdef WITH_XSLT_DEBUG
1066 "freeing dictionary from stylesheet\n");
1067#endif
1068 xmlDictFree(style->dict);
1069
1070 if (style->xpathCtxt != NULL)
1071 xmlXPathFreeContext(style->xpathCtxt);
1072
1073 memset(style, -1, sizeof(xsltStylesheet));
1074 xmlFree(style);
1075}
void xsltShutdownExts(xsltStylesheetPtr style)
Definition: extensions.c:1158
void xsltFreeExts(xsltStylesheetPtr style)
Definition: extensions.c:501
void xsltFreeStylePreComps(xsltStylesheetPtr style)
Definition: preproc.c:1951
void xsltFreeAVTList(void *avt)
Definition: attrvt.c:131
void xsltFreeAttributeSetsHashes(xsltStylesheetPtr style)
Definition: attributes.c:1237
void xsltFreeTemplateHashes(xsltStylesheetPtr style)
Definition: pattern.c:2512
void xsltFreeStyleDocuments(xsltStylesheetPtr style)
Definition: documents.c:208
void xsltFreeKeys(xsltStylesheetPtr style)
Definition: keys.c:203
void xsltFreeNamespaceAliasHashes(xsltStylesheetPtr style)
Definition: namespaces.c:831
void xmlDictFree(xmlDictPtr dict)
Definition: dict.c:333
void xmlHashFree(xmlHashTablePtr hash, xmlHashDeallocator dealloc)
Definition: hash.c:229
#define memset(x, y, z)
Definition: compat.h:39
void xsltFreeStackElemList(xsltStackElemPtr elem)
Definition: variables.c:626
static void xsltFreeTemplateList(xsltTemplatePtr template)
Definition: xslt.c:460
static void xsltFreeStylesheetList(xsltStylesheetPtr style)
Definition: xslt.c:888
static void xsltFreeDecimalFormatList(xsltStylesheetPtr self)
Definition: xslt.c:323
static int xsltCleanupStylesheetTree(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr rootElem ATTRIBUTE_UNUSED)
Definition: xslt.c:910
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633

Referenced by node_transform_node_params(), 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 888 of file xslt.c.

888 {
890
891 while (style != NULL) {
892 next = style->next;
894 style = next;
895 }
896}
static unsigned __int64 next
Definition: rand_nt.c:6
void xsltFreeStylesheet(xsltStylesheetPtr style)
Definition: xslt.c:965

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 430 of file xslt.c.

430 {
431 if (template == NULL)
432 return;
433 if (template->match) xmlFree(template->match);
434/*
435* NOTE: @name and @nameURI are put into the string dict now.
436* if (template->name) xmlFree(template->name);
437* if (template->nameURI) xmlFree(template->nameURI);
438*/
439/*
440 if (template->mode) xmlFree(template->mode);
441 if (template->modeURI) xmlFree(template->modeURI);
442 */
443 if (template->inheritedNs) xmlFree(template->inheritedNs);
444
445 /* free profiling data */
446 if (template->templCalledTab) xmlFree(template->templCalledTab);
447 if (template->templCountTab) xmlFree(template->templCountTab);
448
449 memset(template, -1, sizeof(xsltTemplate));
450 xmlFree(template);
451}
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 460 of file xslt.c.

460 {
462
463 while (template != NULL) {
464 cur = template;
465 template = template->next;
467 }
468}
static void xsltFreeTemplate(xsltTemplatePtr template)
Definition: xslt.c:430

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 3682 of file xslt.c.

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

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 1101 of file xslt.c.

1104{
1105 xmlNsPtr cur;
1106 xmlNsPtr *ret = NULL, *tmp;
1107 int nbns = 0;
1108 int maxns = 0;
1109 int i;
1110
1111 if ((style == NULL) || (template == NULL) || (node == NULL) ||
1112 (template->inheritedNsNr != 0) || (template->inheritedNs != NULL))
1113 return(0);
1114 while (node != NULL) {
1115 if (node->type == XML_ELEMENT_NODE) {
1116 cur = node->nsDef;
1117 while (cur != NULL) {
1118 if (xmlStrEqual(cur->href, XSLT_NAMESPACE))
1119 goto skip_ns;
1120
1121 if ((cur->prefix != NULL) &&
1122 (xsltCheckExtPrefix(style, cur->prefix)))
1123 goto skip_ns;
1124 /*
1125 * Check if this namespace was excluded.
1126 * Note that at this point only the exclusions defined
1127 * on the topmost stylesheet element are in the exclusion-list.
1128 */
1129 for (i = 0;i < style->exclPrefixNr;i++) {
1130 if (xmlStrEqual(cur->href, style->exclPrefixTab[i]))
1131 goto skip_ns;
1132 }
1133 /*
1134 * Skip shadowed namespace bindings.
1135 */
1136 for (i = 0; i < nbns; i++) {
1137 if ((cur->prefix == ret[i]->prefix) ||
1138 (xmlStrEqual(cur->prefix, ret[i]->prefix)))
1139 break;
1140 }
1141 if (i >= nbns) {
1142 if (nbns >= maxns) {
1143 maxns = (maxns == 0) ? 10 : 2 * maxns;
1144 tmp = (xmlNsPtr *) xmlRealloc(ret,
1145 (maxns + 1) * sizeof(xmlNsPtr));
1146 if (tmp == NULL) {
1148 "xsltGetInheritedNsList : realloc failed!\n");
1149 xmlFree(ret);
1150 return(0);
1151 }
1152 ret = tmp;
1153 }
1154 ret[nbns++] = cur;
1155 ret[nbns] = NULL;
1156 }
1157skip_ns:
1158 cur = cur->next;
1159 }
1160 }
1161 node = node->parent;
1162 }
1163 if (nbns != 0) {
1164#ifdef WITH_XSLT_DEBUG_PARSING
1166 "template has %d inherited namespaces\n", nbns);
1167#endif
1168 template->inheritedNsNr = nbns;
1169 template->inheritedNs = ret;
1170 }
1171 return (nbns);
1172}
int xsltCheckExtPrefix(xsltStylesheetPtr style, const xmlChar *URI)
Definition: extensions.c:1183
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 216 of file xslt.c.

216 {
217 if (initialized == 0) {
218 initialized = 1;
219#ifdef XSLT_LOCALE_WINAPI
220 xsltLocaleMutex = xmlNewRMutex();
221#endif
223 }
224}
void xsltRegisterAllExtras(void)
Definition: extra.c:167
XMLPUBFUN xmlRMutexPtr xmlNewRMutex(void)
Definition: threads.c:248
static int initialized
Definition: xslt.c:208

Referenced by init_libxslt(), and 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 249 of file xslt.c.

249 {
250 if (str == NULL)
251 return(1);
252 while (*str != 0) {
253 if (!(IS_BLANK(*str))) return(0);
254 str++;
255 }
256 return(1);
257}
const WCHAR * str
#define IS_BLANK(c)
Definition: xslt.c:102

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 6915 of file xslt.c.

6915 {
6916 xmlNodePtr child;
6918 xmlChar *href = NULL;
6919 xmlURIPtr URI;
6920
6922
6923 if (doc == NULL)
6924 return(NULL);
6925
6926 /*
6927 * Find the text/xml stylesheet PI id any before the root
6928 */
6929 child = doc->children;
6930 while ((child != NULL) && (child->type != XML_ELEMENT_NODE)) {
6931 if ((child->type == XML_PI_NODE) &&
6932 (xmlStrEqual(child->name, BAD_CAST "xml-stylesheet"))) {
6933 href = xsltParseStylesheetPI(child->content);
6934 if (href != NULL)
6935 break;
6936 }
6937 child = child->next;
6938 }
6939
6940 /*
6941 * If found check the href to select processing
6942 */
6943 if (href != NULL) {
6944#ifdef WITH_XSLT_DEBUG_PARSING
6946 "xsltLoadStylesheetPI : found PI href=%s\n", href);
6947#endif
6948 URI = xmlParseURI((const char *) href);
6949 if (URI == NULL) {
6951 "xml-stylesheet : href %s is not valid\n", href);
6952 xmlFree(href);
6953 return(NULL);
6954 }
6955 if ((URI->fragment != NULL) && (URI->scheme == NULL) &&
6956 (URI->opaque == NULL) && (URI->authority == NULL) &&
6957 (URI->server == NULL) && (URI->user == NULL) &&
6958 (URI->path == NULL) && (URI->query == NULL)) {
6959 xmlAttrPtr ID;
6960
6961#ifdef WITH_XSLT_DEBUG_PARSING
6963 "xsltLoadStylesheetPI : Reference to ID %s\n", href);
6964#endif
6965 if (URI->fragment[0] == '#')
6966 ID = xmlGetID(doc, (const xmlChar *) &(URI->fragment[1]));
6967 else
6968 ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
6969 if (ID == NULL) {
6971 "xml-stylesheet : no ID %s found\n", URI->fragment);
6972 } else {
6973 xmlDocPtr fake;
6974 xmlNodePtr subtree, newtree;
6975 xmlNsPtr ns;
6976
6977#ifdef WITH_XSLT_DEBUG
6979 "creating new document from %s for embedded stylesheet\n",
6980 doc->URL);
6981#endif
6982 /*
6983 * move the subtree in a new document passed to
6984 * the stylesheet analyzer
6985 */
6986 subtree = ID->parent;
6987 fake = xmlNewDoc(NULL);
6988 if (fake != NULL) {
6989 /*
6990 * Should the dictionary still be shared even though
6991 * the nodes are being copied rather than moved?
6992 */
6993 fake->dict = doc->dict;
6994 xmlDictReference(doc->dict);
6995#ifdef WITH_XSLT_DEBUG
6997 "reusing dictionary from %s for embedded stylesheet\n",
6998 doc->URL);
6999#endif
7000
7001 newtree = xmlDocCopyNode(subtree, fake, 1);
7002
7003 fake->URL = xmlNodeGetBase(doc, subtree->parent);
7004#ifdef WITH_XSLT_DEBUG
7006 "set base URI for embedded stylesheet as %s\n",
7007 fake->URL);
7008#endif
7009
7010 /*
7011 * Add all namespaces in scope of embedded stylesheet to
7012 * root element of newly created stylesheet document
7013 */
7014 while ((subtree = subtree->parent) != (xmlNodePtr)doc) {
7015 for (ns = subtree->ns; ns; ns = ns->next) {
7016 xmlNewNs(newtree, ns->href, ns->prefix);
7017 }
7018 }
7019
7020 xmlAddChild((xmlNodePtr)fake, newtree);
7022 if (ret == NULL)
7023 xmlFreeDoc(fake);
7024 }
7025 }
7026 } else {
7027 xmlChar *URL, *base;
7028
7029 /*
7030 * Reference to an external stylesheet
7031 */
7032
7033 base = xmlNodeGetBase(doc, (xmlNodePtr) doc);
7034 URL = xmlBuildURI(href, base);
7035 if (URL != NULL) {
7036#ifdef WITH_XSLT_DEBUG_PARSING
7038 "xsltLoadStylesheetPI : fetching %s\n", URL);
7039#endif
7041 xmlFree(URL);
7042 } else {
7043#ifdef WITH_XSLT_DEBUG_PARSING
7045 "xsltLoadStylesheetPI : fetching %s\n", href);
7046#endif
7048 }
7049 if (base != NULL)
7050 xmlFree(base);
7051 }
7052 xmlFreeURI(URI);
7053 xmlFree(href);
7054 }
7055 return(ret);
7056}
void xsltInitGlobals(void)
Definition: extensions.c:2282
static HWND child
Definition: cursoricon.c:298
#define ID
Definition: ruserpass.c:36
int xmlDictReference(xmlDictPtr dict)
Definition: dict.c:317
Definition: uri.h:34
char * authority
Definition: uri.h:37
char * server
Definition: uri.h:38
char * opaque
Definition: uri.h:36
char * user
Definition: uri.h:39
char * path
Definition: uri.h:41
char * scheme
Definition: uri.h:35
char * query
Definition: uri.h:42
char * fragment
Definition: uri.h:43
XMLPUBFUN xmlChar * xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1902
XMLPUBFUN void xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1396
XMLPUBFUN xmlURIPtr xmlParseURI(const char *str)
Definition: uri.c:947
XMLPUBFUN xmlAttrPtr xmlGetID(xmlDocPtr doc, const xmlChar *ID)
Definition: valid.c:2719
#define BAD_CAST
Definition: xmlstring.h:35
xsltStylesheetPtr xsltParseStylesheetFile(const xmlChar *filename)
Definition: xslt.c:6752
xsltStylesheetPtr xsltParseStylesheetDoc(xmlDocPtr doc)
Definition: xslt.c:6736
static xmlChar * xsltParseStylesheetPI(const xmlChar *value)
Definition: xslt.c:6824

◆ xsltNewDecimalFormat()

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

Definition at line 265 of file xslt.c.

266{
268 /* UTF-8 for 0x2030 */
269 static const xmlChar permille[4] = {0xe2, 0x80, 0xb0, 0};
270
271 self = xmlMalloc(sizeof(xsltDecimalFormat));
272 if (self != NULL) {
273 self->next = NULL;
274 self->nsUri = nsUri;
275 self->name = name;
276
277 /* Default values */
278 self->digit = xmlStrdup(BAD_CAST("#"));
279 self->patternSeparator = xmlStrdup(BAD_CAST(";"));
280 self->decimalPoint = xmlStrdup(BAD_CAST("."));
281 self->grouping = xmlStrdup(BAD_CAST(","));
282 self->percent = xmlStrdup(BAD_CAST("%"));
283 self->permille = xmlStrdup(BAD_CAST(permille));
284 self->zeroDigit = xmlStrdup(BAD_CAST("0"));
285 self->minusSign = xmlStrdup(BAD_CAST("-"));
286 self->infinity = xmlStrdup(BAD_CAST("Infinity"));
287 self->noNumber = xmlStrdup(BAD_CAST("NaN"));
288 }
289 return self;
290}
const xmlChar * nsUri
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69

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 810 of file xslt.c.

810 {
812}
static xsltStylesheetPtr xsltNewStylesheetInternal(xsltStylesheetPtr parent)
Definition: xslt.c:745

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 745 of file xslt.c.

745 {
747
749 if (ret == NULL) {
751 "xsltNewStylesheet : malloc failed\n");
752 goto internal_err;
753 }
754 memset(ret, 0, sizeof(xsltStylesheet));
755
756 ret->parent = parent;
757 ret->omitXmlDeclaration = -1;
758 ret->standalone = -1;
759 ret->decimalFormat = xsltNewDecimalFormat(NULL, NULL);
760 ret->indent = -1;
761 ret->errors = 0;
762 ret->warnings = 0;
763 ret->exclPrefixNr = 0;
764 ret->exclPrefixMax = 0;
765 ret->exclPrefixTab = NULL;
766 ret->extInfos = NULL;
767 ret->extrasNr = 0;
768 ret->internalized = 1;
769 ret->literal_result = 0;
770 ret->forwards_compatible = 0;
771 ret->dict = xmlDictCreate();
772#ifdef WITH_XSLT_DEBUG
774 "creating dictionary for stylesheet\n");
775#endif
776
777 if (parent == NULL) {
778 ret->principal = ret;
779
780 ret->xpathCtxt = xmlXPathNewContext(NULL);
781 if (ret->xpathCtxt == NULL) {
783 "xsltNewStylesheet: xmlXPathNewContext failed\n");
784 goto internal_err;
785 }
786 if (xmlXPathContextSetCache(ret->xpathCtxt, 1, -1, 0) == -1)
787 goto internal_err;
788 } else {
789 ret->principal = parent->principal;
790 }
791
792 xsltInit();
793
794 return(ret);
795
796internal_err:
797 if (ret != NULL)
799 return(NULL);
800}
r parent
Definition: btrfs.c:3010
xmlDictPtr xmlDictCreate(void)
Definition: dict.c:262
xsltStylesheet * xsltStylesheetPtr
void xsltInit(void)
Definition: xslt.c:216
static xsltDecimalFormatPtr xsltNewDecimalFormat(const xmlChar *nsUri, xmlChar *name)
Definition: xslt.c:265

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 409 of file xslt.c.

409 {
411
413 if (cur == NULL) {
415 "xsltNewTemplate : malloc failed\n");
416 return(NULL);
417 }
418 memset(cur, 0, sizeof(xsltTemplate));
419 cur->priority = XSLT_PAT_NO_PRIORITY;
420 return(cur);
421}
#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 120 of file xslt.c.

122{
123 if ((style == NULL) || (node == NULL))
124 return;
125
126 if (IS_XSLT_ELEM(node))
128 "The XSLT-element '%s' is not allowed at this position.\n",
129 node->name);
130 else
132 "The element '%s' is not allowed at this position.\n",
133 node->name);
134 style->errors++;
135}
#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 1405 of file xslt.c.

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

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetDoc()

xsltStylesheetPtr xsltParseStylesheetDoc ( xmlDocPtr  doc)

xsltParseStylesheetDoc: @doc: an 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 6736 of file xslt.c.

6736 {
6738
6740}
xsltStylesheetPtr xsltParseStylesheetImportedDoc(xmlDocPtr doc, xsltStylesheetPtr parentStyle)
Definition: xslt.c:6555

Referenced by node_transform_node_params(), 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 1743 of file xslt.c.

1745{
1746 int nb = 0;
1748 xmlChar *prefix, *end;
1749
1750 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
1751 return(0);
1752
1753 if (isXsltElem)
1754 prefixes = xmlGetNsProp(cur,
1755 (const xmlChar *)"exclude-result-prefixes", NULL);
1756 else
1757 prefixes = xmlGetNsProp(cur,
1758 (const xmlChar *)"exclude-result-prefixes", XSLT_NAMESPACE);
1759
1760 if (prefixes == NULL) {
1761 return(0);
1762 }
1763
1764 prefix = prefixes;
1765 while (*prefix != 0) {
1766 while (IS_BLANK(*prefix)) prefix++;
1767 if (*prefix == 0)
1768 break;
1769 end = prefix;
1770 while ((*end != 0) && (!IS_BLANK(*end))) end++;
1772 if (prefix) {
1773 xmlNsPtr ns;
1774
1775 if (xmlStrEqual(prefix, (const xmlChar *)"#default"))
1776 ns = xmlSearchNs(style->doc, cur, NULL);
1777 else
1778 ns = xmlSearchNs(style->doc, cur, prefix);
1779 if (ns == NULL) {
1781 "xsl:exclude-result-prefixes : undefined namespace %s\n",
1782 prefix);
1783 if (style != NULL) style->warnings++;
1784 } else {
1785 if (exclPrefixPush(style, (xmlChar *) ns->href) >= 0) {
1786#ifdef WITH_XSLT_DEBUG_PARSING
1788 "exclude result prefix %s\n", prefix);
1789#endif
1790 nb++;
1791 }
1792 }
1793 xmlFree(prefix);
1794 }
1795 prefix = end;
1796 }
1798 return(nb);
1799}
GLuint GLuint end
Definition: gl.h:1545
static int prefixes
Definition: i386-dis.c:276
Character const *const prefix
Definition: tempnam.cpp:195
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:45
static int exclPrefixPush(xsltStylesheetPtr style, xmlChar *value)
Definition: xslt.c:150

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 1607 of file xslt.c.

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

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 6752 of file xslt.c.

6752 {
6755 xmlDocPtr doc;
6756
6758
6759 if (filename == NULL)
6760 return(NULL);
6761
6762#ifdef WITH_XSLT_DEBUG_PARSING
6764 "xsltParseStylesheetFile : parse %s\n", filename);
6765#endif
6766
6767 /*
6768 * Security framework check
6769 */
6771 if (sec != NULL) {
6772 int res;
6773
6774 res = xsltCheckRead(sec, NULL, filename);
6775 if (res <= 0) {
6776 if (res == 0)
6778 "xsltParseStylesheetFile: read rights for %s denied\n",
6779 filename);
6780 return(NULL);
6781 }
6782 }
6783
6786 if (doc == NULL) {
6788 "xsltParseStylesheetFile : cannot parse %s\n", filename);
6789 return(NULL);
6790 }
6792 if (ret == NULL) {
6793 xmlFreeDoc(doc);
6794 return(NULL);
6795 }
6796
6797 return(ret);
6798}
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:180
int xsltCheckRead(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:419
xsltDocLoaderFunc xsltDocDefaultLoader
Definition: documents.c:108
@ 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 6555 of file xslt.c.

6556 {
6557 xsltStylesheetPtr retStyle;
6558
6559 if (doc == NULL)
6560 return(NULL);
6561
6562 retStyle = xsltNewStylesheetInternal(parentStyle);
6563 if (retStyle == NULL)
6564 return(NULL);
6565
6566 if (xsltParseStylesheetUser(retStyle, doc) != 0) {
6567 xsltFreeStylesheet(retStyle);
6568 return(NULL);
6569 }
6570
6571 return(retStyle);
6572}
int xsltParseStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc)
Definition: xslt.c:6584

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 5120 of file xslt.c.

5120 {
5121 xmlChar *prop = NULL;
5122 xmlChar *use = NULL;
5123 xmlChar *match = NULL;
5124 xmlChar *name = NULL;
5125 xmlChar *nameURI = NULL;
5126
5127 if ((style == NULL) || (key == NULL) || (key->type != XML_ELEMENT_NODE))
5128 return;
5129
5130 /*
5131 * Get arguments
5132 */
5133 prop = xmlGetNsProp(key, (const xmlChar *)"name", NULL);
5134 if (prop != NULL) {
5135 const xmlChar *URI;
5136
5137 /*
5138 * TODO: Don't use xsltGetQNameURI().
5139 */
5140 URI = xsltGetQNameURI(key, &prop);
5141 if (prop == NULL) {
5142 if (style != NULL) style->errors++;
5143 goto error;
5144 } else {
5145 name = prop;
5146 if (URI != NULL)
5147 nameURI = xmlStrdup(URI);
5148 }
5149#ifdef WITH_XSLT_DEBUG_PARSING
5151 "xsltParseStylesheetKey: name %s\n", name);
5152#endif
5153 } else {
5155 "xsl:key : error missing name\n");
5156 if (style != NULL) style->errors++;
5157 goto error;
5158 }
5159
5160 match = xmlGetNsProp(key, (const xmlChar *)"match", NULL);
5161 if (match == NULL) {
5163 "xsl:key : error missing match\n");
5164 if (style != NULL) style->errors++;
5165 goto error;
5166 }
5167
5168 use = xmlGetNsProp(key, (const xmlChar *)"use", NULL);
5169 if (use == NULL) {
5171 "xsl:key : error missing use\n");
5172 if (style != NULL) style->errors++;
5173 goto error;
5174 }
5175
5176 /*
5177 * register the keys
5178 */
5179 xsltAddKey(style, name, nameURI, match, use, key);
5180
5181
5182error:
5183 if (use != NULL)
5184 xmlFree(use);
5185 if (match != NULL)
5186 xmlFree(match);
5187 if (name != NULL)
5188 xmlFree(name);
5189 if (nameURI != NULL)
5190 xmlFree(nameURI);
5191
5192 if (key->children != NULL) {
5193 xsltParseContentError(style, key->children);
5194 }
5195}
int xsltAddKey(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *nameURI, const xmlChar *match, const xmlChar *use, xmlNodePtr inst)
Definition: keys.c:281
#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 1185 of file xslt.c.

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

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 6824 of file xslt.c.

6824 {
6825 const xmlChar *cur;
6826 const xmlChar *start;
6827 xmlChar *val;
6828 xmlChar tmp;
6829 xmlChar *href = NULL;
6830 int isXml = 0;
6831
6832 if (value == NULL)
6833 return(NULL);
6834
6835 cur = value;
6836 while (CUR != 0) {
6838 if ((CUR == 't') && (NXT(1) == 'y') && (NXT(2) == 'p') &&
6839 (NXT(3) == 'e')) {
6840 SKIP(4);
6842 if (CUR != '=')
6843 continue;
6844 NEXT;
6845 if ((CUR != '\'') && (CUR != '"'))
6846 continue;
6847 tmp = CUR;
6848 NEXT;
6849 start = cur;
6850 while ((CUR != 0) && (CUR != tmp))
6851 NEXT;
6852 if (CUR != tmp)
6853 continue;
6855 NEXT;
6856 if (val == NULL)
6857 return(NULL);
6858 if ((xmlStrcasecmp(val, BAD_CAST "text/xml")) &&
6859 (xmlStrcasecmp(val, BAD_CAST "text/xsl")) &&
6860 (xmlStrcasecmp(val, BAD_CAST "application/xslt+xml"))) {
6861 xmlFree(val);
6862 break;
6863 }
6864 isXml = 1;
6865 xmlFree(val);
6866 } else if ((CUR == 'h') && (NXT(1) == 'r') && (NXT(2) == 'e') &&
6867 (NXT(3) == 'f')) {
6868 SKIP(4);
6870 if (CUR != '=')
6871 continue;
6872 NEXT;
6873 if ((CUR != '\'') && (CUR != '"'))
6874 continue;
6875 tmp = CUR;
6876 NEXT;
6877 start = cur;
6878 while ((CUR != 0) && (CUR != tmp))
6879 NEXT;
6880 if (CUR != tmp)
6881 continue;
6882 if (href == NULL)
6883 href = xmlStrndup(start, cur - start);
6884 NEXT;
6885 } else {
6886 while ((CUR != 0) && (!IS_BLANK(CUR)))
6887 NEXT;
6888 }
6889
6890 }
6891
6892 if (!isXml) {
6893 if (href != NULL)
6894 xmlFree(href);
6895 href = NULL;
6896 }
6897 return(href);
6898}
GLuint start
Definition: gl.h:1545
GLuint GLfloat * val
Definition: glext.h:7180
XMLPUBFUN int xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:277
#define NEXT
Definition: xslt.c:6811
#define SKIP_BLANKS
Definition: xslt.c:6809
#define SKIP(val)
Definition: xslt.c:6807
#define NXT(val)
Definition: xslt.c:6808
#define CUR
Definition: xslt.c:6806

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 1532 of file xslt.c.

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

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 6447 of file xslt.c.

6447 {
6448 xmlNodePtr cur;
6449
6451
6452 if (doc == NULL)
6453 return(NULL);
6454 if (ret == NULL)
6455 return(ret);
6456
6457 /*
6458 * First steps, remove blank nodes,
6459 * locate the xsl:stylesheet element and the
6460 * namespace declaration.
6461 */
6462 cur = xmlDocGetRootElement(doc);
6463 if (cur == NULL) {
6464 xsltTransformError(NULL, ret, (xmlNodePtr) doc,
6465 "xsltParseStylesheetProcess : empty stylesheet\n");
6466 return(NULL);
6467 }
6468
6469 if ((IS_XSLT_ELEM(cur)) &&
6470 ((IS_XSLT_NAME(cur, "stylesheet")) ||
6471 (IS_XSLT_NAME(cur, "transform")))) {
6472#ifdef WITH_XSLT_DEBUG_PARSING
6474 "xsltParseStylesheetProcess : found stylesheet\n");
6475#endif
6476 ret->literal_result = 0;
6479 } else {
6482 ret->literal_result = 1;
6483 }
6484 if (!ret->nopreproc) {
6486 }
6487 if (ret->literal_result == 0) {
6489 } else {
6490 xmlChar *prop;
6491 xsltTemplatePtr template;
6492
6493 /*
6494 * the document itself might be the template, check xsl:version
6495 */
6496 prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
6497 if (prop == NULL) {
6499 "xsltParseStylesheetProcess : document is not a stylesheet\n");
6500 return(NULL);
6501 }
6502
6503#ifdef WITH_XSLT_DEBUG_PARSING
6505 "xsltParseStylesheetProcess : document is stylesheet\n");
6506#endif
6507
6508 if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
6509 (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
6511 "xsl:version: only 1.1 features are supported\n");
6512 ret->forwards_compatible = 1;
6513 ret->warnings++;
6514 }
6515 xmlFree(prop);
6516
6517 /*
6518 * Create and link the template
6519 */
6520 template = xsltNewTemplate();
6521 if (template == NULL) {
6522 return(NULL);
6523 }
6524 template->next = ret->templates;
6525 ret->templates = template;
6526 template->match = xmlStrdup((const xmlChar *)"/");
6527
6528 /*
6529 * parse the content and register the pattern
6530 */
6531 xsltParseTemplateContent(ret, (xmlNodePtr) doc);
6532 template->elem = (xmlNodePtr) doc;
6533 template->content = doc->children;
6534 xsltAddTemplate(ret, template, NULL, NULL);
6535 ret->literal_result = 1;
6536 }
6537
6538 return(ret);
6539}
int xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, const xmlChar *mode, const xmlChar *modeURI)
Definition: pattern.c:2030
static void xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top)
Definition: xslt.c:6106
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4894
static void xsltPreprocessStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:3477
static int xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1743
static void xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur, int isXsltElem)
Definition: xslt.c:1607
static xsltTemplatePtr xsltNewTemplate(void)
Definition: xslt.c:409
#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 1673 of file xslt.c.

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

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 5372 of file xslt.c.

5372 {
5374 xmlChar *prop;
5375 xmlChar *mode = NULL;
5376 xmlChar *modeURI = NULL;
5377 double priority;
5378
5379 if ((style == NULL) || (template == NULL) ||
5380 (template->type != XML_ELEMENT_NODE))
5381 return;
5382
5383 if (style->principal->opLimit > 0) {
5384 if (style->principal->opCount > style->principal->opLimit) {
5386 "XSLT parser operation limit exceeded\n");
5387 style->errors++;
5388 return;
5389 }
5390 }
5391
5392 /*
5393 * Create and link the structure
5394 */
5395 ret = xsltNewTemplate();
5396 if (ret == NULL)
5397 return;
5398 ret->next = style->templates;
5399 style->templates = ret;
5400 ret->style = style;
5401
5402 /*
5403 * Get inherited namespaces
5404 */
5405 /*
5406 * TODO: Apply the optimized in-scope-namespace mechanism
5407 * as for the other XSLT instructions.
5408 */
5409 xsltGetInheritedNsList(style, ret, template);
5410
5411 /*
5412 * Get arguments
5413 */
5414 prop = xmlGetNsProp(template, (const xmlChar *)"mode", NULL);
5415 if (prop != NULL) {
5416 const xmlChar *URI;
5417
5418 /*
5419 * TODO: Don't use xsltGetQNameURI().
5420 */
5421 URI = xsltGetQNameURI(template, &prop);
5422 if (prop == NULL) {
5423 if (style != NULL) style->errors++;
5424 goto error;
5425 } else {
5426 mode = prop;
5427 if (URI != NULL)
5428 modeURI = xmlStrdup(URI);
5429 }
5430 ret->mode = xmlDictLookup(style->dict, mode, -1);
5431 ret->modeURI = xmlDictLookup(style->dict, modeURI, -1);
5432#ifdef WITH_XSLT_DEBUG_PARSING
5434 "xsltParseStylesheetTemplate: mode %s\n", mode);
5435#endif
5436 if (mode != NULL) xmlFree(mode);
5437 if (modeURI != NULL) xmlFree(modeURI);
5438 }
5439 prop = xmlGetNsProp(template, (const xmlChar *)"match", NULL);
5440 if (prop != NULL) {
5441 if (ret->match != NULL) xmlFree(ret->match);
5442 ret->match = prop;
5443 }
5444
5445 prop = xmlGetNsProp(template, (const xmlChar *)"priority", NULL);
5446 if (prop != NULL) {
5447 priority = xmlXPathStringEvalNumber(prop);
5448 ret->priority = (float) priority;
5449 xmlFree(prop);
5450 }
5451
5452 prop = xmlGetNsProp(template, (const xmlChar *)"name", NULL);
5453 if (prop != NULL) {
5454 const xmlChar *URI;
5455
5456 /*
5457 * TODO: Don't use xsltGetQNameURI().
5458 */
5459 URI = xsltGetQNameURI(template, &prop);
5460 if (prop == NULL) {
5461 if (style != NULL) style->errors++;
5462 goto error;
5463 } else {
5464 if (xmlValidateNCName(prop,0)) {
5465 xsltTransformError(NULL, style, template,
5466 "xsl:template : error invalid name '%s'\n", prop);
5467 if (style != NULL) style->errors++;
5468 xmlFree(prop);
5469 goto error;
5470 }
5471 ret->name = xmlDictLookup(style->dict, BAD_CAST prop, -1);
5472 xmlFree(prop);
5473 prop = NULL;
5474 if (URI != NULL)
5475 ret->nameURI = xmlDictLookup(style->dict, BAD_CAST URI, -1);
5476 else
5477 ret->nameURI = NULL;
5478 }
5479 }
5480
5481 /*
5482 * parse the content and register the pattern
5483 */
5485 ret->elem = template;
5486 ret->content = template->children;
5487 xsltAddTemplate(style, ret, ret->mode, ret->modeURI);
5488
5489error:
5490 return;
5491}
GLenum mode
Definition: glext.h:6217
static float(__cdecl *square_half_float)(float x
static int priority
Definition: timer.c:163
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
static int xsltGetInheritedNsList(xsltStylesheetPtr style, xsltTemplatePtr template, xmlNodePtr node)
Definition: xslt.c:1101

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 6106 of file xslt.c.

6106 {
6107 xmlNodePtr cur;
6108 xmlChar *prop;
6109#ifdef WITH_XSLT_DEBUG_PARSING
6110 int templates = 0;
6111#endif
6112
6113 if ((top == NULL) || (top->type != XML_ELEMENT_NODE))
6114 return;
6115
6116 if (style->principal->opLimit > 0) {
6117 if (style->principal->opCount > style->principal->opLimit) {
6119 "XSLT parser operation limit exceeded\n");
6120 style->errors++;
6121 return;
6122 }
6123 }
6124
6125 prop = xmlGetNsProp(top, (const xmlChar *)"version", NULL);
6126 if (prop == NULL) {
6128 "xsl:version is missing: document may not be a stylesheet\n");
6129 if (style != NULL) style->warnings++;
6130 } else {
6131 if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
6132 (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
6134 "xsl:version: only 1.1 features are supported\n");
6135 if (style != NULL) {
6136 style->forwards_compatible = 1;
6137 style->warnings++;
6138 }
6139 }
6140 xmlFree(prop);
6141 }
6142
6143 /*
6144 * process xsl:import elements
6145 */
6146 cur = top->children;
6147 while (cur != NULL) {
6148 style->principal->opCount += 1;
6149
6150 if (IS_BLANK_NODE(cur)) {
6151 cur = cur->next;
6152 continue;
6153 }
6154 if (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "import")) {
6156 if (style != NULL) style->errors++;
6157 } else
6158 break;
6159 cur = cur->next;
6160 }
6161
6162 /*
6163 * process other top-level elements
6164 */
6165 while (cur != NULL) {
6166 style->principal->opCount += 1;
6167
6168 if (IS_BLANK_NODE(cur)) {
6169 cur = cur->next;
6170 continue;
6171 }
6172 if (cur->type == XML_TEXT_NODE) {
6173 if (cur->content != NULL) {
6175 "misplaced text node: '%s'\n", cur->content);
6176 }
6177 if (style != NULL) style->errors++;
6178 cur = cur->next;
6179 continue;
6180 }
6181 if ((cur->type == XML_ELEMENT_NODE) && (cur->ns == NULL)) {
6183 "Found a top-level element %s with null namespace URI\n",
6184 cur->name);
6185 if (style != NULL) style->errors++;
6186 cur = cur->next;
6187 continue;
6188 }
6189 if ((cur->type == XML_ELEMENT_NODE) && (!(IS_XSLT_ELEM(cur)))) {
6190 xsltTopLevelFunction function;
6191
6192 function = xsltExtModuleTopLevelLookup(cur->name,
6193 cur->ns->href);
6194 if (function != NULL)
6195 function(style, cur);
6196
6197#ifdef WITH_XSLT_DEBUG_PARSING
6199 "xsltParseStylesheetTop : found foreign element %s\n",
6200 cur->name);
6201#endif
6202 cur = cur->next;
6203 continue;
6204 }
6205 if (IS_XSLT_NAME(cur, "import")) {
6207 "xsltParseStylesheetTop: ignoring misplaced import element\n");
6208 if (style != NULL) style->errors++;
6209 } else if (IS_XSLT_NAME(cur, "include")) {
6211 if (style != NULL) style->errors++;
6212 } else if (IS_XSLT_NAME(cur, "strip-space")) {
6214 } else if (IS_XSLT_NAME(cur, "preserve-space")) {
6216 } else if (IS_XSLT_NAME(cur, "output")) {
6218 } else if (IS_XSLT_NAME(cur, "key")) {
6220 } else if (IS_XSLT_NAME(cur, "decimal-format")) {
6222 } else if (IS_XSLT_NAME(cur, "attribute-set")) {
6224 } else if (IS_XSLT_NAME(cur, "variable")) {
6226 } else if (IS_XSLT_NAME(cur, "param")) {
6228 } else if (IS_XSLT_NAME(cur, "template")) {
6229#ifdef WITH_XSLT_DEBUG_PARSING
6230 templates++;
6231#endif
6233 } else if (IS_XSLT_NAME(cur, "namespace-alias")) {
6235 } else {
6236 if ((style != NULL) && (style->forwards_compatible == 0)) {
6238 "xsltParseStylesheetTop: unknown %s element\n",
6239 cur->name);
6240 if (style != NULL) style->errors++;
6241 }
6242 }
6243 cur = cur->next;
6244 }
6245#ifdef WITH_XSLT_DEBUG_PARSING
6247 "parsed %d templates\n", templates);
6248#endif
6249}
xsltTopLevelFunction xsltExtModuleTopLevelLookup(const xmlChar *name, const xmlChar *URI)
Definition: extensions.c:1881
void xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: attributes.c:368
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:116
int xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: imports.c:205
char templates[]
Definition: meshbuilder.c:39
void xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node)
Definition: namespaces.c:75
void xsltParseGlobalVariable(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: variables.c:2051
void xsltParseGlobalParam(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: variables.c:2114
static void xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:1673
static void xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key)
Definition: xslt.c:5120
void xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:1185
static void xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:1532
static void xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
Definition: xslt.c:1405
#define IS_BLANK_NODE(n)
Definition: xslt.c:108
static void xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template)
Definition: xslt.c:5372
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:586
void * xsltGenericErrorContext
Definition: xsltutils.c:587

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 6584 of file xslt.c.

6584 {
6585 if ((style == NULL) || (doc == NULL))
6586 return(-1);
6587
6588 /*
6589 * Adjust the string dict.
6590 */
6591 if (doc->dict != NULL) {
6592 xmlDictFree(style->dict);
6593 style->dict = doc->dict;
6594#ifdef WITH_XSLT_DEBUG
6596 "reusing dictionary from %s for stylesheet\n",
6597 doc->URL);
6598#endif
6599 xmlDictReference(style->dict);
6600 }
6601
6602 /*
6603 * TODO: Eliminate xsltGatherNamespaces(); we must not restrict
6604 * the stylesheet to containt distinct namespace prefixes.
6605 */
6607
6608#ifdef XSLT_REFACTORED
6609 {
6610 xsltCompilerCtxtPtr cctxt;
6611 xsltStylesheetPtr oldCurSheet;
6612
6613 if (style->parent == NULL) {
6614 xsltPrincipalStylesheetDataPtr principalData;
6615 /*
6616 * Create extra data for the principal stylesheet.
6617 */
6618 principalData = xsltNewPrincipalStylesheetData();
6619 if (principalData == NULL) {
6620 return(-1);
6621 }
6622 style->principalData = principalData;
6623 /*
6624 * Create the compilation context
6625 * ------------------------------
6626 * (only once; for the principal stylesheet).
6627 * This is currently the only function where the
6628 * compilation context is created.
6629 */
6630 cctxt = xsltCompilationCtxtCreate(style);
6631 if (cctxt == NULL) {
6632 return(-1);
6633 }
6634 style->compCtxt = (void *) cctxt;
6635 cctxt->style = style;
6636 cctxt->dict = style->dict;
6637 cctxt->psData = principalData;
6638 /*
6639 * Push initial dummy node info.
6640 */
6641 cctxt->depth = -1;
6642 xsltCompilerNodePush(cctxt, (xmlNodePtr) doc);
6643 } else {
6644 /*
6645 * Imported stylesheet.
6646 */
6647 cctxt = style->parent->compCtxt;
6648 style->compCtxt = cctxt;
6649 }
6650 /*
6651 * Save the old and set the current stylesheet structure in the
6652 * compilation context.
6653 */
6654 oldCurSheet = cctxt->style;
6655 cctxt->style = style;
6656
6657 style->doc = doc;
6659
6660 cctxt->style = oldCurSheet;
6661 if (style->parent == NULL) {
6662 /*
6663 * Pop the initial dummy node info.
6664 */
6665 xsltCompilerNodePop(cctxt, (xmlNodePtr) doc);
6666 } else {
6667 /*
6668 * Clear the compilation context of imported
6669 * stylesheets.
6670 * TODO: really?
6671 */
6672 /* style->compCtxt = NULL; */
6673 }
6674
6675#ifdef XSLT_REFACTORED_XSLT_NSCOMP
6676 if (style->errors != 0) {
6677 /*
6678 * Restore all changes made to namespace URIs of ns-decls.
6679 */
6680 if (cctxt->psData->nsMap)
6681 xsltRestoreDocumentNamespaces(cctxt->psData->nsMap, doc);
6682 }
6683#endif
6684
6685 if (style->parent == NULL) {
6686 xsltCompilationCtxtFree(style->compCtxt);
6687 style->compCtxt = NULL;
6688 }
6689 }
6690
6691#else /* XSLT_REFACTORED */
6692 /*
6693 * Old behaviour.
6694 */
6695 style->doc = doc;
6696 if (xsltParseStylesheetProcess(style, doc) == NULL) {
6697 style->doc = NULL;
6698 return(-1);
6699 }
6700#endif /* else of XSLT_REFACTORED */
6701
6702 if (style->parent == NULL)
6704
6705 if (style->errors != 0) {
6706 /*
6707 * Detach the doc from the stylesheet; otherwise the doc
6708 * will be freed in xsltFreeStylesheet().
6709 */
6710 style->doc = NULL;
6711 /*
6712 * Cleanup the doc if its the main stylesheet.
6713 */
6714 if (style->parent == NULL)
6715 xsltCleanupStylesheetTree(doc, xmlDocGetRootElement(doc));
6716 return(-1);
6717 }
6718
6719 return(0);
6720}
void xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style)
Definition: attributes.c:701
xsltStylesheetPtr xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc)
Definition: xslt.c:6447
static void xsltGatherNamespaces(xsltStylesheetPtr style)
Definition: xslt.c:3682

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 4894 of file xslt.c.

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

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

◆ xsltPreprocessStylesheet()

static void xsltPreprocessStylesheet ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)
static

Definition at line 3477 of file xslt.c.

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

Referenced by xsltParseStylesheetProcess(), and xsltPreprocessStylesheet().

◆ xsltUninit()

void xsltUninit ( void  )

xsltUninit:

Uninitializes the processor.

Definition at line 232 of file xslt.c.

232 {
233#ifdef XSLT_LOCALE_WINAPI
234 xmlFreeRMutex(xsltLocaleMutex);
235 xsltLocaleMutex = NULL;
236#endif
237 initialized = 0;
238}
XMLPUBFUN void xmlFreeRMutex(xmlRMutexPtr tok)
Definition: threads.c:275

Referenced by xsltCleanupGlobals().

Variable Documentation

◆ initialized

int initialized = 0
static

Definition at line 208 of file xslt.c.

Referenced by xsltInit(), and xsltUninit().

◆ xsltEngineVersion

Definition at line 52 of file xslt.c.

◆ xsltLibxmlVersion

const int xsltLibxmlVersion = LIBXML_VERSION

Definition at line 54 of file xslt.c.

◆ xsltLibxsltVersion

const int xsltLibxsltVersion = LIBXSLT_VERSION

Definition at line 53 of file xslt.c.