ReactOS 0.4.16-dev-2208-g6350669
xsltutils.c File Reference
#include "libxslt.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/HTMLtree.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlIO.h>
#include "xsltutils.h"
#include "templates.h"
#include "xsltInternals.h"
#include "imports.h"
#include "transform.h"
Include dependency graph for xsltutils.c:

Go to the source code of this file.

Macros

#define IN_LIBXSLT
 

Functions

: the full QName

xsltSplitQName: @dict: a dictionary

@prefix: the return value

Split QNames into prefix and local names, both allocated from a dictionary.

Returns: the localname or NULL in case of error.

const xmlCharxsltSplitQName (xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
 

: the attribute name

xsltGetNsProp: @node: the node

@nameSpace: the URI of the namespace

Similar to xmlGetNsProp() but with a slightly different semantic

Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified, or has no namespace and the element is in that namespace.

This does the entity substitution. This function looks in DTD attribute declaration for FIXED or default declaration values unless DTD use has been turned off.

Returns the attribute value or NULL if not found. It's up to the caller to free the memory.

#define XSLT_GET_VAR_STR(msg, str)
 
xmlGenericErrorFunc xsltGenericError = xsltGenericErrorDefaultFunc
 
voidxsltGenericErrorContext = NULL
 
xmlGenericErrorFunc xsltGenericDebug = xsltGenericDebugDefaultFunc
 
voidxsltGenericDebugContext = NULL
 
const xmlCharxsltGetCNsProp (xsltStylesheetPtr style, xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace)
 
xmlCharxsltGetNsProp (xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace)
 
int xsltGetUTF8Char (const unsigned char *utf, int *len)
 
int xsltGetUTF8CharZ (const unsigned char *utf, int *len)
 
void xsltMessage (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst)
 
static void LIBXSLT_ATTR_FORMAT (2, 3)
 
void xsltSetGenericErrorFunc (void *ctx, xmlGenericErrorFunc handler)
 
void xsltSetGenericDebugFunc (void *ctx, xmlGenericErrorFunc handler)
 
void xsltPrintErrorContext (xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node)
 
void xsltSetTransformErrorFunc (xsltTransformContextPtr ctxt, void *ctx, xmlGenericErrorFunc handler)
 
void xsltTransformError (xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
 

is

not prefixed.

static xsltSortFunc xsltSortFunction = xsltDefaultSortFunction
 
int xslDebugStatus
 
const xmlCharxsltGetQNameURI (xmlNodePtr node, xmlChar **name)
 
const xmlCharxsltGetQNameURI2 (xsltStylesheetPtr style, xmlNodePtr node, const xmlChar **name)
 
void xsltDocumentSortFunction (xmlNodeSetPtr list)
 
static xmlXPathObjectPtr * xsltComputeSortResultInternal (xsltTransformContextPtr ctxt, xmlNodePtr sort, int number, void *locale)
 
xmlXPathObjectPtr * xsltComputeSortResult (xsltTransformContextPtr ctxt, xmlNodePtr sort)
 
void xsltDefaultSortFunction (xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
 
void xsltDoSortFunction (xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
 
void xsltSetSortFunc (xsltSortFunc handler)
 
void xsltSetCtxtSortFunc (xsltTransformContextPtr ctxt, xsltSortFunc handler)
 
void xsltSetCtxtLocaleHandlers (xsltTransformContextPtr ctxt, xsltNewLocaleFunc newLocale, xsltFreeLocaleFunc freeLocale, xsltGenSortKeyFunc genSortKey)
 
int xsltSetCtxtParseOptions (xsltTransformContextPtr ctxt, int options)
 
int xsltSaveResultTo (xmlOutputBufferPtr buf, xmlDocPtr result, xsltStylesheetPtr style)
 
int xsltSaveResultToFilename (const char *URL, xmlDocPtr result, xsltStylesheetPtr style, int compression)
 
int xsltSaveResultToFile (FILE *file, xmlDocPtr result, xsltStylesheetPtr style)
 
int xsltSaveResultToFd (int fd, xmlDocPtr result, xsltStylesheetPtr style)
 
int xsltSaveResultToString (xmlChar **doc_txt_ptr, int *doc_txt_len, xmlDocPtr result, xsltStylesheetPtr style)
 
int xsltGetSourceNodeFlags (xmlNodePtr node)
 
int xsltSetSourceNodeFlags (xsltTransformContextPtr ctxt, xmlNodePtr node, int flags)
 
int xsltClearSourceNodeFlags (xmlNodePtr node, int flags)
 
void ** xsltGetPSVIPtr (xmlNodePtr cur)
 
xmlXPathCompExprPtr xsltXPathCompileFlags (xsltStylesheetPtr style, const xmlChar *str, int flags)
 
xmlXPathCompExprPtr xsltXPathCompile (xsltStylesheetPtr style, const xmlChar *str)
 
int xsltGetDebuggerStatus (void)
 

Detailed Description

Returns the number of bytes written or -1 in case of failure.

Definition in file xsltutils.c.

Macro Definition Documentation

◆ IN_LIBXSLT

#define IN_LIBXSLT

Definition at line 12 of file xsltutils.c.

◆ XSLT_GET_VAR_STR

#define XSLT_GET_VAR_STR (   msg,
  str 
)
Value:
{ \
int size; \
int chars; \
char *larger; \
\
str = (char *) xmlMalloc(150); \
if (str == NULL) \
return; \
\
size = 150; \
\
while (size < 64000) { \
va_start(ap, msg); \
chars = vsnprintf(str, size, msg, ap); \
va_end(ap); \
if ((chars > -1) && (chars < size)) \
break; \
if (chars > -1) \
size += chars + 1; \
else \
size += 100; \
if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
xmlFree(str); \
return; \
} \
str = larger; \
} \
}
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
char * va_list
Definition: vadefs.h:50
GLsizeiptr size
Definition: glext.h:5919
const WCHAR * str
xmlReallocFunc xmlRealloc
Definition: globals.c:214
xmlMallocFunc xmlMalloc
Definition: globals.c:193
#define vsnprintf
Definition: tif_win32.c:406
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Definition at line 537 of file xsltutils.c.

Function Documentation

◆ LIBXSLT_ATTR_FORMAT()

static void LIBXSLT_ATTR_FORMAT ( ,
 
)
static

xsltGenericErrorDefaultFunc: @ctx: an error context @msg: the message to display/transmit ...: extra parameters for the message display

Default handler for out of context error messages.

xsltGenericDebugDefaultFunc: @ctx: an error context @msg: the message to display/transmit ...: extra parameters for the message display

Default handler for out of context error messages.

Definition at line 574 of file xsltutils.c.

575 {
577
580
581 va_start(args, msg);
583 va_end(args);
584}
int CDECL vfprintf(FILE *file, const char *format, va_list valist)
Definition: file.c:5349
#define stderr
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
#define args
Definition: format.c:66
Definition: match.c:390
void * xsltGenericErrorContext
Definition: xsltutils.c:587

◆ xsltClearSourceNodeFlags()

int xsltClearSourceNodeFlags ( xmlNodePtr  node,
int  flags 
)

xsltClearSourceNodeFlags: @node: Node from source document @flags: Flags

Sets the specified flags to 0.

Returns 0 on success, -1 on error.

Definition at line 1999 of file xsltutils.c.

1999 {
2000 switch (node->type) {
2001 case XML_DOCUMENT_NODE:
2002 case XML_HTML_DOCUMENT_NODE:
2003 ((xmlDocPtr) node)->properties &= ~(flags << 27);
2004 return 0;
2005
2006 case XML_ATTRIBUTE_NODE:
2007 ((xmlAttrPtr) node)->atype &= ~(flags << 27);
2008 return 0;
2009
2010 case XML_ELEMENT_NODE:
2011 case XML_TEXT_NODE:
2012 case XML_CDATA_SECTION_NODE:
2013 case XML_PI_NODE:
2014 case XML_COMMENT_NODE:
2015 node->extra &= ~(flags << 12);
2016 return 0;
2017
2018 default:
2019 return -1;
2020 }
2021}
GLbitfield flags
Definition: glext.h:7161
Definition: dlist.c:348

Referenced by xsltCleanupSourceDoc().

◆ xsltComputeSortResult()

xmlXPathObjectPtr * xsltComputeSortResult ( xsltTransformContextPtr  ctxt,
xmlNodePtr  sort 
)

xsltComputeSortResult: @ctxt: a XSLT process context @sort: node list

reorder the current node list accordingly to the set of sorting requirement provided by the array of nodes.

Returns a ordered XPath nodeset or NULL in case of error.

Definition at line 1161 of file xsltutils.c.

1161 {
1162 const xsltStylePreComp *comp = sort->psvi;
1163 int number = 0;
1164
1165 if (comp != NULL)
1166 number = comp->number;
1168 /* locale */ NULL);
1169}
static struct @508 sort
static unsigned int number
Definition: dsound.c:1479
static xmlXPathObjectPtr * xsltComputeSortResultInternal(xsltTransformContextPtr ctxt, xmlNodePtr sort, int number, void *locale)
Definition: xsltutils.c:1023

◆ xsltComputeSortResultInternal()

static xmlXPathObjectPtr * xsltComputeSortResultInternal ( xsltTransformContextPtr  ctxt,
xmlNodePtr  sort,
int  number,
void locale 
)
static

xsltComputeSortResultInternal: @ctxt: a XSLT process context @sort: xsl:sort node @number: data-type is number @locale: transform strings according to locale

reorder the current node list accordingly to the set of sorting requirement provided by the array of nodes.

Returns a ordered XPath nodeset or NULL in case of error.

Definition at line 1023 of file xsltutils.c.

1024 {
1025#ifdef XSLT_REFACTORED
1026 xsltStyleItemSortPtr comp;
1027#else
1028 const xsltStylePreComp *comp;
1029#endif
1030 xmlXPathObjectPtr *results = NULL;
1031 xmlNodeSetPtr list = NULL;
1032 xmlXPathObjectPtr res;
1033 int len = 0;
1034 int i;
1035 xmlNodePtr oldNode;
1036 xmlNodePtr oldInst;
1037 int oldPos, oldSize ;
1038 int oldNsNr;
1039 xmlNsPtr *oldNamespaces;
1040
1041 comp = sort->psvi;
1042 if (comp == NULL) {
1044 "xsl:sort : compilation failed\n");
1045 return(NULL);
1046 }
1047
1048 if ((comp->select == NULL) || (comp->comp == NULL))
1049 return(NULL);
1050
1051 list = ctxt->nodeList;
1052 if ((list == NULL) || (list->nodeNr <= 1))
1053 return(NULL);
1054
1055 len = list->nodeNr;
1056
1057 /* TODO: xsl:sort lang attribute */
1058 /* TODO: xsl:sort case-order attribute */
1059
1060
1061 results = xmlMalloc(len * sizeof(xmlXPathObjectPtr));
1062 if (results == NULL) {
1064 "xsltComputeSortResult: memory allocation failure\n");
1065 return(NULL);
1066 }
1067
1068 oldNode = ctxt->node;
1069 oldInst = ctxt->inst;
1070 oldPos = ctxt->xpathCtxt->proximityPosition;
1071 oldSize = ctxt->xpathCtxt->contextSize;
1072 oldNsNr = ctxt->xpathCtxt->nsNr;
1073 oldNamespaces = ctxt->xpathCtxt->namespaces;
1074 for (i = 0;i < len;i++) {
1075 ctxt->inst = sort;
1076 ctxt->xpathCtxt->contextSize = len;
1077 ctxt->xpathCtxt->proximityPosition = i + 1;
1078 ctxt->node = list->nodeTab[i];
1079 ctxt->xpathCtxt->node = ctxt->node;
1080#ifdef XSLT_REFACTORED
1081 if (comp->inScopeNs != NULL) {
1082 ctxt->xpathCtxt->namespaces = comp->inScopeNs->list;
1083 ctxt->xpathCtxt->nsNr = comp->inScopeNs->xpathNumber;
1084 } else {
1085 ctxt->xpathCtxt->namespaces = NULL;
1086 ctxt->xpathCtxt->nsNr = 0;
1087 }
1088#else
1089 ctxt->xpathCtxt->namespaces = comp->nsList;
1090 ctxt->xpathCtxt->nsNr = comp->nsNr;
1091#endif
1092 res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
1093 if (res != NULL) {
1094 if (res->type != XPATH_STRING)
1095 res = xmlXPathConvertString(res);
1096 if (number)
1097 res = xmlXPathConvertNumber(res);
1098 }
1099 if (res != NULL) {
1100 res->index = i; /* Save original pos for dupl resolv */
1101 if (number) {
1102 if (res->type == XPATH_NUMBER) {
1103 results[i] = res;
1104 } else {
1105#ifdef WITH_XSLT_DEBUG_PROCESS
1107 "xsltComputeSortResult: select didn't evaluate to a number\n");
1108#endif
1109 results[i] = NULL;
1110 }
1111 } else {
1112 if (res->type == XPATH_STRING) {
1113 if (locale != NULL) {
1114 xmlChar *str = res->stringval;
1115 xmlChar *sortKey = ctxt->genSortKey(locale, str);
1116
1117 if (sortKey == NULL) {
1119 "xsltComputeSortResult: sort key is null\n");
1120 } else {
1121 res->stringval = sortKey;
1122 xmlFree(str);
1123 }
1124 }
1125
1126 results[i] = res;
1127 } else {
1128#ifdef WITH_XSLT_DEBUG_PROCESS
1130 "xsltComputeSortResult: select didn't evaluate to a string\n");
1131#endif
1132 results[i] = NULL;
1133 }
1134 }
1135 } else {
1136 ctxt->state = XSLT_STATE_STOPPED;
1137 results[i] = NULL;
1138 }
1139 }
1140 ctxt->node = oldNode;
1141 ctxt->inst = oldInst;
1142 ctxt->xpathCtxt->contextSize = oldSize;
1143 ctxt->xpathCtxt->proximityPosition = oldPos;
1144 ctxt->xpathCtxt->nsNr = oldNsNr;
1145 ctxt->xpathCtxt->namespaces = oldNamespaces;
1146
1147 return(results);
1148}
static struct _test_info results[8]
Definition: SetCursorPos.c:31
Definition: list.h:37
Definition: _locale.h:75
GLuint res
Definition: glext.h:9613
GLenum GLsizei len
Definition: glext.h:6722
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
xmlFreeFunc xmlFree
Definition: globals.c:184
xsltTransformState state
xmlNodeSetPtr nodeList
xsltGenSortKeyFunc genSortKey
xmlXPathContextPtr xpathCtxt
unsigned char xmlChar
Definition: xmlstring.h:28
@ XSLT_STATE_STOPPED
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:586
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633

