18#define WITH_XSLT_DEBUG_FUNCTION
26#define DOCBOOK_XSL_HACK
42 xmlXPathContextPtr ctxt = (xmlXPathContextPtr) vctxt;
48#ifdef WITH_XSLT_DEBUG_FUNCTION
50 "Lookup function {%s}%s\n", ns_uri,
name);
62#ifdef WITH_XSLT_DEBUG_FUNCTION
65 "found function %s\n",
name);
85 xmlXPathContextPtr xptrctxt =
NULL;
86 xmlXPathObjectPtr resObj =
NULL;
91 "document() : internal error tctxt == NULL\n");
92 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
99 "document() : failed to parse URI\n");
100 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
129 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
131 if (fragment !=
NULL)
139 if (fragment ==
NULL) {
140 valuePush(ctxt, xmlXPathNewNodeSet((
xmlNodePtr) doc));
145#ifdef LIBXML_XPTR_ENABLED
146 xptrctxt = xmlXPtrNewContext(doc,
NULL,
NULL);
147 if (xptrctxt ==
NULL) {
149 "document() : internal error xptrctxt == NULL\n");
153#if LIBXML_VERSION >= 20911 || \
154 defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
155 xptrctxt->opLimit = ctxt->context->opLimit;
156 xptrctxt->opCount = ctxt->context->opCount;
157 xptrctxt->depth = ctxt->context->depth;
159 resObj = xmlXPtrEval(fragment, xptrctxt);
161 ctxt->context->opCount = xptrctxt->opCount;
163 resObj = xmlXPtrEval(fragment, xptrctxt);
166 xmlXPathFreeContext(xptrctxt);
169 if ((resObj !=
NULL) && (resObj->type != XPATH_NODESET)) {
171 "document() : XPointer does not select a node set: #%s\n",
173 xmlXPathFreeObject(resObj);
179 resObj = xmlXPathNewNodeSet(
NULL);
180 valuePush(ctxt, resObj);
195 xmlXPathObjectPtr
obj, obj2 =
NULL;
199 if ((nargs < 1) || (nargs > 2)) {
201 "document() : invalid number of args %d\n",
203 ctxt->error = XPATH_INVALID_ARITY;
206 if (ctxt->value ==
NULL) {
208 "document() : invalid arg value\n");
209 ctxt->error = XPATH_INVALID_TYPE;
214 if (ctxt->value->type != XPATH_NODESET) {
216 "document() : invalid arg expecting a nodeset\n");
217 ctxt->error = XPATH_INVALID_TYPE;
221 obj2 = valuePop(ctxt);
224 if (ctxt->value->type == XPATH_NODESET) {
226 xmlXPathObjectPtr newobj,
ret;
228 obj = valuePop(ctxt);
229 ret = xmlXPathNewNodeSet(
NULL);
232 for (
i = 0;
i <
obj->nodesetval->nodeNr;
i++) {
234 xmlXPathNewNodeSet(
obj->nodesetval->nodeTab[
i]));
235 xmlXPathStringFunction(ctxt, 1);
237 valuePush(ctxt, xmlXPathObjectCopy(obj2));
240 xmlXPathNewNodeSet(
obj->nodesetval->
244 newobj = valuePop(ctxt);
245 ret->nodesetval = xmlXPathNodeSetMerge(
ret->nodesetval,
247 xmlXPathFreeObject(newobj);
252 xmlXPathFreeObject(
obj);
254 xmlXPathFreeObject(obj2);
255 valuePush(ctxt,
ret);
261 xmlXPathStringFunction(ctxt, 1);
262 if (ctxt->value->type != XPATH_STRING) {
264 "document() : invalid arg expecting a string\n");
265 ctxt->error = XPATH_INVALID_TYPE;
267 xmlXPathFreeObject(obj2);
270 obj = valuePop(ctxt);
272 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
276 if ((obj2 !=
NULL) && (obj2->nodesetval !=
NULL) &&
277 (obj2->nodesetval->nodeNr > 0) &&
281 target = obj2->nodesetval->nodeTab[0];
306 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
313 xmlXPathFreeObject(
obj);
315 xmlXPathFreeObject(obj2);
328 xmlXPathObjectPtr obj1, obj2;
332 "key() : expects two arguments\n");
333 ctxt->error = XPATH_INVALID_ARITY;
340 obj2 = valuePop(ctxt);
341 xmlXPathStringFunction(ctxt, 1);
342 if ((obj2 ==
NULL) ||
343 (ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
345 "key() : invalid arg expecting a string\n");
346 ctxt->error = XPATH_INVALID_TYPE;
347 xmlXPathFreeObject(obj2);
354 obj1 = valuePop(ctxt);
356 if ((obj2->type == XPATH_NODESET) || (obj2->type == XPATH_XSLT_TREE)) {
358 xmlXPathObjectPtr newobj,
ret;
360 ret = xmlXPathNewNodeSet(
NULL);
362 if (obj2->nodesetval !=
NULL) {
363 for (
i = 0;
i < obj2->nodesetval->nodeNr;
i++) {
364 valuePush(ctxt, xmlXPathObjectCopy(obj1));
366 xmlXPathNewNodeSet(obj2->nodesetval->nodeTab[
i]));
367 xmlXPathStringFunction(ctxt, 1);
369 newobj = valuePop(ctxt);
370 ret->nodesetval = xmlXPathNodeSetMerge(
ret->nodesetval,
372 xmlXPathFreeObject(newobj);
375 valuePush(ctxt,
ret);
377 xmlNodeSetPtr nodelist =
NULL;
382 xmlXPathContextPtr xpctxt = ctxt->context;
390 if (xpctxt->node ==
NULL) {
392 "Internal error in xsltKeyFunction(): "
393 "The context node is not set on the XPath context.\n");
400 qname = obj1->stringval;
408 if (prefix !=
NULL) {
409 keyURI = xmlXPathNsLookup(xpctxt, prefix);
410 if (keyURI ==
NULL) {
412 "key() : prefix %s is not bound\n", prefix);
426 valuePush(ctxt, obj2);
427 xmlXPathStringFunction(ctxt, 1);
428 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
430 "key() : invalid arg expecting a string\n");
431 ctxt->error = XPATH_INVALID_TYPE;
434 obj2 = valuePop(ctxt);
435 value = obj2->stringval;
459 tmpNode = xpctxt->node;
463 "Internal error in xsltKeyFunction(): "
464 "Couldn't get the doc of the XPath context node.\n");
471 if (tmpNode->
doc->name && (tmpNode->
doc->name[0] ==
' ')) {
475 if (tmpNode->
doc->_private ==
NULL) {
477 if (tmpNode->
doc->_private ==
NULL)
490 "Internal error in xsltKeyFunction(): "
491 "Could not get the document info of a context doc.\n");
503 valuePush(ctxt, xmlXPathWrapNodeSet(
504 xmlXPathNodeSetMerge(
NULL, nodelist)));
510 xmlXPathFreeObject(obj1);
512 xmlXPathFreeObject(obj2);
525 xmlXPathObjectPtr
obj;
528 if ((nargs != 1) || (ctxt->value ==
NULL)) {
530 "unparsed-entity-uri() : expects one string arg\n");
531 ctxt->error = XPATH_INVALID_ARITY;
534 obj = valuePop(ctxt);
535 if (
obj->type != XPATH_STRING) {
536 obj = xmlXPathConvertString(
obj);
541 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
547 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
550 valuePush(ctxt, xmlXPathNewString(
entity->URI));
552 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
555 xmlXPathFreeObject(
obj);
569 xmlXPathObjectPtr numberObj =
NULL;
570 xmlXPathObjectPtr formatObj =
NULL;
571 xmlXPathObjectPtr decimalObj =
NULL;
583 sheet = tctxt->
style;
590 if ((ctxt->value !=
NULL) && (ctxt->value->type != XPATH_STRING))
591 xmlXPathStringFunction(ctxt, 1);
592 decimalObj = valuePop(ctxt);
594 if (prefix !=
NULL) {
598 "format-number : No namespace found for QName '%s:%s'\n",
607 if (ncname !=
NULL) {
610 if (formatValues ==
NULL) {
612 "format-number() : undeclared decimal format '%s'\n",
613 decimalObj->stringval);
617 if ((ctxt->value !=
NULL) && (ctxt->value->type != XPATH_STRING))
618 xmlXPathStringFunction(ctxt, 1);
619 formatObj = valuePop(ctxt);
620 if ((ctxt->value !=
NULL) && (ctxt->value->type != XPATH_NUMBER))
621 xmlXPathNumberFunction(ctxt, 1);
622 numberObj = valuePop(ctxt);
625 xmlXPathErr(ctxt, XPATH_INVALID_ARITY);
629 if (formatValues !=
NULL) {
631 formatObj->stringval,
633 &
result) == XPATH_EXPRESSION_OK) {
634 valuePush(ctxt, xmlXPathNewString(
result));
639 xmlXPathFreeObject(numberObj);
640 xmlXPathFreeObject(formatObj);
641 xmlXPathFreeObject(decimalObj);
654 static char base_address;
661 cur = ctxt->context->node;
662 }
else if (nargs == 1) {
663 xmlNodeSetPtr nodelist;
666 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_NODESET)) {
667 ctxt->error = XPATH_INVALID_TYPE;
669 "generate-id() : invalid arg expecting a node-set\n");
672 obj = valuePop(ctxt);
673 nodelist =
obj->nodesetval;
674 if ((nodelist ==
NULL) || (nodelist->nodeNr <= 0)) {
675 xmlXPathFreeObject(
obj);
676 valuePush(ctxt, xmlXPathNewCString(
""));
679 cur = nodelist->nodeTab[0];
680 for (
i = 1;
i < nodelist->nodeNr;
i++) {
681 ret = xmlXPathCmpNodes(
cur, nodelist->nodeTab[
i]);
683 cur = nodelist->nodeTab[
i];
687 "generate-id() : invalid number of args %d\n", nargs);
688 ctxt->error = XPATH_INVALID_ARITY;
693 xmlXPathFreeObject(
obj);
695 val = (
long)((
char *)
cur - (
char *)&base_address);
701 valuePush(ctxt, xmlXPathNewString(
str));
714 xmlXPathObjectPtr
obj;
720 "system-property() : expects one string arg\n");
721 ctxt->error = XPATH_INVALID_ARITY;
724 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
726 "system-property() : invalid arg expecting a string\n");
727 ctxt->error = XPATH_INVALID_TYPE;
730 obj = valuePop(ctxt);
732 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
738 nsURI = xmlXPathNsLookup(ctxt->context, prefix);
741 "system-property() : prefix %s is not bound\n", prefix);
746#ifdef DOCBOOK_XSL_HACK
757 sheet = tctxt->
style;
764 valuePush(ctxt, xmlXPathNewString(
765 (
const xmlChar *)
"libxslt (SAXON 6.2 compatible)"));
768 valuePush(ctxt, xmlXPathNewString(
774 valuePush(ctxt, xmlXPathNewString(
779 valuePush(ctxt, xmlXPathNewString(
782 valuePush(ctxt, xmlXPathNewString(
785 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
788 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
795 xmlXPathFreeObject(
obj);
808 xmlXPathObjectPtr
obj;
815 "element-available() : expects one string arg\n");
816 ctxt->error = XPATH_INVALID_ARITY;
819 xmlXPathStringFunction(ctxt, 1);
820 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
822 "element-available() : invalid arg expecting a string\n");
823 ctxt->error = XPATH_INVALID_TYPE;
826 obj = valuePop(ctxt);
830 "element-available() : internal error tctxt == NULL\n");
831 xmlXPathFreeObject(
obj);
832 valuePush(ctxt, xmlXPathNewBoolean(0));
845 nsURI = xmlXPathNsLookup(ctxt->context, prefix);
848 "element-available() : prefix %s is not bound\n", prefix);
853 valuePush(ctxt, xmlXPathNewBoolean(1));
855 valuePush(ctxt, xmlXPathNewBoolean(0));
858 xmlXPathFreeObject(
obj);
875 xmlXPathObjectPtr
obj;
881 "function-available() : expects one string arg\n");
882 ctxt->error = XPATH_INVALID_ARITY;
885 xmlXPathStringFunction(ctxt, 1);
886 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
888 "function-available() : invalid arg expecting a string\n");
889 ctxt->error = XPATH_INVALID_TYPE;
892 obj = valuePop(ctxt);
898 nsURI = xmlXPathNsLookup(ctxt->context, prefix);
901 "function-available() : prefix %s is not bound\n", prefix);
905 if (xmlXPathFunctionLookupNS(ctxt->context,
name, nsURI) !=
NULL) {
906 valuePush(ctxt, xmlXPathNewBoolean(1));
908 valuePush(ctxt, xmlXPathNewBoolean(0));
911 xmlXPathFreeObject(
obj);
932 "current() : function uses no argument\n");
933 ctxt->error = XPATH_INVALID_ARITY;
939 "current() : internal error tctxt == NULL\n");
940 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
942 valuePush(ctxt, xmlXPathNewNodeSet(tctxt->
node));
961 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"current",
963 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"document",
966 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"unparsed-entity-uri",
968 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"format-number",
970 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"generate-id",
972 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"system-property",
974 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"element-available",
976 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"function-available",
xsltTransformContextPtr xsltXPathGetTransformContext(xmlXPathParserContextPtr ctxt)
xmlXPathFunction xsltExtModuleFunctionLookup(const xmlChar *name, const xmlChar *URI)
xsltTransformFunction xsltExtElementLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *URI)
xmlXPathError xsltFormatNumberConversion(xsltDecimalFormatPtr self, xmlChar *format, double number, xmlChar **result)
xsltDocumentPtr xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc)
xsltDocumentPtr xsltFindDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc)
xsltDocumentPtr xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI)
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name)
void xsltSystemPropertyFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltRegisterAllFunctions(xmlXPathContextPtr ctxt)
void xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
xmlXPathFunction xsltXPathFunctionLookup(void *vctxt, const xmlChar *name, const xmlChar *ns_uri)
void xsltElementAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltUnparsedEntityURIFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltFunctionAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs)
static void xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar *URI)
static void xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs)
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
xmlNodeSetPtr xsltGetKey(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI, const xmlChar *value)
static unsigned __int64 next
XMLPUBVAR xmlFreeFunc xmlFree
#define XML_CAST_FPTR(fptr)
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName2(const xmlChar *name, xmlChar **prefix)
xsltDecimalFormatPtr decimalFormat
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
XMLPUBFUN xmlChar *XMLCALL xmlSaveUri(xmlURIPtr uri)
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
XMLPUBFUN const xmlChar *XMLCALL xmlStrstr(const xmlChar *str, const xmlChar *val)
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
xsltDocument * xsltDocumentPtr
xsltDecimalFormatPtr xsltDecimalFormatGetByQName(xsltStylesheetPtr style, const xmlChar *nsUri, const xmlChar *name)
#define XSLT_DEFAULT_VENDOR
#define XSLT_DEFAULT_VERSION
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
xmlGenericErrorFunc xsltGenericError
xmlGenericErrorFunc xsltGenericDebug
void * xsltGenericDebugContext
void * xsltGenericErrorContext
const xmlChar * xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
#define IS_XSLT_REAL_NODE(n)