17 #ifdef WITH_XSLT_DEBUG 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 resObj = xmlXPtrEval(fragment, xptrctxt);
154 xmlXPathFreeContext(xptrctxt);
160 switch (resObj->type) {
163 case XPATH_UNDEFINED:
169 case XPATH_XSLT_TREE:
171 case XPATH_LOCATIONSET:
173 "document() : XPointer does not select a node set: #%s\n",
178 valuePush(ctxt, resObj);
183 xmlXPathFreeObject(resObj);
186 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
201 xmlXPathObjectPtr
obj, obj2 =
NULL;
205 if ((nargs < 1) || (nargs > 2)) {
207 "document() : invalid number of args %d\n",
209 ctxt->error = XPATH_INVALID_ARITY;
212 if (ctxt->value ==
NULL) {
214 "document() : invalid arg value\n");
215 ctxt->error = XPATH_INVALID_TYPE;
220 if (ctxt->value->type != XPATH_NODESET) {
222 "document() : invalid arg expecting a nodeset\n");
223 ctxt->error = XPATH_INVALID_TYPE;
227 obj2 = valuePop(ctxt);
230 if (ctxt->value->type == XPATH_NODESET) {
232 xmlXPathObjectPtr newobj,
ret;
234 obj = valuePop(ctxt);
235 ret = xmlXPathNewNodeSet(
NULL);
238 for (
i = 0;
i <
obj->nodesetval->nodeNr;
i++) {
240 xmlXPathNewNodeSet(
obj->nodesetval->nodeTab[
i]));
241 xmlXPathStringFunction(ctxt, 1);
243 valuePush(ctxt, xmlXPathObjectCopy(obj2));
246 xmlXPathNewNodeSet(
obj->nodesetval->
250 newobj = valuePop(ctxt);
251 ret->nodesetval = xmlXPathNodeSetMerge(
ret->nodesetval,
253 xmlXPathFreeObject(newobj);
258 xmlXPathFreeObject(
obj);
260 xmlXPathFreeObject(obj2);
261 valuePush(ctxt,
ret);
267 xmlXPathStringFunction(ctxt, 1);
268 if (ctxt->value->type != XPATH_STRING) {
270 "document() : invalid arg expecting a string\n");
271 ctxt->error = XPATH_INVALID_TYPE;
273 xmlXPathFreeObject(obj2);
276 obj = valuePop(ctxt);
278 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
282 if ((obj2 !=
NULL) && (obj2->nodesetval !=
NULL) &&
283 (obj2->nodesetval->nodeNr > 0) &&
287 target = obj2->nodesetval->nodeTab[0];
312 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
319 xmlXPathFreeObject(
obj);
321 xmlXPathFreeObject(obj2);
334 xmlXPathObjectPtr obj1, obj2;
338 "key() : expects two arguments\n");
339 ctxt->error = XPATH_INVALID_ARITY;
346 obj2 = valuePop(ctxt);
347 xmlXPathStringFunction(ctxt, 1);
348 if ((obj2 ==
NULL) ||
349 (ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
351 "key() : invalid arg expecting a string\n");
352 ctxt->error = XPATH_INVALID_TYPE;
353 xmlXPathFreeObject(obj2);
360 obj1 = valuePop(ctxt);
362 if ((obj2->type == XPATH_NODESET) || (obj2->type == XPATH_XSLT_TREE)) {
364 xmlXPathObjectPtr newobj,
ret;
366 ret = xmlXPathNewNodeSet(
NULL);
368 if (obj2->nodesetval !=
NULL) {
369 for (
i = 0;
i < obj2->nodesetval->nodeNr;
i++) {
370 valuePush(ctxt, xmlXPathObjectCopy(obj1));
372 xmlXPathNewNodeSet(obj2->nodesetval->nodeTab[
i]));
373 xmlXPathStringFunction(ctxt, 1);
375 newobj = valuePop(ctxt);
376 ret->nodesetval = xmlXPathNodeSetMerge(
ret->nodesetval,
378 xmlXPathFreeObject(newobj);
381 valuePush(ctxt,
ret);
383 xmlNodeSetPtr nodelist =
NULL;
388 xmlXPathContextPtr xpctxt = ctxt->context;
396 if (xpctxt->node ==
NULL) {
398 "Internal error in xsltKeyFunction(): " 399 "The context node is not set on the XPath context.\n");
406 qname = obj1->stringval;
414 if (prefix !=
NULL) {
415 keyURI = xmlXPathNsLookup(xpctxt, prefix);
416 if (keyURI ==
NULL) {
418 "key() : prefix %s is not bound\n", prefix);
432 valuePush(ctxt, obj2);
433 xmlXPathStringFunction(ctxt, 1);
434 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
436 "key() : invalid arg expecting a string\n");
437 ctxt->error = XPATH_INVALID_TYPE;
440 obj2 = valuePop(ctxt);
441 value = obj2->stringval;
465 tmpNode = xpctxt->node;
469 "Internal error in xsltKeyFunction(): " 470 "Couldn't get the doc of the XPath context node.\n");
477 if (tmpNode->
doc->name && (tmpNode->
doc->name[0] ==
' ')) {
481 if (tmpNode->
doc->_private ==
NULL) {
483 if (tmpNode->
doc->_private ==
NULL)
496 "Internal error in xsltKeyFunction(): " 497 "Could not get the document info of a context doc.\n");
509 valuePush(ctxt, xmlXPathWrapNodeSet(
510 xmlXPathNodeSetMerge(
NULL, nodelist)));
516 xmlXPathFreeObject(obj1);
518 xmlXPathFreeObject(obj2);
531 xmlXPathObjectPtr
obj;
534 if ((nargs != 1) || (ctxt->value ==
NULL)) {
536 "unparsed-entity-uri() : expects one string arg\n");
537 ctxt->error = XPATH_INVALID_ARITY;
540 obj = valuePop(ctxt);
541 if (
obj->type != XPATH_STRING) {
542 obj = xmlXPathConvertString(
obj);
547 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
553 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
556 valuePush(ctxt, xmlXPathNewString(
entity->URI));
558 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
561 xmlXPathFreeObject(
obj);
575 xmlXPathObjectPtr numberObj =
NULL;
576 xmlXPathObjectPtr formatObj =
NULL;
577 xmlXPathObjectPtr decimalObj =
NULL;
589 sheet = tctxt->
style;
597 decimalObj = valuePop(ctxt);
599 if (prefix !=
NULL) {
603 "format-number : No namespace found for QName '%s:%s'\n",
612 if (ncname !=
NULL) {
615 if (formatValues ==
NULL) {
617 "format-number() : undeclared decimal format '%s'\n",
618 decimalObj->stringval);
623 formatObj = valuePop(ctxt);
625 numberObj = valuePop(ctxt);
628 XP_ERROR(XPATH_INVALID_ARITY);
631 if (formatValues !=
NULL) {
633 formatObj->stringval,
635 &
result) == XPATH_EXPRESSION_OK) {
636 valuePush(ctxt, xmlXPathNewString(
result));
641 xmlXPathFreeObject(numberObj);
642 xmlXPathFreeObject(formatObj);
643 xmlXPathFreeObject(decimalObj);
656 static char base_address;
663 cur = ctxt->context->node;
664 }
else if (nargs == 1) {
665 xmlNodeSetPtr nodelist;
668 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_NODESET)) {
669 ctxt->error = XPATH_INVALID_TYPE;
671 "generate-id() : invalid arg expecting a node-set\n");
674 obj = valuePop(ctxt);
675 nodelist =
obj->nodesetval;
676 if ((nodelist ==
NULL) || (nodelist->nodeNr <= 0)) {
677 xmlXPathFreeObject(
obj);
678 valuePush(ctxt, xmlXPathNewCString(
""));
681 cur = nodelist->nodeTab[0];
682 for (
i = 1;
i < nodelist->nodeNr;
i++) {
683 ret = xmlXPathCmpNodes(
cur, nodelist->nodeTab[
i]);
685 cur = nodelist->nodeTab[
i];
689 "generate-id() : invalid number of args %d\n", nargs);
690 ctxt->error = XPATH_INVALID_ARITY;
695 xmlXPathFreeObject(
obj);
697 val = (
long)((
char *)
cur - (
char *)&base_address);
703 valuePush(ctxt, xmlXPathNewString(
str));
716 xmlXPathObjectPtr
obj;
722 "system-property() : expects one string arg\n");
723 ctxt->error = XPATH_INVALID_ARITY;
726 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
728 "system-property() : invalid arg expecting a string\n");
729 ctxt->error = XPATH_INVALID_TYPE;
732 obj = valuePop(ctxt);
734 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
740 nsURI = xmlXPathNsLookup(ctxt->context, prefix);
743 "system-property() : prefix %s is not bound\n", prefix);
748 #ifdef DOCBOOK_XSL_HACK 759 sheet = tctxt->
style;
766 valuePush(ctxt, xmlXPathNewString(
767 (
const xmlChar *)
"libxslt (SAXON 6.2 compatible)"));
770 valuePush(ctxt, xmlXPathNewString(
776 valuePush(ctxt, xmlXPathNewString(
781 valuePush(ctxt, xmlXPathNewString(
784 valuePush(ctxt, xmlXPathNewString(
787 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
790 valuePush(ctxt, xmlXPathNewString((
const xmlChar *)
""));
797 xmlXPathFreeObject(
obj);
810 xmlXPathObjectPtr
obj;
817 "element-available() : expects one string arg\n");
818 ctxt->error = XPATH_INVALID_ARITY;
821 xmlXPathStringFunction(ctxt, 1);
822 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
824 "element-available() : invalid arg expecting a string\n");
825 ctxt->error = XPATH_INVALID_TYPE;
828 obj = valuePop(ctxt);
832 "element-available() : internal error tctxt == NULL\n");
833 xmlXPathFreeObject(
obj);
834 valuePush(ctxt, xmlXPathNewBoolean(0));
847 nsURI = xmlXPathNsLookup(ctxt->context, prefix);
850 "element-available() : prefix %s is not bound\n", prefix);
855 valuePush(ctxt, xmlXPathNewBoolean(1));
857 valuePush(ctxt, xmlXPathNewBoolean(0));
860 xmlXPathFreeObject(
obj);
877 xmlXPathObjectPtr
obj;
883 "function-available() : expects one string arg\n");
884 ctxt->error = XPATH_INVALID_ARITY;
887 xmlXPathStringFunction(ctxt, 1);
888 if ((ctxt->value ==
NULL) || (ctxt->value->type != XPATH_STRING)) {
890 "function-available() : invalid arg expecting a string\n");
891 ctxt->error = XPATH_INVALID_TYPE;
894 obj = valuePop(ctxt);
900 nsURI = xmlXPathNsLookup(ctxt->context, prefix);
903 "function-available() : prefix %s is not bound\n", prefix);
907 if (xmlXPathFunctionLookupNS(ctxt->context,
name, nsURI) !=
NULL) {
908 valuePush(ctxt, xmlXPathNewBoolean(1));
910 valuePush(ctxt, xmlXPathNewBoolean(0));
913 xmlXPathFreeObject(
obj);
934 "current() : function uses no argument\n");
935 ctxt->error = XPATH_INVALID_ARITY;
941 "current() : internal error tctxt == NULL\n");
942 valuePush(ctxt, xmlXPathNewNodeSet(
NULL));
944 valuePush(ctxt, xmlXPathNewNodeSet(tctxt->
node));
963 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"current",
965 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"document",
968 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"unparsed-entity-uri",
970 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"format-number",
972 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"generate-id",
974 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"system-property",
976 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"element-available",
978 xmlXPathRegisterFunc(ctxt, (
const xmlChar *)
"function-available",
XMLPUBFUN const xmlChar *XMLCALL xmlStrstr(const xmlChar *str, const xmlChar *val)
static void xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltSystemPropertyFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltElementAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs)
#define XSLT_DEFAULT_VENDOR
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
xsltDocument * xsltDocumentPtr
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
GLsizei GLsizei GLuint * obj
void xsltFunctionAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
void xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs)
xmlGenericErrorFunc xsltGenericError
void xsltRegisterAllFunctions(xmlXPathContextPtr ctxt)
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
xsltTransformFunction xsltExtElementLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *URI)
void xsltUnparsedEntityURIFunction(xmlXPathParserContextPtr ctxt, int nargs)
xmlXPathFunction xsltExtModuleFunctionLookup(const xmlChar *name, const xmlChar *URI)
xsltDecimalFormatPtr xsltDecimalFormatGetByQName(xsltStylesheetPtr style, const xmlChar *nsUri, const xmlChar *name)
void * xsltGenericDebugContext
xmlNodeSetPtr xsltGetKey(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI, const xmlChar *value)
const xmlChar * xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
#define IS_XSLT_REAL_NODE(n)
XMLPUBVAR xmlFreeFunc xmlFree
xmlGenericErrorFunc xsltGenericDebug
void * xsltGenericErrorContext
xsltDecimalFormatPtr decimalFormat
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name)
GLsizei const GLfloat * value
static void xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar *URI)
void xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
static unsigned __int64 next
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
xmlXPathFunction xsltXPathFunctionLookup(void *vctxt, const xmlChar *name, const xmlChar *ns_uri)
#define XML_CAST_FPTR(fptr)
xsltDocumentPtr xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI)
xmlXPathError xsltFormatNumberConversion(xsltDecimalFormatPtr self, xmlChar *format, double number, xmlChar **result)
#define XSLT_DEFAULT_VERSION
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
xsltTransformContextPtr xsltXPathGetTransformContext(xmlXPathParserContextPtr ctxt)
xsltDocumentPtr xsltFindDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
xsltDocumentPtr xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc)
XMLPUBFUN xmlChar *XMLCALL xmlSaveUri(xmlURIPtr uri)
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName2(const xmlChar *name, xmlChar **prefix)
GLuint const GLchar * name