Referenced by xsltComputeSortResult(), and xsltDefaultSortFunction().

◆ xsltDefaultSortFunction()

void xsltDefaultSortFunction ( xsltTransformContextPtr  ctxt,
xmlNodePtr *  sorts,
int  nbsorts 
)

xsltDefaultSortFunction: @ctxt: a XSLT process context @sorts: array of sort nodes @nbsorts: the number of sorts in the array

reorder the current node list accordingly to the set of sorting requirement provided by the arry of nodes.

Definition at line 1181 of file xsltutils.c.

1182 {
1183#ifdef XSLT_REFACTORED
1184 xsltStyleItemSortPtr comp;
1185#else
1186 const xsltStylePreComp *comp;
1187#endif
1188 xmlXPathObjectPtr *resultsTab[XSLT_MAX_SORT];
1189 xmlXPathObjectPtr *results = NULL, *res;
1190 xmlNodeSetPtr list = NULL;
1191 int len = 0;
1192 int i, j, incr;
1193 int tst;
1194 int depth;
1195 xmlNodePtr node;
1196 xmlXPathObjectPtr tmp;
1198 void *locale[XSLT_MAX_SORT];
1199
1200 if ((ctxt == NULL) || (sorts == NULL) || (nbsorts <= 0) ||
1201 (nbsorts >= XSLT_MAX_SORT))
1202 return;
1203 if (sorts[0] == NULL)
1204 return;
1205 comp = sorts[0]->psvi;
1206 if (comp == NULL)
1207 return;
1208
1209 list = ctxt->nodeList;
1210 if ((list == NULL) || (list->nodeNr <= 1))
1211 return; /* nothing to do */
1212
1213 for (j = 0; j < nbsorts; j++) {
1214 xmlChar *lang;
1215
1216 comp = sorts[j]->psvi;
1217 if ((comp->stype == NULL) && (comp->has_stype != 0)) {
1218 xmlChar *stype =
1219 xsltEvalAttrValueTemplate(ctxt, sorts[j],
1220 BAD_CAST "data-type", NULL);
1221 number[j] = 0;
1222 if (stype != NULL) {
1223 if (xmlStrEqual(stype, (const xmlChar *) "text"))
1224 ;
1225 else if (xmlStrEqual(stype, (const xmlChar *) "number"))
1226 number[j] = 1;
1227 else {
1228 xsltTransformError(ctxt, NULL, sorts[j],
1229 "xsltDoSortFunction: no support for data-type = %s\n",
1230 stype);
1231 }
1232 xmlFree(stype);
1233 }
1234 } else {
1235 number[j] = comp->number;
1236 }
1237 if ((comp->order == NULL) && (comp->has_order != 0)) {
1238 xmlChar *order = xsltEvalAttrValueTemplate(ctxt, sorts[j],
1239 BAD_CAST "order", NULL);
1240 desc[j] = 0;
1241 if (order != NULL) {
1242 if (xmlStrEqual(order, (const xmlChar *) "ascending"))
1243 ;
1244 else if (xmlStrEqual(order, (const xmlChar *) "descending"))
1245 desc[j] = 1;
1246 else {
1247 xsltTransformError(ctxt, NULL, sorts[j],
1248 "xsltDoSortFunction: invalid value %s for order\n",
1249 order);
1250 }
1251 xmlFree(order);
1252 }
1253 } else {
1254 desc[j] = comp->descending;
1255 }
1256 if ((comp->lang == NULL) && (comp->has_lang != 0)) {
1257 lang = xsltEvalAttrValueTemplate(ctxt, sorts[j],
1258 (xmlChar *) "lang",
1259 NULL);
1260 } else {
1261 lang = (xmlChar *) comp->lang;
1262 }
1263 if (lang != NULL) {
1264 locale[j] = ctxt->newLocale(lang, comp->lower_first);
1265 if (lang != comp->lang)
1266 xmlFree(lang);
1267 } else {
1268 locale[j] = NULL;
1269 }
1270 }
1271
1272 len = list->nodeNr;
1273
1274 resultsTab[0] = xsltComputeSortResultInternal(ctxt, sorts[0], number[0],
1275 locale[0]);
1276 for (i = 1;i < XSLT_MAX_SORT;i++)
1277 resultsTab[i] = NULL;
1278
1279 results = resultsTab[0];
1280
1281 comp = sorts[0]->psvi;
1282 if (results == NULL)
1283 goto cleanup;
1284
1285 /* Shell's sort of node-set */
1286 for (incr = len / 2; incr > 0; incr /= 2) {
1287 for (i = incr; i < len; i++) {
1288 j = i - incr;
1289 if (results[i] == NULL)
1290 continue;
1291
1292 while (j >= 0) {
1293 if (results[j] == NULL)
1294 tst = 1;
1295 else {
1296 if (number[0]) {
1297 /* We make NaN smaller than number in accordance
1298 with XSLT spec */
1299 if (xmlXPathIsNaN(results[j]->floatval)) {
1300 if (xmlXPathIsNaN(results[j + incr]->floatval))
1301 tst = 0;
1302 else
1303 tst = -1;
1304 } else if (xmlXPathIsNaN(results[j + incr]->floatval))
1305 tst = 1;
1306 else if (results[j]->floatval ==
1307 results[j + incr]->floatval)
1308 tst = 0;
1309 else if (results[j]->floatval >
1310 results[j + incr]->floatval)
1311 tst = 1;
1312 else tst = -1;
1313 } else {
1314 tst = xmlStrcmp(results[j]->stringval,
1315 results[j + incr]->stringval);
1316 }
1317 if (desc[0])
1318 tst = -tst;
1319 }
1320 if (tst == 0) {
1321 /*
1322 * Okay we need to use multi level sorts
1323 */
1324 depth = 1;
1325 while (depth < nbsorts) {
1326 if (sorts[depth] == NULL)
1327 break;
1328 comp = sorts[depth]->psvi;
1329 if (comp == NULL)
1330 break;
1331
1332 /*
1333 * Compute the result of the next level for the
1334 * full set, this might be optimized ... or not
1335 */
1336 if (resultsTab[depth] == NULL)
1337 resultsTab[depth] =
1339 sorts[depth],
1340 number[depth],
1341 locale[depth]);
1342 res = resultsTab[depth];
1343 if (res == NULL)
1344 break;
1345 if (res[j] == NULL) {
1346 if (res[j+incr] != NULL)
1347 tst = 1;
1348 } else if (res[j+incr] == NULL) {
1349 tst = -1;
1350 } else {
1351 if (number[depth]) {
1352 /* We make NaN smaller than number in
1353 accordance with XSLT spec */
1354 if (xmlXPathIsNaN(res[j]->floatval)) {
1355 if (xmlXPathIsNaN(res[j +
1356 incr]->floatval))
1357 tst = 0;
1358 else
1359 tst = -1;
1360 } else if (xmlXPathIsNaN(res[j + incr]->
1361 floatval))
1362 tst = 1;
1363 else if (res[j]->floatval == res[j + incr]->
1364 floatval)
1365 tst = 0;
1366 else if (res[j]->floatval >
1367 res[j + incr]->floatval)
1368 tst = 1;
1369 else tst = -1;
1370 } else {
1371 tst = xmlStrcmp(res[j]->stringval,
1372 res[j + incr]->stringval);
1373 }
1374 if (desc[depth])
1375 tst = -tst;
1376 }
1377
1378 /*
1379 * if we still can't differenciate at this level
1380 * try one level deeper.
1381 */
1382 if (tst != 0)
1383 break;
1384 depth++;
1385 }
1386 }
1387 if (tst == 0) {
1388 tst = results[j]->index > results[j + incr]->index;
1389 }
1390 if (tst > 0) {
1391 tmp = results[j];
1392 results[j] = results[j + incr];
1393 results[j + incr] = tmp;
1394 node = list->nodeTab[j];
1395 list->nodeTab[j] = list->nodeTab[j + incr];
1396 list->nodeTab[j + incr] = node;
1397 depth = 1;
1398 while (depth < nbsorts) {
1399 if (sorts[depth] == NULL)
1400 break;
1401 if (resultsTab[depth] == NULL)
1402 break;
1403 res = resultsTab[depth];
1404 tmp = res[j];
1405 res[j] = res[j + incr];
1406 res[j + incr] = tmp;
1407 depth++;
1408 }
1409 j -= incr;
1410 } else
1411 break;
1412 }
1413 }
1414 }
1415
1416cleanup:
1417 for (j = 0; j < nbsorts; j++) {
1418 if (locale[j] != NULL) {
1419 ctxt->freeLocale(locale[j]);
1420 }
1421 if (resultsTab[j] != NULL) {
1422 for (i = 0;i < len;i++)
1423 xmlXPathFreeObject(resultsTab[j][i]);
1424 xmlFree(resultsTab[j]);
1425 }
1426 }
1427}
const char * stype[]
Definition: cmds.c:192
static void cleanup(void)
Definition: main.c:1335
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
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 GLint GLint j
Definition: glfuncs.h:250
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
xsltNewLocaleFunc newLocale
xsltFreeLocaleFunc freeLocale
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:410
static const WCHAR lang[]
Definition: wbemdisp.c:287
XMLPUBFUN int xmlStrcmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:135
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162
#define XSLT_MAX_SORT

