ReactOS 0.4.16-dev-2207-geb15453
xsltutils.c
Go to the documentation of this file.
1/*
2 * xsltutils.c: Utilities for the XSL Transformation 1.0 engine
3 *
4 * Reference:
5 * http://www.w3.org/TR/1999/REC-xslt-19991116
6 *
7 * See Copyright for the status of this software.
8 *
9 * daniel@veillard.com
10 */
11
12#define IN_LIBXSLT
13#include "libxslt.h"
14
15#ifndef XSLT_NEED_TRIO
16#include <stdio.h>
17#else
18#include <trio.h>
19#endif
20
21#include <string.h>
22#include <stdlib.h>
23#include <stdarg.h>
24#include <time.h>
25
26#ifdef HAVE_SYS_TIME_H
27#include <sys/time.h>
28#endif
29#ifdef HAVE_UNISTD_H
30#include <unistd.h>
31#endif
32
33#include <libxml/xmlmemory.h>
34#include <libxml/tree.h>
35#include <libxml/HTMLtree.h>
36#include <libxml/xmlerror.h>
37#include <libxml/xmlIO.h>
38#include "xsltutils.h"
39#include "templates.h"
40#include "xsltInternals.h"
41#include "imports.h"
42#include "transform.h"
43
44#if defined(_WIN32)
45#include <windows.h>
46#define XSLT_WIN32_PERFORMANCE_COUNTER
47#endif
48
49/************************************************************************
50 * *
51 * Convenience function *
52 * *
53 ************************************************************************/
54
75const xmlChar *
77 const xmlChar *name, const xmlChar *nameSpace) {
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}
165xmlChar *
166xsltGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
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}
237
250int
251xsltGetUTF8Char(const unsigned char *utf, int *len) {
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}
307
318int
319xsltGetUTF8CharZ(const unsigned char *utf, int *len) {
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}
367
368#ifdef XSLT_REFACTORED
369
381int
382xsltPointerListAddSize(xsltPointerListPtr list,
383 void *item,
384 int initialSize)
385{
386 if (list->items == NULL) {
387 if (initialSize <= 0)
388 initialSize = 1;
389 list->items = (void **) xmlMalloc(
390 initialSize * sizeof(void *));
391 if (list->items == NULL) {
393 "xsltPointerListAddSize: memory allocation failure.\n");
394 return(-1);
395 }
396 list->number = 0;
397 list->size = initialSize;
398 } else if (list->size <= list->number) {
399 list->size *= 2;
400 list->items = (void **) xmlRealloc(list->items,
401 list->size * sizeof(void *));
402 if (list->items == NULL) {
404 "xsltPointerListAddSize: memory re-allocation failure.\n");
405 list->size = 0;
406 return(-1);
407 }
408 }
409 list->items[list->number++] = item;
410 return(0);
411}
412
421xsltPointerListPtr
422xsltPointerListCreate(int initialSize)
423{
424 xsltPointerListPtr ret;
425
426 ret = xmlMalloc(sizeof(xsltPointerList));
427 if (ret == NULL) {
429 "xsltPointerListCreate: memory allocation failure.\n");
430 return (NULL);
431 }
432 memset(ret, 0, sizeof(xsltPointerList));
433 if (initialSize > 0) {
434 xsltPointerListAddSize(ret, NULL, initialSize);
435 ret->number = 0;
436 }
437 return (ret);
438}
439
447void
448xsltPointerListFree(xsltPointerListPtr list)
449{
450 if (list == NULL)
451 return;
452 if (list->items != NULL)
453 xmlFree(list->items);
454 xmlFree(list);
455}
456
464void
465xsltPointerListClear(xsltPointerListPtr list)
466{
467 if (list->items != NULL) {
468 xmlFree(list->items);
469 list->items = NULL;
470 }
471 list->number = 0;
472 list->size = 0;
473}
474
475#endif /* XSLT_REFACTORED */
476
477/************************************************************************
478 * *
479 * Handling of XSLT stylesheets messages *
480 * *
481 ************************************************************************/
482
491void
492xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst) {
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}
530
531/************************************************************************
532 * *
533 * Handling of out of context errors *
534 * *
535 ************************************************************************/
536
537#define XSLT_GET_VAR_STR(msg, str) { \
538 int size; \
539 int chars; \
540 char *larger; \
541 va_list ap; \
542 \
543 str = (char *) xmlMalloc(150); \
544 if (str == NULL) \
545 return; \
546 \
547 size = 150; \
548 \
549 while (size < 64000) { \
550 va_start(ap, msg); \
551 chars = vsnprintf(str, size, msg, ap); \
552 va_end(ap); \
553 if ((chars > -1) && (chars < size)) \
554 break; \
555 if (chars > -1) \
556 size += chars + 1; \
557 else \
558 size += 100; \
559 if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
560 xmlFree(str); \
561 return; \
562 } \
563 str = larger; \
564 } \
565}
574static void LIBXSLT_ATTR_FORMAT(2,3)
575xsltGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
577
580
581 va_start(args, msg);
583 va_end(args);
584}
585
586xmlGenericErrorFunc xsltGenericError = xsltGenericErrorDefaultFunc;
588
589
603void
606 if (handler != NULL)
608 else
609 xsltGenericError = xsltGenericErrorDefaultFunc;
610}
611
620static void LIBXSLT_ATTR_FORMAT(2,3)
621xsltGenericDebugDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
623
625 return;
626
627 va_start(args, msg);
629 va_end(args);
630}
631
632xmlGenericErrorFunc xsltGenericDebug = xsltGenericDebugDefaultFunc;
634
635
649void
652 if (handler != NULL)
654 else
655 xsltGenericDebug = xsltGenericDebugDefaultFunc;
656}
657
666void
668 xsltStylesheetPtr style, xmlNodePtr node) {
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}
729
742void
745{
746 ctxt->error = handler;
747 ctxt->errctx = ctx;
748}
749
761void
764 xmlNodePtr node,
765 const char *msg, ...) {
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}
786
787/************************************************************************
788 * *
789 * QNames *
790 * *
791 ************************************************************************/
792
803const xmlChar *
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}
818
836const xmlChar *
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}
897
910const xmlChar *
912 const xmlChar **name) {
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}
972
973/************************************************************************
974 * *
975 * Sorting *
976 * *
977 ************************************************************************/
978
986void
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}
1009
1022static xmlXPathObjectPtr *
1024 int number, void *locale) {
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}
1149
1160xmlXPathObjectPtr *
1162 const xsltStylePreComp *comp = sort->psvi;
1163 int number = 0;
1164
1165 if (comp != NULL)
1166 number = comp->number;
1168 /* locale */ NULL);
1169}
1170
1180void
1182 int nbsorts) {
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}
1428
1429
1431
1446void
1448 int nbsorts)
1449{
1450 if (ctxt->sortfunc != NULL)
1451 (ctxt->sortfunc)(ctxt, sorts, nbsorts);
1452 else if (xsltSortFunction != NULL)
1453 xsltSortFunction(ctxt, sorts, nbsorts);
1454}
1455
1465void
1467 if (handler != NULL)
1469 else
1471}
1472
1485void
1487 ctxt->sortfunc = handler;
1488}
1489
1499void
1501 xsltNewLocaleFunc newLocale,
1502 xsltFreeLocaleFunc freeLocale,
1503 xsltGenSortKeyFunc genSortKey) {
1504 if (ctxt == NULL)
1505 return;
1506
1507 ctxt->newLocale = newLocale;
1508 ctxt->freeLocale = freeLocale;
1509 ctxt->genSortKey = genSortKey;
1510}
1511
1512/************************************************************************
1513 * *
1514 * Parsing options *
1515 * *
1516 ************************************************************************/
1517
1528int
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}
1545
1546/************************************************************************
1547 * *
1548 * Output *
1549 * *
1550 ************************************************************************/
1551
1563int
1564xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result,
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}
1726
1739int
1740xsltSaveResultToFilename(const char *URL, xmlDocPtr result,
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}
1769
1782int
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}
1812
1825int
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}
1854
1867int
1868xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len,
1869 xmlDocPtr result, xsltStylesheetPtr style) {
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}
1915
1922int
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}
1950
1960int
1962 int flags) {
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}
1988
1998int
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}
2022
2029void **
2030xsltGetPSVIPtr(xmlNodePtr cur) {
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}
2050
2051#ifdef WITH_PROFILER
2052
2053/************************************************************************
2054 * *
2055 * Generating profiling information *
2056 * *
2057 ************************************************************************/
2058
2059static long calibration = -1;
2060
2069#if !defined(XSLT_WIN32_PERFORMANCE_COUNTER) && \
2070 (defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETTIMEOFDAY))
2071static long
2072xsltCalibrateTimestamps(void) {
2073 register int i;
2074
2075 for (i = 0;i < 999;i++)
2076 xsltTimestamp();
2077 return(xsltTimestamp() / 1000);
2078}
2079#endif
2080
2087void
2088xsltCalibrateAdjust(long delta) {
2089 calibration += delta;
2090}
2091
2100long
2101xsltTimestamp(void)
2102{
2103#ifdef XSLT_WIN32_PERFORMANCE_COUNTER
2104 BOOL ok;
2105 LARGE_INTEGER performanceCount;
2106 LARGE_INTEGER performanceFrequency;
2107 LONGLONG quadCount;
2108 double seconds;
2109 static LONGLONG startupQuadCount = 0;
2110 static LONGLONG startupQuadFreq = 0;
2111
2112 ok = QueryPerformanceCounter(&performanceCount);
2113 if (!ok)
2114 return 0;
2115 quadCount = performanceCount.QuadPart;
2116 if (calibration < 0) {
2117 calibration = 0;
2118 ok = QueryPerformanceFrequency(&performanceFrequency);
2119 if (!ok)
2120 return 0;
2121 startupQuadFreq = performanceFrequency.QuadPart;
2122 startupQuadCount = quadCount;
2123 return (0);
2124 }
2125 if (startupQuadFreq == 0)
2126 return 0;
2127 seconds = (quadCount - startupQuadCount) / (double) startupQuadFreq;
2128 return (long) (seconds * XSLT_TIMESTAMP_TICS_PER_SEC);
2129
2130#else /* XSLT_WIN32_PERFORMANCE_COUNTER */
2131#ifdef HAVE_CLOCK_GETTIME
2132# if defined(CLOCK_MONOTONIC)
2133# define XSLT_CLOCK CLOCK_MONOTONIC
2134# elif defined(CLOCK_HIGHRES)
2135# define XSLT_CLOCK CLOCK_HIGHRES
2136# else
2137# define XSLT_CLOCK CLOCK_REALTIME
2138# endif
2139 static struct timespec startup;
2140 struct timespec cur;
2141 long tics;
2142
2143 if (calibration < 0) {
2144 clock_gettime(XSLT_CLOCK, &startup);
2145 calibration = 0;
2146 calibration = xsltCalibrateTimestamps();
2147 clock_gettime(XSLT_CLOCK, &startup);
2148 return (0);
2149 }
2150
2151 clock_gettime(XSLT_CLOCK, &cur);
2152 tics = (cur.tv_sec - startup.tv_sec) * XSLT_TIMESTAMP_TICS_PER_SEC;
2153 tics += (cur.tv_nsec - startup.tv_nsec) /
2154 (1000000000l / XSLT_TIMESTAMP_TICS_PER_SEC);
2155
2156 tics -= calibration;
2157 return(tics);
2158
2159#elif HAVE_GETTIMEOFDAY
2160 static struct timeval startup;
2161 struct timeval cur;
2162 long tics;
2163
2164 if (calibration < 0) {
2166 calibration = 0;
2167 calibration = xsltCalibrateTimestamps();
2169 return (0);
2170 }
2171
2173 tics = (cur.tv_sec - startup.tv_sec) * XSLT_TIMESTAMP_TICS_PER_SEC;
2174 tics += (cur.tv_usec - startup.tv_usec) /
2175 (1000000l / XSLT_TIMESTAMP_TICS_PER_SEC);
2176
2177 tics -= calibration;
2178 return(tics);
2179#else
2180
2181 /* Neither gettimeofday() nor Win32 performance counter available */
2182
2183 return (0);
2184
2185#endif /* HAVE_GETTIMEOFDAY */
2186#endif /* XSLT_WIN32_PERFORMANCE_COUNTER */
2187}
2188
2189static char *
2190pretty_templ_match(xsltTemplatePtr templ) {
2191 static char dst[1001];
2192 char *src = (char *)templ->match;
2193 int i=0,j;
2194
2195 /* strip white spaces */
2196 for (j=0; i<1000 && src[j]; i++,j++) {
2197 for(;src[j]==' ';j++);
2198 dst[i]=src[j];
2199 }
2200 if(i<998 && templ->mode) {
2201 /* append [mode] */
2202 dst[i++]='[';
2203 src=(char *)templ->mode;
2204 for (j=0; i<999 && src[j]; i++,j++) {
2205 dst[i]=src[j];
2206 }
2207 dst[i++]=']';
2208 }
2209 dst[i]='\0';
2210 return dst;
2211}
2212
2213#define MAX_TEMPLATES 10000
2214
2222void
2223xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
2224 int nb, i,j,k,l;
2225 int max;
2226 int total;
2227 unsigned long totalt;
2230 xsltTemplatePtr templ1,templ2;
2231 int *childt;
2232
2233 if ((output == NULL) || (ctxt == NULL))
2234 return;
2235 if (ctxt->profile == 0)
2236 return;
2237
2238 nb = 0;
2241 if (templates == NULL)
2242 return;
2243
2244 style = ctxt->style;
2245 while (style != NULL) {
2246 templ1 = style->templates;
2247 while (templ1 != NULL) {
2248 if (nb >= max)
2249 break;
2250
2251 if (templ1->nbCalls > 0)
2252 templates[nb++] = templ1;
2253 templ1 = templ1->next;
2254 }
2255
2257 }
2258
2259 for (i = 0;i < nb -1;i++) {
2260 for (j = i + 1; j < nb; j++) {
2261 if ((templates[i]->time <= templates[j]->time) ||
2262 ((templates[i]->time == templates[j]->time) &&
2263 (templates[i]->nbCalls <= templates[j]->nbCalls))) {
2264 templ1 = templates[j];
2265 templates[j] = templates[i];
2266 templates[i] = templ1;
2267 }
2268 }
2269 }
2270
2271
2272 /* print flat profile */
2273
2274 fprintf(output, "%6s%20s%20s%10s Calls Tot 100us Avg\n\n",
2275 "number", "match", "name", "mode");
2276 total = 0;
2277 totalt = 0;
2278 for (i = 0;i < nb;i++) {
2279 templ1 = templates[i];
2280 fprintf(output, "%5d ", i);
2281 if (templ1->match != NULL) {
2282 if (xmlStrlen(templ1->match) > 20)
2283 fprintf(output, "%s\n%26s", templ1->match, "");
2284 else
2285 fprintf(output, "%20s", templ1->match);
2286 } else {
2287 fprintf(output, "%20s", "");
2288 }
2289 if (templ1->name != NULL) {
2290 if (xmlStrlen(templ1->name) > 20)
2291 fprintf(output, "%s\n%46s", templ1->name, "");
2292 else
2293 fprintf(output, "%20s", templ1->name);
2294 } else {
2295 fprintf(output, "%20s", "");
2296 }
2297 if (templ1->mode != NULL) {
2298 if (xmlStrlen(templ1->mode) > 10)
2299 fprintf(output, "%s\n%56s", templ1->mode, "");
2300 else
2301 fprintf(output, "%10s", templ1->mode);
2302 } else {
2303 fprintf(output, "%10s", "");
2304 }
2305 fprintf(output, " %6d", templ1->nbCalls);
2306 fprintf(output, " %6ld %6ld\n", templ1->time,
2307 templ1->time / templ1->nbCalls);
2308 total += templ1->nbCalls;
2309 totalt += templ1->time;
2310 }
2311 fprintf(output, "\n%30s%26s %6d %6ld\n", "Total", "", total, totalt);
2312
2313
2314 /* print call graph */
2315
2316 childt = xmlMalloc((nb + 1) * sizeof(int));
2317 if (childt == NULL)
2318 return;
2319
2320 /* precalculate children times */
2321 for (i = 0; i < nb; i++) {
2322 templ1 = templates[i];
2323
2324 childt[i] = 0;
2325 for (k = 0; k < nb; k++) {
2326 templ2 = templates[k];
2327 for (l = 0; l < templ2->templNr; l++) {
2328 if (templ2->templCalledTab[l] == templ1) {
2329 childt[i] +=templ2->time;
2330 }
2331 }
2332 }
2333 }
2334 childt[i] = 0;
2335
2336 fprintf(output, "\nindex %% time self children called name\n");
2337
2338 for (i = 0; i < nb; i++) {
2339 char ix_str[20], timep_str[20], times_str[20], timec_str[20], called_str[20];
2340 unsigned long t;
2341
2342 templ1 = templates[i];
2343 /* callers */
2344 for (j = 0; j < templ1->templNr; j++) {
2345 templ2 = templ1->templCalledTab[j];
2346 for (k = 0; k < nb; k++) {
2347 if (templates[k] == templ2)
2348 break;
2349 }
2350 t=templ2?templ2->time:totalt;
2351 snprintf(times_str,sizeof(times_str),"%8.3f",(float)t/XSLT_TIMESTAMP_TICS_PER_SEC);
2352 snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
2353 snprintf(called_str,sizeof(called_str),"%6d/%d",
2354 templ1->templCountTab[j], /* number of times caller calls 'this' */
2355 templ1->nbCalls); /* total number of calls to 'this' */
2356
2357 fprintf(output, " %-8s %-8s %-12s %s [%d]\n",
2358 times_str,timec_str,called_str,
2359 (templ2?(templ2->name?(char *)templ2->name:pretty_templ_match(templ2)):"-"),k);
2360 }
2361 /* this */
2362 snprintf(ix_str,sizeof(ix_str),"[%d]",i);
2363 snprintf(timep_str,sizeof(timep_str),"%6.2f",(float)templ1->time*100.0/totalt);
2364 snprintf(times_str,sizeof(times_str),"%8.3f",(float)templ1->time/XSLT_TIMESTAMP_TICS_PER_SEC);
2365 snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[i]/XSLT_TIMESTAMP_TICS_PER_SEC);
2366 fprintf(output, "%-5s %-6s %-8s %-8s %6d %s [%d]\n",
2367 ix_str, timep_str,times_str,timec_str,
2368 templ1->nbCalls,
2369 templ1->name?(char *)templ1->name:pretty_templ_match(templ1),i);
2370 /* callees
2371 * - go over templates[0..nb] and their templCalledTab[]
2372 * - print those where we in the the call-stack
2373 */
2374 total = 0;
2375 for (k = 0; k < nb; k++) {
2376 templ2 = templates[k];
2377 for (l = 0; l < templ2->templNr; l++) {
2378 if (templ2->templCalledTab[l] == templ1) {
2379 total+=templ2->templCountTab[l];
2380 }
2381 }
2382 }
2383 for (k = 0; k < nb; k++) {
2384 templ2 = templates[k];
2385 for (l = 0; l < templ2->templNr; l++) {
2386 if (templ2->templCalledTab[l] == templ1) {
2387 snprintf(times_str,sizeof(times_str),"%8.3f",(float)templ2->time/XSLT_TIMESTAMP_TICS_PER_SEC);
2388 snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
2389 snprintf(called_str,sizeof(called_str),"%6d/%d",
2390 templ2->templCountTab[l], /* number of times 'this' calls callee */
2391 total); /* total number of calls from 'this' */
2392 fprintf(output, " %-8s %-8s %-12s %s [%d]\n",
2393 times_str,timec_str,called_str,
2394 templ2->name?(char *)templ2->name:pretty_templ_match(templ2),k);
2395 }
2396 }
2397 }
2398 fprintf(output, "-----------------------------------------------\n");
2399 }
2400
2401 fprintf(output, "\f\nIndex by function name\n");
2402 for (i = 0; i < nb; i++) {
2403 templ1 = templates[i];
2404 fprintf(output, "[%d] %s (%s:%d)\n",
2405 i, templ1->name?(char *)templ1->name:pretty_templ_match(templ1),
2406 templ1->style->doc->URL,templ1->elem->line);
2407 }
2408
2409 fprintf(output, "\f\n");
2410 xmlFree(childt);
2411
2413}
2414
2415/************************************************************************
2416 * *
2417 * Fetching profiling information *
2418 * *
2419 ************************************************************************/
2420
2442xmlDocPtr
2443xsltGetProfileInformation(xsltTransformContextPtr ctxt)
2444{
2445 xmlDocPtr ret = NULL;
2446 xmlNodePtr root, child;
2447 char buf[100];
2448
2451 xsltTemplatePtr templ;
2452 int nb = 0, max = 0, i, j;
2453
2454 if (!ctxt)
2455 return NULL;
2456
2457 if (!ctxt->profile)
2458 return NULL;
2459
2460 nb = 0;
2461 max = 10000;
2462 templates =
2464 if (templates == NULL)
2465 return NULL;
2466
2467 /*
2468 * collect all the templates in an array
2469 */
2470 style = ctxt->style;
2471 while (style != NULL) {
2472 templ = style->templates;
2473 while (templ != NULL) {
2474 if (nb >= max)
2475 break;
2476
2477 if (templ->nbCalls > 0)
2478 templates[nb++] = templ;
2479 templ = templ->next;
2480 }
2481
2483 }
2484
2485 /*
2486 * Sort the array by time spent
2487 */
2488 for (i = 0; i < nb - 1; i++) {
2489 for (j = i + 1; j < nb; j++) {
2490 if ((templates[i]->time <= templates[j]->time) ||
2491 ((templates[i]->time == templates[j]->time) &&
2492 (templates[i]->nbCalls <= templates[j]->nbCalls))) {
2493 templ = templates[j];
2494 templates[j] = templates[i];
2495 templates[i] = templ;
2496 }
2497 }
2498 }
2499
2500 /*
2501 * Generate a document corresponding to the results.
2502 */
2503 ret = xmlNewDoc(BAD_CAST "1.0");
2504 root = xmlNewDocNode(ret, NULL, BAD_CAST "profile", NULL);
2505 xmlDocSetRootElement(ret, root);
2506
2507 for (i = 0; i < nb; i++) {
2508 child = xmlNewChild(root, NULL, BAD_CAST "template", NULL);
2509 snprintf(buf, sizeof(buf), "%d", i + 1);
2510 xmlSetProp(child, BAD_CAST "rank", BAD_CAST buf);
2511 xmlSetProp(child, BAD_CAST "match", BAD_CAST templates[i]->match);
2512 xmlSetProp(child, BAD_CAST "name", BAD_CAST templates[i]->name);
2513 xmlSetProp(child, BAD_CAST "mode", BAD_CAST templates[i]->mode);
2514
2515 snprintf(buf, sizeof(buf), "%d", templates[i]->nbCalls);
2516 xmlSetProp(child, BAD_CAST "calls", BAD_CAST buf);
2517
2518 snprintf(buf, sizeof(buf), "%ld", templates[i]->time);
2519 xmlSetProp(child, BAD_CAST "time", BAD_CAST buf);
2520
2521 snprintf(buf, sizeof(buf), "%ld", templates[i]->time / templates[i]->nbCalls);
2522 xmlSetProp(child, BAD_CAST "average", BAD_CAST buf);
2523 };
2524
2526
2527 return ret;
2528}
2529
2530#endif /* WITH_PROFILER */
2531
2532/************************************************************************
2533 * *
2534 * Hooks for libxml2 XPath *
2535 * *
2536 ************************************************************************/
2537
2549xmlXPathCompExprPtr
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}
2581
2592xmlXPathCompExprPtr
2594 return(xsltXPathCompileFlags(style, str, 0));
2595}
2596
2597/************************************************************************
2598 * *
2599 * Hooks for the debugger *
2600 * *
2601 ************************************************************************/
2602
2604
2612int
2614{
2615 return(xslDebugStatus);
2616}
2617
2618#ifdef WITH_DEBUGGER
2619
2620/*
2621 * There is currently only 3 debugging callback defined
2622 * Debugger callbacks are disabled by default
2623 */
2624#define XSLT_CALLBACK_NUMBER 3
2625
2626typedef struct _xsltDebuggerCallbacks xsltDebuggerCallbacks;
2627typedef xsltDebuggerCallbacks *xsltDebuggerCallbacksPtr;
2628struct _xsltDebuggerCallbacks {
2632};
2633
2634static xsltDebuggerCallbacks xsltDebuggerCurrentCallbacks = {
2635 NULL, /* handler */
2636 NULL, /* add */
2637 NULL /* drop */
2638};
2639
2646void
2647xsltSetDebuggerStatus(int value)
2648{
2650}
2651
2663int
2664xsltSetDebuggerCallbacks(int no, void *block)
2665{
2666 xsltDebuggerCallbacksPtr callbacks;
2667
2668 if ((block == NULL) || (no != XSLT_CALLBACK_NUMBER))
2669 return(-1);
2670
2671 callbacks = (xsltDebuggerCallbacksPtr) block;
2672 xsltDebuggerCurrentCallbacks.handler = callbacks->handler;
2673 xsltDebuggerCurrentCallbacks.add = callbacks->add;
2674 xsltDebuggerCurrentCallbacks.drop = callbacks->drop;
2675 return(0);
2676}
2677
2689void
2690xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ,
2692{
2693 if (xsltDebuggerCurrentCallbacks.handler != NULL)
2694 xsltDebuggerCurrentCallbacks.handler(cur, node, templ, ctxt);
2695}
2696
2706int
2707xslAddCall(xsltTemplatePtr templ, xmlNodePtr source)
2708{
2709 if (xsltDebuggerCurrentCallbacks.add != NULL)
2710 return(xsltDebuggerCurrentCallbacks.add(templ, source));
2711 return(0);
2712}
2713
2719void
2720xslDropCall(void)
2721{
2722 if (xsltDebuggerCurrentCallbacks.drop != NULL)
2723 xsltDebuggerCurrentCallbacks.drop();
2724}
2725
2726#endif /* WITH_DEBUGGER */
static struct _test_info results[8]
Definition: SetCursorPos.c:31
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
static void startup(void)
Arabic default style
Definition: afstyles.h:94
#define MAX_TEMPLATES
Definition: appearance.h:29
#define ok(value,...)
Definition: atltest.h:57
#define msg(x)
Definition: auth_time.c:54
const char * stype[]
Definition: cmds.c:192
struct _root root
_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
xmlChar * xmlBufContent(const xmlBuf *buf)
Definition: buf.c:490
size_t xmlBufUse(const xmlBufPtr buf)
Definition: buf.c:570
r l[0]
Definition: byte_order.h:168
Definition: list.h:37
size_type size() const
Definition: _list.h:379
Definition: _locale.h:75
#define NULL
Definition: types.h:112
static const WCHAR indent[]
Definition: object.c:1156
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
static void cleanup(void)
Definition: main.c:1335
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
static struct @508 sort
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
void CDECL terminate(void)
Definition: cpp.c:698
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
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
char * va_list
Definition: vadefs.h:50
method
Definition: dragdrop.c:54
return ret
Definition: mutex.c:146
const char * xmlGetCharEncodingName(xmlCharEncoding enc)
Definition: encoding.c:1229
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1677
xmlCharEncoding
Definition: encoding.h:65
@ XML_CHAR_ENCODING_UTF8
Definition: encoding.h:68
XMLPUBFUN int xmlCharEncCloseFunc(xmlCharEncodingHandler *handler)
unsigned int BOOL
Definition: ntddk_ex.h:94
FxCollectionEntry * cur
size_t total
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble t
Definition: gl.h:2047
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
const GLubyte * c
Definition: glext.h:8905
GLenum mode
Definition: glext.h:6217
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLuint64EXT * result
Definition: glext.h:11304
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
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
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
#define ATTRIBUTE_UNUSED
Definition: i386-dis.c:36
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:297
#define c
Definition: ke_i.h:80
char templates[]
Definition: meshbuilder.c:39
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
#define for
Definition: utility.h:88
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
static unsigned int number
Definition: dsound.c:1479
static HWND child
Definition: cursoricon.c:298
int k
Definition: mpi.c:3369
__forceinline bool __cdecl add(big_integer &x, uint32_t const value)
#define XSLT_GET_IMPORT_INT(res, style, name)
Definition: node.c:1079
#define XSLT_GET_IMPORT_PTR(res, style, name)
Definition: node.c:1070
const WCHAR * str
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
xmlReallocFunc xmlRealloc
Definition: globals.c:214
xmlFreeFunc xmlFree
Definition: globals.c:184
xmlMallocFunc xmlMalloc
Definition: globals.c:193
@ XML_PARSE_XINCLUDE
Definition: parser.h:1240
static int fd
Definition: io.c:51
#define memset(x, y, z)
Definition: compat.h:39
#define args
Definition: format.c:66
Definition: dict.c:59
xmlNodePtr elem
struct _xsltTemplate * next
const xmlChar * name
const xmlChar * mode
unsigned long time
struct _xsltStylesheet * style
xsltTemplatePtr * templCalledTab
xmlChar * match
xsltTransformState state
xsltNewLocaleFunc newLocale
xmlNodeSetPtr nodeList
xsltGenSortKeyFunc genSortKey
xsltFreeLocaleFunc freeLocale
xsltStylesheetPtr style
xmlGenericErrorFunc error
xmlXPathContextPtr xpathCtxt
Definition: match.c:390
Definition: fci.c:127
Definition: parser.c:49
Definition: match.c:28
Definition: tftpd.h:60
Definition: name.c:39
Definition: mxnamespace.c:38
Definition: time.h:53
#define max(a, b)
Definition: svc.c:63
xmlChar * xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns)
Definition: templates.c:410
xmlChar * xsltEvalTemplateString(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst)
Definition: templates.c:207
Character const *const prefix
Definition: tempnam.cpp:195
XSLTPUBFUN void XSLTCALL xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
int64_t LONGLONG
Definition: typedefs.h:68
LONGLONG QuadPart
Definition: typedefs.h:114
Definition: dlist.c:348
Definition: pdh_main.c:96
XMLPUBFUN xmlAttributePtr xmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name)
Definition: valid.c:3230
static const WCHAR lang[]
Definition: wbemdisp.c:287
#define snprintf
Definition: wintirpc.h:48
void(* xmlGenericErrorFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
Definition: xmlerror.h:848
static unsigned int block
Definition: xmlmemory.c:101
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:45
XMLPUBFUN int xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:428
XMLPUBFUN int xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:277
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
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69
xmlChar *(* xsltGenSortKeyFunc)(void *locale, const xmlChar *lang)
void(* xsltSortFunc)(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
void *(* xsltNewLocaleFunc)(const xmlChar *lang, int lowerFirst)
xsltStylesheet * xsltStylesheetPtr
@ XSLT_STATE_ERROR
@ XSLT_STATE_STOPPED
@ XSLT_STATE_OK
#define XSLT_MAX_SORT
void(* xsltFreeLocaleFunc)(void *locale)
#define LIBXSLT_ATTR_FORMAT(fmt, args)
Definition: xsltconfig.h:159
void xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
Definition: xsltutils.c:1447
const xmlChar * xsltGetQNameURI(xmlNodePtr node, xmlChar **name)
Definition: xsltutils.c:837
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762
xmlXPathCompExprPtr xsltXPathCompileFlags(xsltStylesheetPtr style, const xmlChar *str, int flags)
Definition: xsltutils.c:2550
xmlXPathObjectPtr * xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort)
Definition: xsltutils.c:1161
static xmlXPathObjectPtr * xsltComputeSortResultInternal(xsltTransformContextPtr ctxt, xmlNodePtr sort, int number, void *locale)
Definition: xsltutils.c:1023
int xsltGetDebuggerStatus(void)
Definition: xsltutils.c:2613
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:586
void xsltDocumentSortFunction(xmlNodeSetPtr list)
Definition: xsltutils.c:987
void xsltSetGenericDebugFunc(void *ctx, xmlGenericErrorFunc handler)
Definition: xsltutils.c:650
const xmlChar * xsltGetCNsProp(xsltStylesheetPtr style, xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace)
Definition: xsltutils.c:76
int xsltSetSourceNodeFlags(xsltTransformContextPtr ctxt, xmlNodePtr node, int flags)
Definition: xsltutils.c:1961
static xsltSortFunc xsltSortFunction
Definition: xsltutils.c:1430
int xsltSaveResultToFd(int fd, xmlDocPtr result, xsltStylesheetPtr style)
Definition: xsltutils.c:1826
int xsltClearSourceNodeFlags(xmlNodePtr node, int flags)
Definition: xsltutils.c:1999
xmlXPathCompExprPtr xsltXPathCompile(xsltStylesheetPtr style, const xmlChar *str)
Definition: xsltutils.c:2593
int xsltGetSourceNodeFlags(xmlNodePtr node)
Definition: xsltutils.c:1923
int xsltSetCtxtParseOptions(xsltTransformContextPtr ctxt, int options)
Definition: xsltutils.c:1529
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
#define XSLT_GET_VAR_STR(msg, str)
Definition: xsltutils.c:537
int xsltGetUTF8Char(const unsigned char *utf, int *len)
Definition: xsltutils.c:251
void xsltSetCtxtLocaleHandlers(xsltTransformContextPtr ctxt, xsltNewLocaleFunc newLocale, xsltFreeLocaleFunc freeLocale, xsltGenSortKeyFunc genSortKey)
Definition: xsltutils.c:1500
void xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts)
Definition: xsltutils.c:1181
void ** xsltGetPSVIPtr(xmlNodePtr cur)
Definition: xsltutils.c:2030
const xmlChar * xsltGetQNameURI2(xsltStylesheetPtr style, xmlNodePtr node, const xmlChar **name)
Definition: xsltutils.c:911
void xsltSetTransformErrorFunc(xsltTransformContextPtr ctxt, void *ctx, xmlGenericErrorFunc handler)
Definition: xsltutils.c:743
void xsltPrintErrorContext(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node)
Definition: xsltutils.c:667
int xsltSaveResultToString(xmlChar **doc_txt_ptr, int *doc_txt_len, xmlDocPtr result, xsltStylesheetPtr style)
Definition: xsltutils.c:1868
int xsltGetUTF8CharZ(const unsigned char *utf, int *len)
Definition: xsltutils.c:319
int xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result, xsltStylesheetPtr style)
Definition: xsltutils.c:1564
int xsltSaveResultToFilename(const char *URL, xmlDocPtr result, xsltStylesheetPtr style, int compression)
Definition: xsltutils.c:1740
void xsltSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler)
Definition: xsltutils.c:604
int xslDebugStatus
Definition: xsltutils.c:2603
void * xsltGenericDebugContext
Definition: xsltutils.c:633
void xsltSetCtxtSortFunc(xsltTransformContextPtr ctxt, xsltSortFunc handler)
Definition: xsltutils.c:1486
void * xsltGenericErrorContext
Definition: xsltutils.c:587
const xmlChar * xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
Definition: xsltutils.c:804
void xsltSetSortFunc(xsltSortFunc handler)
Definition: xsltutils.c:1466
int xsltSaveResultToFile(FILE *file, xmlDocPtr result, xsltStylesheetPtr style)
Definition: xsltutils.c:1783
xmlChar * xsltGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace)
Definition: xsltutils.c:166
void xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst)
Definition: xsltutils.c:492
int(* xsltAddCallCallback)(xsltTemplatePtr templ, xmlNodePtr source)
Definition: xsltutils.h:320
void(* xsltHandleDebuggerCallback)(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
Definition: xsltutils.h:318
void(* xsltDropCallCallback)(void)
Definition: xsltutils.h:321
#define XSLT_TIMESTAMP_TICS_PER_SEC
Definition: xsltutils.h:297
#define const
Definition: zconf.h:233