Referenced by xsltSetSortFunc().

◆ xsltDocumentSortFunction()

void xsltDocumentSortFunction ( xmlNodeSetPtr  list)

xsltDocumentSortFunction: @list: the node set

reorder the current node list @list accordingly to the document order This function is slow, obsolete and should not be used anymore.

Definition at line 987 of file xsltutils.c.

987 {
988 int i, j;
989 int len, tst;
990 xmlNodePtr node;
991
992 if (list == NULL)
993 return;
994 len = list->nodeNr;
995 if (len <= 1)
996 return;
997 /* TODO: sort is really not optimized, does it needs to ? */
998 for (i = 0;i < len -1;i++) {
999 for (j = i + 1; j < len; j++) {
1000 tst = xmlXPathCmpNodes(list->nodeTab[i], list->nodeTab[j]);
1001 if (tst == -1) {
1002 node = list->nodeTab[i];
1003 list->nodeTab[i] = list->nodeTab[j];
1004 list->nodeTab[j] = node;
1005 }
1006 }
1007 }
1008}

◆ xsltDoSortFunction()

void xsltDoSortFunction ( xsltTransformContextPtr  ctxt,
xmlNodePtr *  sorts,
int  nbsorts 
)

xsltDoSortFunction: @ctxt: a XSLT process context @sorts: array of sort nodes @nbsorts: the number of sorts in the array

reorder the current node list accordingly to the set of sorting requirement provided by the arry of nodes. This is a wrapper function, the actual function used is specified using xsltSetCtxtSortFunc() to set the context specific sort function, or xsltSetSortFunc() to set the global sort function. If a sort function is set on the context, this will get called. Otherwise the global sort function is called.

Definition at line 1447 of file xsltutils.c.

1449{
1450 if (ctxt->sortfunc != NULL)
1451 (ctxt->sortfunc)(ctxt, sorts, nbsorts);
1452 else if (xsltSortFunction != NULL)
1453 xsltSortFunction(ctxt, sorts, nbsorts);
1454}
static xsltSortFunc xsltSortFunction
Definition: xsltutils.c:1430

Referenced by xsltApplyTemplates(), and xsltForEach().

◆ xsltGetCNsProp()

const xmlChar * xsltGetCNsProp ( xsltStylesheetPtr  style,
xmlNodePtr  node,
const xmlChar name,
const xmlChar nameSpace 
)

Definition at line 76 of file xsltutils.c.

77 {
78 xmlAttrPtr prop;
79 xmlDocPtr doc;
80 xmlNsPtr ns;
81 xmlChar *tmp;
82 const xmlChar *ret;
83
84 if ((node == NULL) || (style == NULL) || (style->dict == NULL))
85 return(NULL);
86
87 if (nameSpace == NULL)
88 return xmlGetProp(node, name);
89
90 if (node->type == XML_NAMESPACE_DECL)
91 return(NULL);
92 if (node->type == XML_ELEMENT_NODE)
93 prop = node->properties;
94 else
95 prop = NULL;
96 while (prop != NULL) {
97 /*
98 * One need to have
99 * - same attribute names
100 * - and the attribute carrying that namespace
101 */
102 if ((xmlStrEqual(prop->name, name)) &&
103 (((prop->ns == NULL) && (node->ns != NULL) &&
104 (xmlStrEqual(node->ns->href, nameSpace))) ||
105 ((prop->ns != NULL) &&
106 (xmlStrEqual(prop->ns->href, nameSpace))))) {
107
108 tmp = xmlNodeListGetString(node->doc, prop->children, 1);
109 if (tmp == NULL)
110 ret = xmlDictLookup(style->dict, BAD_CAST "", 0);
111 else {
112 ret = xmlDictLookup(style->dict, tmp, -1);
113 xmlFree(tmp);
114 }
115 return ret;
116 }
117 prop = prop->next;
118 }
119 tmp = NULL;
120 /*
121 * Check if there is a default declaration in the internal
122 * or external subsets
123 */
124 doc = node->doc;
125 if (doc != NULL) {
126 if (doc->intSubset != NULL) {
127 xmlAttributePtr attrDecl;
128
129 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, node->name, name);
130 if ((attrDecl == NULL) && (doc->extSubset != NULL))
131 attrDecl = xmlGetDtdAttrDesc(doc->extSubset, node->name, name);
132
133 if ((attrDecl != NULL) && (attrDecl->prefix != NULL)) {
134 /*
135 * The DTD declaration only allows a prefix search
136 */
137 ns = xmlSearchNs(doc, node, attrDecl->prefix);
138 if ((ns != NULL) && (xmlStrEqual(ns->href, nameSpace)))
139 return(xmlDictLookup(style->dict,
140 attrDecl->defaultValue, -1));
141 }
142 }
143 }
144 return(NULL);
145}
Arabic default style
Definition: afstyles.h:94
return ret
Definition: mutex.c:146
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
Definition: name.c:39
Definition: mxnamespace.c:38
XMLPUBFUN xmlAttributePtr xmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name)
Definition: valid.c:3230

Referenced by xsltApplyTemplatesComp(), xsltCopyComp(), xsltCopyOfComp(), xsltForEachComp(), xsltGetQNameProperty(), xsltIfComp(), xsltNumberComp(), xsltParamComp(), xsltSortComp(), xsltTextComp(), xsltValueOfComp(), xsltVariableComp(), xsltWhenComp(), and xsltWithParamComp().

◆ xsltGetDebuggerStatus()

int xsltGetDebuggerStatus ( void  )

xsltGetDebuggerStatus:

Get xslDebugStatus.

Returns the value of xslDebugStatus.

Definition at line 2613 of file xsltutils.c.

2614{
2615 return(xslDebugStatus);
2616}
int xslDebugStatus
Definition: xsltutils.c:2603

◆ xsltGetNsProp()

xmlChar * xsltGetNsProp ( xmlNodePtr  node,
const xmlChar name,
const xmlChar nameSpace 
)

Definition at line 166 of file xsltutils.c.

166 {
167 xmlAttrPtr prop;
168 xmlDocPtr doc;
169 xmlNsPtr ns;
170
171 if (node == NULL)
172 return(NULL);
173
174 if (nameSpace == NULL)
175 return xmlGetProp(node, name);
176
177 if (node->type == XML_NAMESPACE_DECL)
178 return(NULL);
179 if (node->type == XML_ELEMENT_NODE)
180 prop = node->properties;
181 else
182 prop = NULL;
183 /*
184 * TODO: Substitute xmlGetProp() for xmlGetNsProp(), since the former
185 * is not namespace-aware and will return an attribute with equal
186 * name regardless of its namespace.
187 * Example:
188 * <xsl:element foo:name="myName"/>
189 * So this would return "myName" even if an attribute @name
190 * in the XSLT was requested.
191 */
192 while (prop != NULL) {
193 /*
194 * One need to have
195 * - same attribute names
196 * - and the attribute carrying that namespace
197 */
198 if ((xmlStrEqual(prop->name, name)) &&
199 (((prop->ns == NULL) && (node->ns != NULL) &&
200 (xmlStrEqual(node->ns->href, nameSpace))) ||
201 ((prop->ns != NULL) &&
202 (xmlStrEqual(prop->ns->href, nameSpace))))) {
203 xmlChar *ret;
204
205 ret = xmlNodeListGetString(node->doc, prop->children, 1);
206 if (ret == NULL) return(xmlStrdup((xmlChar *)""));
207 return(ret);
208 }
209 prop = prop->next;
210 }
211
212 /*
213 * Check if there is a default declaration in the internal
214 * or external subsets
215 */
216 doc = node->doc;
217 if (doc != NULL) {
218 if (doc->intSubset != NULL) {
219 xmlAttributePtr attrDecl;
220
221 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, node->name, name);
222 if ((attrDecl == NULL) && (doc->extSubset != NULL))
223 attrDecl = xmlGetDtdAttrDesc(doc->extSubset, node->name, name);
224
225 if ((attrDecl != NULL) && (attrDecl->prefix != NULL)) {
226 /*
227 * The DTD declaration only allows a prefix search
228 */
229 ns = xmlSearchNs(doc, node, attrDecl->prefix);
230 if ((ns != NULL) && (xmlStrEqual(ns->href, nameSpace)))
231 return(xmlStrdup(attrDecl->defaultValue));
232 }
233 }
234 }
235 return(NULL);
236}
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69

Referenced by xsltEvalAttrValueTemplate(), and xsltEvalStaticAttrValueTemplate().

◆ xsltGetPSVIPtr()

void ** xsltGetPSVIPtr ( xmlNodePtr  cur)

xsltGetPSVIPtr: @cur: Node

Returns a pointer to the psvi member of a node or NULL on error.

Definition at line 2030 of file xsltutils.c.

2030 {
2031 switch (cur->type) {
2032 case XML_DOCUMENT_NODE:
2033 case XML_HTML_DOCUMENT_NODE:
2034 return &((xmlDocPtr) cur)->psvi;
2035
2036 case XML_ATTRIBUTE_NODE:
2037 return &((xmlAttrPtr) cur)->psvi;
2038
2039 case XML_ELEMENT_NODE:
2040 case XML_TEXT_NODE:
2041 case XML_CDATA_SECTION_NODE:
2042 case XML_PI_NODE:
2043 case XML_COMMENT_NODE:
2044 return &cur->psvi;
2045
2046 default:
2047 return NULL;
2048 }
2049}
FxCollectionEntry * cur

Referenced by xsltCleanupSourceDoc(), and xsltGenerateIdFunction().

◆ xsltGetQNameURI()

const xmlChar * xsltGetQNameURI ( xmlNodePtr  node,
xmlChar **  name 
)

Definition at line 837 of file xsltutils.c.

838{
839 int len = 0;
840 xmlChar *qname;
841 xmlNsPtr ns;
842
843 if (name == NULL)
844 return(NULL);
845 qname = *name;
846 if ((qname == NULL) || (*qname == 0))
847 return(NULL);
848 if (node == NULL) {
850 "QName: no element for namespace lookup %s\n",
851 qname);
852 xmlFree(qname);
853 *name = NULL;
854 return(NULL);
855 }
856
857 /* nasty but valid */
858 if (qname[0] == ':')
859 return(NULL);
860
861 /*
862 * we are not trying to validate but just to cut, and yes it will
863 * work even if this is a set of UTF-8 encoded chars
864 */
865 while ((qname[len] != 0) && (qname[len] != ':'))
866 len++;
867
868 if (qname[len] == 0)
869 return(NULL);
870
871 /*
872 * handle xml: separately, this one is magical
873 */
874 if ((qname[0] == 'x') && (qname[1] == 'm') &&
875 (qname[2] == 'l') && (qname[3] == ':')) {
876 if (qname[4] == 0)
877 return(NULL);
878 *name = xmlStrdup(&qname[4]);
879 xmlFree(qname);
880 return(XML_XML_NAMESPACE);
881 }
882
883 qname[len] = 0;
884 ns = xmlSearchNs(node->doc, node, qname);
885 if (ns == NULL) {
887 "%s:%s : no namespace bound to prefix %s\n",
888 qname, &qname[len + 1], qname);
889 *name = NULL;
890 xmlFree(qname);
891 return(NULL);
892 }
893 *name = xmlStrdup(&qname[len + 1]);
894 xmlFree(qname);
895 return(ns->href);
896}

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

◆ xsltGetQNameURI2()

const xmlChar * xsltGetQNameURI2 ( xsltStylesheetPtr  style,
xmlNodePtr  node,
const xmlChar **  name 
)

Definition at line 911 of file xsltutils.c.

912 {
913 int len = 0;
914 xmlChar *qname;
915 xmlNsPtr ns;
916
917 if (name == NULL)
918 return(NULL);
919 qname = (xmlChar *)*name;
920 if ((qname == NULL) || (*qname == 0))
921 return(NULL);
922 if (node == NULL) {
924 "QName: no element for namespace lookup %s\n",
925 qname);
926 *name = NULL;
927 return(NULL);
928 }
929
930 /*
931 * we are not trying to validate but just to cut, and yes it will
932 * work even if this is a set of UTF-8 encoded chars
933 */
934 while ((qname[len] != 0) && (qname[len] != ':'))
935 len++;
936
937 if (qname[len] == 0)
938 return(NULL);
939
940 /*
941 * handle xml: separately, this one is magical
942 */
943 if ((qname[0] == 'x') && (qname[1] == 'm') &&
944 (qname[2] == 'l') && (qname[3] == ':')) {
945 if (qname[4] == 0)
946 return(NULL);
947 *name = xmlDictLookup(style->dict, &qname[4], -1);
948 return(XML_XML_NAMESPACE);
949 }
950
951 qname = xmlStrndup(*name, len);
952 ns = xmlSearchNs(node->doc, node, qname);
953 if (ns == NULL) {
954 if (style) {
956 "No namespace bound to prefix '%s'.\n",
957 qname);
958 style->errors++;
959 } else {
961 "%s : no namespace bound to prefix %s\n",
962 *name, qname);
963 }
964 *name = NULL;
965 xmlFree(qname);
966 return(NULL);
967 }
968 *name = xmlDictLookup(style->dict, (*name)+len+1, -1);
969 xmlFree(qname);
970 return(ns->href);
971}
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:45

Referenced by xsltGetQNameProperty().

◆ xsltGetSourceNodeFlags()

int xsltGetSourceNodeFlags ( xmlNodePtr  node)

xsltGetSourceNodeFlags: @node: Node from source document

Returns the flags for a source node.

Definition at line 1923 of file xsltutils.c.

1923 {
1924 /*
1925 * Squeeze the bit flags into the upper bits of
1926 *
1927 * - 'int properties' member in struct _xmlDoc
1928 * - 'xmlAttributeType atype' member in struct _xmlAttr
1929 * - 'unsigned short extra' member in struct _xmlNode
1930 */
1931 switch (node->type) {
1932 case XML_DOCUMENT_NODE:
1933 case XML_HTML_DOCUMENT_NODE:
1934 return ((xmlDocPtr) node)->properties >> 27;
1935
1936 case XML_ATTRIBUTE_NODE:
1937 return ((xmlAttrPtr) node)->atype >> 27;
1938
1939 case XML_ELEMENT_NODE:
1940 case XML_TEXT_NODE:
1941 case XML_CDATA_SECTION_NODE:
1942 case XML_PI_NODE:
1943 case XML_COMMENT_NODE:
1944 return node->extra >> 12;
1945
1946 default:
1947 return 0;
1948 }
1949}

Referenced by xsltGenerateIdFunction(), and xsltGetTemplate().

◆ xsltGetUTF8Char()

int xsltGetUTF8Char ( const unsigned char utf,
int len 
)

xsltGetUTF8Char: @utf: a sequence of UTF-8 encoded bytes @len: a pointer to @bytes len

Read one UTF8 Char from @utf Function copied from libxml2 xmlGetUTF8Char() ... to discard ultimately and use the original API

Returns the char value or -1 in case of error and update @len with the number of bytes used

Definition at line 251 of file xsltutils.c.

251 {
252 unsigned int c;
253
254 if (utf == NULL)
255 goto error;
256 if (len == NULL)
257 goto error;
258 if (*len < 1)
259 goto error;
260
261 c = utf[0];
262 if (c & 0x80) {
263 if (*len < 2)
264 goto error;
265 if ((utf[1] & 0xc0) != 0x80)
266 goto error;
267 if ((c & 0xe0) == 0xe0) {
268 if (*len < 3)
269 goto error;
270 if ((utf[2] & 0xc0) != 0x80)
271 goto error;
272 if ((c & 0xf0) == 0xf0) {
273 if (*len < 4)
274 goto error;
275 if ((c & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80)
276 goto error;
277 *len = 4;
278 /* 4-byte code */
279 c = (utf[0] & 0x7) << 18;
280 c |= (utf[1] & 0x3f) << 12;
281 c |= (utf[2] & 0x3f) << 6;
282 c |= utf[3] & 0x3f;
283 } else {
284 /* 3-byte code */
285 *len = 3;
286 c = (utf[0] & 0xf) << 12;
287 c |= (utf[1] & 0x3f) << 6;
288 c |= utf[2] & 0x3f;
289 }
290 } else {
291 /* 2-byte code */
292 *len = 2;
293 c = (utf[0] & 0x1f) << 6;
294 c |= utf[1] & 0x3f;
295 }
296 } else {
297 /* 1-byte code */
298 *len = 1;
299 }
300 return(c);
301
302error:
303 if (len != NULL)
304 *len = 0;
305 return(-1);
306}
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
#define error(str)
Definition: mkdosfs.c:1605

Referenced by xsltFormatNumberConversion(), and xsltNumberComp().

◆ xsltGetUTF8CharZ()

int xsltGetUTF8CharZ ( const unsigned char utf,
int len 
)

xsltGetUTF8CharZ: @utf: a sequence of UTF-8 encoded bytes @len: a pointer to @bytes len

Read one UTF8 Char from a null-terminated string.

Returns the char value or -1 in case of error and update @len with the number of bytes used

Definition at line 319 of file xsltutils.c.

319 {
320 unsigned int c;
321
322 if (utf == NULL)
323 goto error;
324 if (len == NULL)
325 goto error;
326
327 c = utf[0];
328 if (c & 0x80) {
329 if ((utf[1] & 0xc0) != 0x80)
330 goto error;
331 if ((c & 0xe0) == 0xe0) {
332 if ((utf[2] & 0xc0) != 0x80)
333 goto error;
334 if ((c & 0xf0) == 0xf0) {
335 if ((c & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80)
336 goto error;
337 *len = 4;
338 /* 4-byte code */
339 c = (utf[0] & 0x7) << 18;
340 c |= (utf[1] & 0x3f) << 12;
341 c |= (utf[2] & 0x3f) << 6;
342 c |= utf[3] & 0x3f;
343 } else {
344 /* 3-byte code */
345 *len = 3;
346 c = (utf[0] & 0xf) << 12;
347 c |= (utf[1] & 0x3f) << 6;
348 c |= utf[2] & 0x3f;
349 }
350 } else {
351 /* 2-byte code */
352 *len = 2;
353 c = (utf[0] & 0x1f) << 6;
354 c |= utf[1] & 0x3f;
355 }
356 } else {
357 /* 1-byte code */
358 *len = 1;
359 }
360 return(c);
361
362error:
363 if (len != NULL)
364 *len = 0;
365 return(-1);
366}

Referenced by xsltNumberFormatTokenize(), xsltScanLiteral(), and xsltScanNCName().

◆ xsltMessage()

void xsltMessage ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst 
)

xsltMessage: @ctxt: an XSLT processing context @node: The current node @inst: The node containing the message instruction

Process and xsl:message construct

Definition at line 492 of file xsltutils.c.

492 {
494 void *errctx = xsltGenericErrorContext;
495 xmlChar *prop, *message;
496 int terminate = 0;
497
498 if ((ctxt == NULL) || (inst == NULL))
499 return;
500
501 if (ctxt->error != NULL) {
502 error = ctxt->error;
503 errctx = ctxt->errctx;
504 }
505
506 prop = xmlGetNsProp(inst, (const xmlChar *)"terminate", NULL);
507 if (prop != NULL) {
508 if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
509 terminate = 1;
510 } else if (xmlStrEqual(prop, (const xmlChar *)"no")) {
511 terminate = 0;
512 } else {
513 xsltTransformError(ctxt, NULL, inst,
514 "xsl:message : terminate expecting 'yes' or 'no'\n");
515 }
516 xmlFree(prop);
517 }
518 message = xsltEvalTemplateString(ctxt, node, inst);
519 if (message != NULL) {
520 int len = xmlStrlen(message);
521
522 error(errctx, "%s", (const char *)message);
523 if ((len > 0) && (message[len - 1] != '\n'))
524 error(errctx, "\n");
526 }
527 if (terminate)
529}
void CDECL terminate(void)
Definition: cpp.c:698
xmlGenericErrorFunc error
Definition: tftpd.h:60
xmlChar * xsltEvalTemplateString(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst)
Definition: templates.c:207
void(* xmlGenericErrorFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
Definition: xmlerror.h:848
XMLPUBFUN int xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:428

Referenced by xsltApplySequenceConstructor(), and xsltMessageWrapper().

◆ xsltPrintErrorContext()

void xsltPrintErrorContext ( xsltTransformContextPtr  ctxt,
xsltStylesheetPtr  style,
xmlNodePtr  node 
)

xsltPrintErrorContext: @ctxt: the transformation context @style: the stylesheet @node: the current node being processed

Display the context of an error.

Definition at line 667 of file xsltutils.c.

668 {
669 int line = 0;
670 const xmlChar *file = NULL;
671 const xmlChar *name = NULL;
672 const char *type = "error";
674 void *errctx = xsltGenericErrorContext;
675
676 if (ctxt != NULL) {
677 if (ctxt->state == XSLT_STATE_OK)
678 ctxt->state = XSLT_STATE_ERROR;
679 if (ctxt->error != NULL) {
680 error = ctxt->error;
681 errctx = ctxt->errctx;
682 }
683 }
684 if ((node == NULL) && (ctxt != NULL))
685 node = ctxt->inst;
686
687 if (node != NULL) {
688 if ((node->type == XML_DOCUMENT_NODE) ||
689 (node->type == XML_HTML_DOCUMENT_NODE)) {
690 xmlDocPtr doc = (xmlDocPtr) node;
691
692 file = doc->URL;
693 } else {
694 line = xmlGetLineNo(node);
695 if ((node->doc != NULL) && (node->doc->URL != NULL))
696 file = node->doc->URL;
697 if (node->name != NULL)
698 name = node->name;
699 }
700 }
701
702 if (ctxt != NULL)
703 type = "runtime error";
704 else if (style != NULL) {
705#ifdef XSLT_REFACTORED
706 if (XSLT_CCTXT(style)->errSeverity == XSLT_ERROR_SEVERITY_WARNING)
707 type = "compilation warning";
708 else
709 type = "compilation error";
710#else
711 type = "compilation error";
712#endif
713 }
714
715 if ((file != NULL) && (line != 0) && (name != NULL))
716 error(errctx, "%s: file %s line %d element %s\n",
717 type, file, line, name);
718 else if ((file != NULL) && (name != NULL))
719 error(errctx, "%s: file %s element %s\n", type, file, name);
720 else if ((file != NULL) && (line != 0))
721 error(errctx, "%s: file %s line %d\n", type, file, line);
722 else if (file != NULL)
723 error(errctx, "%s: file %s\n", type, file);
724 else if (name != NULL)
725 error(errctx, "%s: element %s\n", type, name);
726 else
727 error(errctx, "%s\n", type);
728}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: fci.c:127
Definition: parser.c:49
@ XSLT_STATE_ERROR
@ XSLT_STATE_OK

Referenced by xsltTransformError().

◆ xsltSaveResultTo()

int xsltSaveResultTo ( xmlOutputBufferPtr  buf,
xmlDocPtr  result,
xsltStylesheetPtr  style 
)

xsltSaveResultTo: @buf: an output buffer

Returns
: the result xmlDocPtr @style: the stylesheet

Save the result

Returns
obtained by applying the @style stylesheet to an I/O output channel @buf

Returns the number of byte written or -1 in case of failure.

Definition at line 1564 of file xsltutils.c.

1565 {
1566 const xmlChar *encoding;
1567 int base;
1568 const xmlChar *method;
1569 int indent;
1570
1571 if ((buf == NULL) || (result == NULL) || (style == NULL))
1572 return(-1);
1573 if ((result->children == NULL) ||
1574 ((result->children->type == XML_DTD_NODE) &&
1575 (result->children->next == NULL)))
1576 return(0);
1577
1578 if ((style->methodURI != NULL) &&
1579 ((style->method == NULL) ||
1580 (!xmlStrEqual(style->method, (const xmlChar *) "xhtml")))) {
1582 "xsltSaveResultTo : unknown output method\n");
1583 return(-1);
1584 }
1585
1586 base = buf->written;
1587
1589 XSLT_GET_IMPORT_PTR(encoding, style, encoding)
1591
1592 if ((method == NULL) && (result->type == XML_HTML_DOCUMENT_NODE))
1593 method = (const xmlChar *) "html";
1594
1595 if ((method != NULL) &&
1596 (xmlStrEqual(method, (const xmlChar *) "html"))) {
1597 if (encoding != NULL) {
1598 htmlSetMetaEncoding(result, (const xmlChar *) encoding);
1599 } else {
1600 htmlSetMetaEncoding(result, (const xmlChar *) "UTF-8");
1601 }
1602 if (indent == -1)
1603 indent = 1;
1604 htmlDocContentDumpFormatOutput(buf, result, (const char *) encoding,
1605 indent);
1606 xmlOutputBufferFlush(buf);
1607 } else if ((method != NULL) &&
1608 (xmlStrEqual(method, (const xmlChar *) "xhtml"))) {
1609 if (encoding != NULL) {
1610 htmlSetMetaEncoding(result, (const xmlChar *) encoding);
1611 } else {
1612 htmlSetMetaEncoding(result, (const xmlChar *) "UTF-8");
1613 }
1614 htmlDocContentDumpOutput(buf, result, (const char *) encoding);
1615 xmlOutputBufferFlush(buf);
1616 } else if ((method != NULL) &&
1617 (xmlStrEqual(method, (const xmlChar *) "text"))) {
1618 xmlNodePtr cur;
1619
1620 cur = result->children;
1621 while (cur != NULL) {
1622 if (cur->type == XML_TEXT_NODE)
1623 xmlOutputBufferWriteString(buf, (const char *) cur->content);
1624
1625 /*
1626 * Skip to next node
1627 */
1628 if (cur->children != NULL) {
1629 if ((cur->children->type != XML_ENTITY_DECL) &&
1630 (cur->children->type != XML_ENTITY_REF_NODE) &&
1631 (cur->children->type != XML_ENTITY_NODE)) {
1632 cur = cur->children;
1633 continue;
1634 }
1635 }
1636 if (cur->next != NULL) {
1637 cur = cur->next;
1638 continue;
1639 }
1640
1641 do {
1642 cur = cur->parent;
1643 if (cur == NULL)
1644 break;
1645 if (cur == (xmlNodePtr) style->doc) {
1646 cur = NULL;
1647 break;
1648 }
1649 if (cur->next != NULL) {
1650 cur = cur->next;
1651 break;
1652 }
1653 } while (cur != NULL);
1654 }
1655 xmlOutputBufferFlush(buf);
1656 } else {
1657 int omitXmlDecl;
1658 int standalone;
1659
1660 XSLT_GET_IMPORT_INT(omitXmlDecl, style, omitXmlDeclaration);
1661 XSLT_GET_IMPORT_INT(standalone, style, standalone);
1662
1663 if (omitXmlDecl != 1) {
1664 xmlOutputBufferWriteString(buf, "<?xml version=");
1665 if (result->version != NULL) {
1666 xmlOutputBufferWriteString(buf, "\"");
1667 xmlOutputBufferWriteString(buf, (const char *)result->version);
1668 xmlOutputBufferWriteString(buf, "\"");
1669 } else
1670 xmlOutputBufferWriteString(buf, "\"1.0\"");
1671 if (encoding == NULL) {
1672 if (result->encoding != NULL)
1673 encoding = result->encoding;
1674 else if (result->charset != XML_CHAR_ENCODING_UTF8)
1675 encoding = (const xmlChar *)
1677 result->charset);
1678 }
1679 if (encoding != NULL) {
1680 xmlOutputBufferWriteString(buf, " encoding=");
1681 xmlOutputBufferWriteString(buf, "\"");
1682 xmlOutputBufferWriteString(buf, (const char *) encoding);
1683 xmlOutputBufferWriteString(buf, "\"");
1684 }
1685 switch (standalone) {
1686 case 0:
1687 xmlOutputBufferWriteString(buf, " standalone=\"no\"");
1688 break;
1689 case 1:
1690 xmlOutputBufferWriteString(buf, " standalone=\"yes\"");
1691 break;
1692 default:
1693 break;
1694 }
1695 xmlOutputBufferWriteString(buf, "?>\n");
1696 }
1697 if (result->children != NULL) {
1698 xmlNodePtr children = result->children;
1699 xmlNodePtr child = children;
1700
1701 /*
1702 * Hack to avoid quadratic behavior when scanning
1703 * result->children in xmlGetIntSubset called by
1704 * xmlNodeDumpOutput.
1705 */
1706 result->children = NULL;
1707
1708 while (child != NULL) {
1709 xmlNodeDumpOutput(buf, result, child, 0, (indent == 1),
1710 (const char *) encoding);
1711 if (indent && ((child->type == XML_DTD_NODE) ||
1712 ((child->type == XML_COMMENT_NODE) &&
1713 (child->next != NULL))))
1714 xmlOutputBufferWriteString(buf, "\n");
1715 child = child->next;
1716 }
1717 if (indent)
1718 xmlOutputBufferWriteString(buf, "\n");
1719
1720 result->children = children;
1721 }
1722 xmlOutputBufferFlush(buf);
1723 }
1724 return(buf->written - base);
1725}
static const WCHAR indent[]
Definition: object.c:1156
method
Definition: dragdrop.c:54
const char * xmlGetCharEncodingName(xmlCharEncoding enc)
Definition: encoding.c:1229
xmlCharEncoding
Definition: encoding.h:65
@ XML_CHAR_ENCODING_UTF8
Definition: encoding.h:68
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint64EXT * result
Definition: glext.h:11304
static HWND child
Definition: cursoricon.c:298
#define XSLT_GET_IMPORT_INT(res, style, name)
Definition: node.c:1079
#define XSLT_GET_IMPORT_PTR(res, style, name)
Definition: node.c:1070

Referenced by xsltRunStylesheetUser(), xsltSaveResultToFd(), xsltSaveResultToFile(), xsltSaveResultToFilename(), and xsltSaveResultToString().

◆ xsltSaveResultToFd()

int xsltSaveResultToFd ( int  fd,
xmlDocPtr  result,
xsltStylesheetPtr  style 
)

xsltSaveResultToFd: @fd: a file descriptor

Returns
: the result xmlDocPtr @style: the stylesheet

Save the result

Returns
obtained by applying the @style stylesheet to an open file descriptor This does not close the descriptor.

Returns the number of bytes written or -1 in case of failure.

Definition at line 1826 of file xsltutils.c.

1826 {
1827 xmlOutputBufferPtr buf;
1828 const xmlChar *encoding;
1829 int ret;
1830
1831 if ((fd < 0) || (result == NULL) || (style == NULL))
1832 return(-1);
1833 if (result->children == NULL)
1834 return(0);
1835
1836 XSLT_GET_IMPORT_PTR(encoding, style, encoding)
1837 if (encoding != NULL) {
1839
1840 /* Don't use UTF-8 dummy encoder */
1841 if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) &&
1842 (xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0))
1843 encoder = xmlFindCharEncodingHandler((char *) encoding);
1844 buf = xmlOutputBufferCreateFd(fd, encoder);
1845 } else {
1846 buf = xmlOutputBufferCreateFd(fd, NULL);
1847 }
1848 if (buf == NULL)
1849 return(-1);
1851 ret = xmlOutputBufferClose(buf);
1852 return(ret);
1853}
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1677
static int fd
Definition: io.c:51
XMLPUBFUN int xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:277
int xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result, xsltStylesheetPtr style)
Definition: xsltutils.c:1564

◆ xsltSaveResultToFile()

int xsltSaveResultToFile ( FILE file,
xmlDocPtr  result,
xsltStylesheetPtr  style 
)

Definition at line 1783 of file xsltutils.c.

1783 {
1784 xmlOutputBufferPtr buf;
1785 const xmlChar *encoding;
1786 int ret;
1787
1788 if ((file == NULL) || (result == NULL) || (style == NULL))
1789 return(-1);
1790 if (result->children == NULL)
1791 return(0);
1792
1793 XSLT_GET_IMPORT_PTR(encoding, style, encoding)
1794 if (encoding != NULL) {
1796
1797 /* Don't use UTF-8 dummy encoder */
1798 if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) &&
1799 (xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0))
1800 encoder = xmlFindCharEncodingHandler((char *) encoding);
1801 buf = xmlOutputBufferCreateFile(file, encoder);
1802 } else {
1803 buf = xmlOutputBufferCreateFile(file, NULL);
1804 }
1805
1806 if (buf == NULL)
1807 return(-1);
1809 ret = xmlOutputBufferClose(buf);
1810 return(ret);
1811}

Referenced by xsltDocumentElem().

◆ xsltSaveResultToFilename()

int xsltSaveResultToFilename ( const char URL,
xmlDocPtr  result,
xsltStylesheetPtr  style,
int  compression 
)

xsltSaveResultToFilename: @URL: a filename or URL

Returns
: the result xmlDocPtr @style: the stylesheet @compression: the compression factor (0 - 9 included)

Save the result

Returns
obtained by applying the @style stylesheet to a file or @URL

Returns the number of byte written or -1 in case of failure.

Definition at line 1740 of file xsltutils.c.

1741 {
1742 xmlOutputBufferPtr buf;
1743 const xmlChar *encoding;
1744 int ret;
1745
1746 if ((URL == NULL) || (result == NULL) || (style == NULL))
1747 return(-1);
1748 if (result->children == NULL)
1749 return(0);
1750
1751 XSLT_GET_IMPORT_PTR(encoding, style, encoding)
1752 if (encoding != NULL) {
1754
1755 /* Don't use UTF-8 dummy encoder */
1756 if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) &&
1757 (xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0))
1758 encoder = xmlFindCharEncodingHandler((char *) encoding);
1759 buf = xmlOutputBufferCreateFilename(URL, encoder, compression);
1760 } else {
1761 buf = xmlOutputBufferCreateFilename(URL, NULL, compression);
1762 }
1763 if (buf == NULL)
1764 return(-1);
1766 ret = xmlOutputBufferClose(buf);
1767 return(ret);
1768}
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
Definition: btrfs_drv.h:1365

Referenced by xsltDocumentElem(), and xsltRunStylesheetUser().

◆ xsltSaveResultToString()

int xsltSaveResultToString ( xmlChar **  doc_txt_ptr,
int doc_txt_len,
xmlDocPtr  result,
xsltStylesheetPtr  style 
)

xsltSaveResultToString: @doc_txt_ptr: Memory pointer for allocated XML text @doc_txt_len: Length of the generated XML text

Returns
: the result xmlDocPtr @style: the stylesheet

Save the result

Returns
obtained by applying the @style stylesheet to a new allocated string.

Returns 0 in case of success and -1 in case of error

Definition at line 1868 of file xsltutils.c.

1869 {
1870 xmlOutputBufferPtr buf;
1871 const xmlChar *encoding;
1872
1873 *doc_txt_ptr = NULL;
1874 *doc_txt_len = 0;
1875 if (result->children == NULL)
1876 return(0);
1877
1878 XSLT_GET_IMPORT_PTR(encoding, style, encoding)
1879 if (encoding != NULL) {
1881
1882 /* Don't use UTF-8 dummy encoder */
1883 if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) &&
1884 (xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0))
1885 encoder = xmlFindCharEncodingHandler((char *) encoding);
1886 buf = xmlAllocOutputBuffer(encoder);
1887 if (buf == NULL)
1889 } else {
1890 buf = xmlAllocOutputBuffer(NULL);
1891 }
1892 if (buf == NULL)
1893 return(-1);
1895#ifdef LIBXML2_NEW_BUFFER
1896 if (buf->conv != NULL) {
1897 *doc_txt_len = xmlBufUse(buf->conv);
1898 *doc_txt_ptr = xmlStrndup(xmlBufContent(buf->conv), *doc_txt_len);
1899 } else {
1900 *doc_txt_len = xmlBufUse(buf->buffer);
1901 *doc_txt_ptr = xmlStrndup(xmlBufContent(buf->buffer), *doc_txt_len);
1902 }
1903#else
1904 if (buf->conv != NULL) {
1905 *doc_txt_len = buf->conv->use;
1906 *doc_txt_ptr = xmlStrndup(buf->conv->content, *doc_txt_len);
1907 } else {
1908 *doc_txt_len = buf->buffer->use;
1909 *doc_txt_ptr = xmlStrndup(buf->buffer->content, *doc_txt_len);
1910 }
1911#endif
1912 (void)xmlOutputBufferClose(buf);
1913 return 0;
1914}
xmlChar * xmlBufContent(const xmlBuf *buf)
Definition: buf.c:490
size_t xmlBufUse(const xmlBufPtr buf)
Definition: buf.c:570
XMLPUBFUN int xmlCharEncCloseFunc(xmlCharEncodingHandler *handler)

◆ xsltSetCtxtLocaleHandlers()

void xsltSetCtxtLocaleHandlers ( xsltTransformContextPtr  ctxt,
xsltNewLocaleFunc  newLocale,
xsltFreeLocaleFunc  freeLocale,
xsltGenSortKeyFunc  genSortKey 
)

xsltSetCtxtLocaleHandlers: @ctxt: an XSLT transform context @newLocale: locale constructor @freeLocale: locale destructor @genSortKey: sort key generator

Set the locale handlers.

Definition at line 1500 of file xsltutils.c.

1503 {
1504 if (ctxt == NULL)
1505 return;
1506
1507 ctxt->newLocale = newLocale;
1508 ctxt->freeLocale = freeLocale;
1509 ctxt->genSortKey = genSortKey;
1510}

◆ xsltSetCtxtParseOptions()

int xsltSetCtxtParseOptions ( xsltTransformContextPtr  ctxt,
int  options 
)

xsltSetCtxtParseOptions: @ctxt: a XSLT process context @options: a combination of libxml2 xmlParserOption

Change the default parser option passed by the XSLT engine to the parser when using document() loading.

Returns the previous options or -1 in case of error

Definition at line 1529 of file xsltutils.c.

1530{
1531 int oldopts;
1532
1533 if (ctxt == NULL)
1534 return(-1);
1535 oldopts = ctxt->parserOptions;
1536 if (ctxt->xinclude)
1537 oldopts |= XML_PARSE_XINCLUDE;
1538 ctxt->parserOptions = options;
1540 ctxt->xinclude = 1;
1541 else
1542 ctxt->xinclude = 0;
1543 return(oldopts);
1544}
@ XML_PARSE_XINCLUDE
Definition: parser.h:1240

◆ xsltSetCtxtSortFunc()

void xsltSetCtxtSortFunc ( xsltTransformContextPtr  ctxt,
xsltSortFunc  handler 
)

xsltSetCtxtSortFunc: @ctxt: a XSLT process context @handler: the new handler function

DEPRECATED: Use xsltSetCtxtLocaleHandlers.

Function to set the handler for XSLT sorting for the specified context. If the handler is NULL, then the global sort function will be called

Definition at line 1486 of file xsltutils.c.

1486 {
1487 ctxt->sortfunc = handler;
1488}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512

◆ xsltSetGenericDebugFunc()

void xsltSetGenericDebugFunc ( void ctx,
xmlGenericErrorFunc  handler 
)

xsltSetGenericDebugFunc: @ctx: the new error handling context @handler: the new handler function

Function to reset the handler and the error context for out of context error messages. This simply means that @handler will be called for subsequent error messages while not parsing or validating. And @ctx will be passed as first argument to @handler One can simply force messages to be emitted to another FILE * than stderr by setting @ctx to this file handle and @handler to NULL.

Definition at line 650 of file xsltutils.c.

650 {
652 if (handler != NULL)
654 else
655 xsltGenericDebug = xsltGenericDebugDefaultFunc;
656}

◆ xsltSetGenericErrorFunc()

void xsltSetGenericErrorFunc ( void ctx,
xmlGenericErrorFunc  handler 
)

xsltSetGenericErrorFunc: @ctx: the new error handling context @handler: the new handler function

Function to reset the handler and the error context for out of context error messages. This simply means that @handler will be called for subsequent error messages while not parsing nor validating. And @ctx will be passed as first argument to @handler One can simply force messages to be emitted to another FILE * than stderr by setting @ctx to this file handle and @handler to NULL.

Definition at line 604 of file xsltutils.c.

604 {
606 if (handler != NULL)
608 else
609 xsltGenericError = xsltGenericErrorDefaultFunc;
610}

◆ xsltSetSortFunc()

void xsltSetSortFunc ( xsltSortFunc  handler)

xsltSetSortFunc: @handler: the new handler function

DEPRECATED: Use xsltSetCtxtLocaleHandlers.

Function to reset the global handler for XSLT sorting. If the handler is NULL, the default sort function will be used.

Definition at line 1466 of file xsltutils.c.

1466 {
1467 if (handler != NULL)
1469 else
1471}
void xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
Definition: xsltutils.c:1181

◆ xsltSetSourceNodeFlags()

int xsltSetSourceNodeFlags ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
int  flags 
)

xsltSetSourceNodeFlags: @node: Node from source document @flags: Flags

Sets the specified flags to 1.

Returns 0 on success, -1 on error.

Definition at line 1961 of file xsltutils.c.

1962 {
1963 if (node->doc == ctxt->initialContextDoc)
1964 ctxt->sourceDocDirty = 1;
1965
1966 switch (node->type) {
1967 case XML_DOCUMENT_NODE:
1968 case XML_HTML_DOCUMENT_NODE:
1969 ((xmlDocPtr) node)->properties |= flags << 27;
1970 return 0;
1971
1972 case XML_ATTRIBUTE_NODE:
1973 ((xmlAttrPtr) node)->atype |= flags << 27;
1974 return 0;
1975
1976 case XML_ELEMENT_NODE:
1977 case XML_TEXT_NODE:
1978 case XML_CDATA_SECTION_NODE:
1979 case XML_PI_NODE:
1980 case XML_COMMENT_NODE:
1981 node->extra |= flags << 12;
1982 return 0;
1983
1984 default:
1985 return -1;
1986 }
1987}

Referenced by xsltGenerateIdFunction(), and xsltInitCtxtKey().

◆ xsltSetTransformErrorFunc()

void xsltSetTransformErrorFunc ( xsltTransformContextPtr  ctxt,
void ctx,
xmlGenericErrorFunc  handler 
)

xsltSetTransformErrorFunc: @ctxt: the XSLT transformation context @ctx: the new error handling context @handler: the new handler function

Function to reset the handler and the error context for out of context error messages specific to a given XSLT transromation.

This simply means that @handler will be called for subsequent error messages while running the transformation.

Definition at line 743 of file xsltutils.c.

745{
746 ctxt->error = handler;
747 ctxt->errctx = ctx;
748}

◆ xsltSplitQName()

const xmlChar * xsltSplitQName ( xmlDictPtr  dict,
const xmlChar name,
const xmlChar **  prefix 
)

Definition at line 804 of file xsltutils.c.

804 {
805 int len = 0;
806 const xmlChar *ret = NULL;
807
808 *prefix = NULL;
809 if ((name == NULL) || (dict == NULL)) return(NULL);
810 if (name[0] == ':')
811 return(xmlDictLookup(dict, name, -1));
812 while ((name[len] != 0) && (name[len] != ':')) len++;
813 if (name[len] == 0) return(xmlDictLookup(dict, name, -1));
814 *prefix = xmlDictLookup(dict, name, len);
815 ret = xmlDictLookup(dict, &name[len + 1], -1);
816 return(ret);
817}
Character const *const prefix
Definition: tempnam.cpp:195

Referenced by xsltApplyAttributeSet(), xsltAttribute(), xsltAttributeComp(), xsltElement(), xsltElementComp(), xsltFormatNumberFunction(), xsltParseStylesheetAttributeSet(), and xsltProcessUserParamInternal().

◆ xsltTransformError()

void xsltTransformError ( xsltTransformContextPtr  ctxt,
xsltStylesheetPtr  style,
xmlNodePtr  node,
const char msg,
  ... 
)

xsltTransformError: @ctxt: an XSLT transformation context @style: the XSLT stylesheet used @node: the current node in the stylesheet @msg: the message to display/transmit ...: extra parameters for the message display

Display and format an error messages, gives file, line, position and extra parameters, will use the specific transformation context if available

Definition at line 762 of file xsltutils.c.

765 {
767 void *errctx = xsltGenericErrorContext;
768 char * str;
769
770 if (ctxt != NULL) {
771 if (ctxt->state == XSLT_STATE_OK)
772 ctxt->state = XSLT_STATE_ERROR;
773 if (ctxt->error != NULL) {
774 error = ctxt->error;
775 errctx = ctxt->errctx;
776 }
777 }
778 if ((node == NULL) && (ctxt != NULL))
779 node = ctxt->inst;
782 error(errctx, "%s", str);
783 if (str != NULL)
784 xmlFree(str);
785}
#define XSLT_GET_VAR_STR(msg, str)
Definition: xsltutils.c:537
void xsltPrintErrorContext(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node)
Definition: xsltutils.c:667

Referenced by xsltAddKey(), xsltAddTemplate(), xsltAddTextString(), xsltAllocateExtraCtxt(), xsltApplyAttributeSet(), xsltApplyImports(), xsltApplySequenceConstructor(), xsltApplyStylesheetInternal(), xsltApplyTemplates(), xsltApplyTemplatesComp(), xsltApplyXSLTTemplate(), xsltAttribute(), xsltAttributeComp(), xsltAttrListTemplateProcess(), xsltAttrTemplateProcess(), xsltAttrTemplateValueProcessNode(), xsltCallTemplate(), xsltCheckCycle(), xsltCheckInstructionElement(), xsltCheckParentElement(), xsltCheckRead(), xsltCheckTopLevelElement(), xsltCheckWrite(), xsltCheckWritePath(), xsltChoose(), xsltComment(), xsltCompileAttr(), xsltCompileIdKeyPattern(), xsltCompileLocationPathPattern(), xsltCompilePatternInternal(), xsltCompileStepPattern(), xsltCompMatchAdd(), xsltComputeAllKeys(), xsltComputeSortResultInternal(), xsltCopyOf(), xsltCopyOfComp(), xsltCopyStackElem(), xsltCopyText(), xsltCopyTextString(), xsltCopyTree(), xsltCurrentFunction(), xsltDefaultProcessOneNode(), xsltDefaultSortFunction(), xsltDocumentElem(), xsltDocumentFunction(), xsltDocumentFunctionLoadDocument(), xsltElement(), xsltElementAvailableFunction(), xsltElementComp(), xsltEvalGlobalVariable(), xsltEvalGlobalVariables(), xsltEvalTemplateString(), xsltEvalVariable(), xsltEvalXPathPredicate(), xsltEvalXPathStringNs(), xsltExtElementPreCompTest(), xsltExtElementTest(), xsltExtFunctionTest(), xsltExtInitTest(), xsltExtShutdownTest(), xsltExtStyleInitTest(), xsltExtStyleShutdownTest(), xsltFlagRVTs(), xsltForEach(), xsltForEachComp(), xsltFormatNumberConversion(), xsltFormatNumberFunction(), xsltFunctionAvailableFunction(), xsltFunctionNodeSet(), xsltGatherNamespaces(), xsltGenerateIdFunction(), xsltGetExtData(), xsltGetQNameProperty(), xsltGetQNameURI2(), xsltGetSpecialNamespace(), xsltGlobalVariableLookup(), xsltIf(), xsltIfComp(), xsltInitCtxtKey(), xsltInitDocKeyTable(), xsltKeyFunction(), xsltLoadDocument(), xsltLoadStyleDocument(), xsltLoadStylesheetPI(), xsltMessage(), xsltNamespaceAlias(), xsltNewAttrVT(), xsltNewCompMatch(), xsltNewDocument(), xsltNewElemPreComp(), xsltNewExtData(), xsltNewExtDef(), xsltNewExtElement(), xsltNewExtModule(), xsltNewKeyDef(), xsltNewKeyTable(), xsltNewParserContext(), xsltNewSecurityPrefs(), xsltNewStackElem(), xsltNewStyleDocument(), xsltNewStylePreComp(), xsltNewStylesheetInternal(), xsltNewTemplate(), xsltNewTransformContext(), xsltNumber(), xsltNumberComp(), xsltNumberFormatInsertNumbers(), xsltParamComp(), xsltParseContentError(), xsltParseGlobalParam(), xsltParseGlobalVariable(), xsltParseStylesheetAttributeSet(), xsltParseStylesheetCallerParam(), xsltParseStylesheetDecimalFormat(), xsltParseStylesheetExcludePrefix(), xsltParseStylesheetExtPrefix(), xsltParseStylesheetFile(), xsltParseStylesheetImport(), xsltParseStylesheetInclude(), xsltParseStylesheetKey(), xsltParseStylesheetOutput(), xsltParseStylesheetParam(), xsltParseStylesheetPreserveSpace(), xsltParseStylesheetProcess(), xsltParseStylesheetStripSpace(), xsltParseStylesheetTemplate(), xsltParseStylesheetTop(), xsltParseStylesheetVariable(), xsltParseTemplateContent(), xsltProcessingInstruction(), xsltProcessUserParamInternal(), xsltRegisterGlobalVariable(), xsltRegisterVariable(), xsltReleaseLocalRVTs(), xsltResolveAttrSet(), xsltRunStylesheetUser(), xsltShallowCopyAttr(), xsltShallowCopyElem(), xsltShallowCopyNsNode(), xsltSort(), xsltSortComp(), xsltStrxfrm(), xsltStyleInitializeStylesheetModule(), xsltStylePreCompute(), xsltSystemPropertyFunction(), xsltTestCompMatch(), xsltTestStepMatch(), xsltText(), xsltTextComp(), xsltTransformCacheCreate(), xsltValueOf(), xsltValueOfComp(), xsltVariableComp(), xsltWhenComp(), xsltWithParamComp(), and xsltXPathVariableLookup().

◆ xsltXPathCompile()

xmlXPathCompExprPtr xsltXPathCompile ( xsltStylesheetPtr  style,
const xmlChar str 
)

xsltXPathCompile: @style: the stylesheet @str: the XPath expression

Compile an XPath expression

Returns the xmlXPathCompExprPtr resulting from the compilation or NULL. the caller has to free the object.

Definition at line 2593 of file xsltutils.c.

2593 {
2594 return(xsltXPathCompileFlags(style, str, 0));
2595}
xmlXPathCompExprPtr xsltXPathCompileFlags(xsltStylesheetPtr style, const xmlChar *str, int flags)
Definition: xsltutils.c:2550

Referenced by xsltAddKey(), xsltApplyTemplatesComp(), xsltCompileAttr(), xsltCopyOfComp(), xsltForEachComp(), xsltIfComp(), xsltParamComp(), xsltSortComp(), xsltValueOfComp(), xsltVariableComp(), xsltWhenComp(), and xsltWithParamComp().

◆ xsltXPathCompileFlags()

xmlXPathCompExprPtr xsltXPathCompileFlags ( xsltStylesheetPtr  style,
const xmlChar str,
int  flags 
)

xsltXPathCompileFlags: @style: the stylesheet @str: the XPath expression @flags: extra compilation flags to pass down to libxml2 XPath

Compile an XPath expression

Returns the xmlXPathCompExprPtr resulting from the compilation or NULL. the caller has to free the object.

Definition at line 2550 of file xsltutils.c.

2550 {
2551 xmlXPathContextPtr xpathCtxt;
2552 xmlXPathCompExprPtr ret;
2553
2554 if (style != NULL) {
2555 xpathCtxt = style->principal->xpathCtxt;
2556 if (xpathCtxt == NULL)
2557 return NULL;
2558 xpathCtxt->dict = style->dict;
2559 } else {
2560 xpathCtxt = xmlXPathNewContext(NULL);
2561 if (xpathCtxt == NULL)
2562 return NULL;
2563 }
2564 xpathCtxt->flags = flags;
2565
2566 /*
2567 * Compile the expression.
2568 */
2569 ret = xmlXPathCtxtCompile(xpathCtxt, str);
2570
2571 if (style == NULL) {
2572 xmlXPathFreeContext(xpathCtxt);
2573 }
2574 /*
2575 * TODO: there is a lot of optimizations which should be possible
2576 * like variable slot precomputations, function precomputations, etc.
2577 */
2578
2579 return(ret);
2580}

Referenced by xsltAddKey(), xsltCompMatchAdd(), and xsltXPathCompile().

Variable Documentation

◆ xslDebugStatus

◆ xsltGenericDebug

xmlGenericErrorFunc xsltGenericDebug = xsltGenericDebugDefaultFunc

Definition at line 632 of file xsltutils.c.

Referenced by xsltAddKey(), xsltAddTemplate(), xsltApplyAttributeSet(), xsltApplyFallbacks(), xsltApplySequenceConstructor(), xsltApplyStripSpaces(), xsltApplyStylesheetInternal(), xsltApplyTemplates(), xsltApplyXSLTTemplate(), xsltBuildVariable(), xsltCallTemplate(), xsltChoose(), xsltComment(), xsltCompileAttr(), xsltCompilePatternInternal(), xsltComputeSortResultInternal(), xsltCopy(), xsltCopyOf(), xsltCopyText(), xsltCopyTextString(), xsltDefaultProcessOneNode(), xsltDocDefaultLoaderFunc(), xsltDocumentComp(), xsltDocumentElem(), xsltEvalAttrValueTemplate(), xsltEvalGlobalVariable(), xsltEvalGlobalVariables(), xsltEvalVariable(), xsltEvalXPathPredicate(), xsltEvalXPathStringNs(), xsltExtElementPreCompTest(), xsltExtElementTest(), xsltExtFunctionTest(), xsltExtInitTest(), xsltExtShutdownTest(), xsltExtStyleInitTest(), xsltExtStyleShutdownTest(), xsltFlagRVTs(), xsltForEach(), xsltFreeStylesheet(), xsltFreeTransformContext(), xsltGatherNamespaces(), xsltGetExtData(), xsltGetInheritedNsList(), xsltGetKey(), xsltGlobalVariableLookup(), xsltIf(), xsltInitCtxtExt(), xsltInitCtxtExts(), xsltInitCtxtKey(), xsltInitCtxtKeys(), xsltInitDocKeyTable(), xsltLoadStylesheetPI(), xsltNewStylesheetInternal(), xsltNewTransformContext(), xsltParseGlobalParam(), xsltParseGlobalVariable(), xsltParseStylesheetAttributeSet(), xsltParseStylesheetCallerParam(), xsltParseStylesheetExcludePrefix(), xsltParseStylesheetExtPrefix(), xsltParseStylesheetFile(), xsltParseStylesheetKey(), xsltParseStylesheetOutput(), xsltParseStylesheetParam(), xsltParseStylesheetPreserveSpace(), xsltParseStylesheetProcess(), xsltParseStylesheetStripSpace(), xsltParseStylesheetTemplate(), xsltParseStylesheetTop(), xsltParseStylesheetUser(), xsltParseStylesheetVariable(), xsltParseTemplateContent(), xsltPreprocessStylesheet(), xsltProcessingInstruction(), xsltProcessOneNode(), xsltProcessUserParamInternal(), xsltRegisterExtPrefix(), xsltRegisterGlobalVariable(), xsltRegisterVariable(), xsltResolveAttrSet(), xsltResolveStylesheetAttributeSet(), xsltSetGenericDebugFunc(), xsltShutdownCtxtExt(), xsltShutdownExt(), xsltStyleInitializeStylesheetModule(), xsltText(), xsltValueOf(), xsltVariableLookup(), xsltXPathFunctionLookup(), and xsltXPathVariableLookup().

◆ xsltGenericDebugContext

void* xsltGenericDebugContext = NULL

Definition at line 633 of file xsltutils.c.

Referenced by xsltAddKey(), xsltAddTemplate(), xsltApplyAttributeSet(), xsltApplyFallbacks(), xsltApplySequenceConstructor(), xsltApplyStripSpaces(), xsltApplyStylesheetInternal(), xsltApplyTemplates(), xsltApplyXSLTTemplate(), xsltBuildVariable(), xsltCallTemplate(), xsltChoose(), xsltComment(), xsltCompileAttr(), xsltCompilePatternInternal(), xsltComputeSortResultInternal(), xsltCopy(), xsltCopyOf(), xsltCopyText(), xsltCopyTextString(), xsltDebug(), xsltDefaultProcessOneNode(), xsltDocDefaultLoaderFunc(), xsltDocumentComp(), xsltDocumentElem(), xsltEvalAttrValueTemplate(), xsltEvalGlobalVariable(), xsltEvalGlobalVariables(), xsltEvalVariable(), xsltEvalXPathPredicate(), xsltEvalXPathStringNs(), xsltExtElementPreCompTest(), xsltExtElementTest(), xsltExtFunctionTest(), xsltExtInitTest(), xsltExtShutdownTest(), xsltExtStyleInitTest(), xsltExtStyleShutdownTest(), xsltFlagRVTs(), xsltForEach(), xsltFreeStylesheet(), xsltFreeTransformContext(), xsltGatherNamespaces(), xsltGetExtData(), xsltGetInheritedNsList(), xsltGetKey(), xsltGlobalVariableLookup(), xsltIf(), xsltInitCtxtExt(), xsltInitCtxtExts(), xsltInitCtxtKey(), xsltInitCtxtKeys(), xsltInitDocKeyTable(), xsltLoadStylesheetPI(), xsltNewStylesheetInternal(), xsltNewTransformContext(), xsltParseGlobalParam(), xsltParseGlobalVariable(), xsltParseStylesheetAttributeSet(), xsltParseStylesheetCallerParam(), xsltParseStylesheetExcludePrefix(), xsltParseStylesheetExtPrefix(), xsltParseStylesheetFile(), xsltParseStylesheetKey(), xsltParseStylesheetOutput(), xsltParseStylesheetParam(), xsltParseStylesheetPreserveSpace(), xsltParseStylesheetProcess(), xsltParseStylesheetStripSpace(), xsltParseStylesheetTemplate(), xsltParseStylesheetTop(), xsltParseStylesheetUser(), xsltParseStylesheetVariable(), xsltParseTemplateContent(), xsltPreprocessStylesheet(), xsltProcessingInstruction(), xsltProcessOneNode(), xsltProcessUserParamInternal(), xsltRegisterExtPrefix(), xsltRegisterGlobalVariable(), xsltRegisterVariable(), xsltResolveAttrSet(), xsltResolveStylesheetAttributeSet(), xsltSetGenericDebugFunc(), xsltShutdownCtxtExt(), xsltShutdownExt(), xsltStyleInitializeStylesheetModule(), xsltText(), xsltValueOf(), xsltVariableLookup(), xsltXPathFunctionLookup(), and xsltXPathVariableLookup().

◆ xsltGenericError

◆ xsltGenericErrorContext

◆ xsltSortFunction

xsltSortFunc xsltSortFunction = xsltDefaultSortFunction
static

Definition at line 1430 of file xsltutils.c.

Referenced by xsltDoSortFunction(), and xsltSetSortFunc().