2 #include "libexslt/libexslt.h"
4 #if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__)
5 #include <win32config.h>
10 #include <libxml/tree.h>
11 #include <libxml/xpath.h>
12 #include <libxml/xpathInternals.h>
14 #include <libxslt/xsltconfig.h>
15 #include <libxslt/xsltutils.h>
16 #include <libxslt/xsltInternals.h>
17 #include <libxslt/extensions.h>
18 #include <libxslt/transform.h>
19 #include <libxslt/extra.h>
20 #include <libxslt/preproc.h>
25 exsltNodeSetFunction (xmlXPathParserContextPtr ctxt, int nargs) {
27 xmlXPathSetArityError(ctxt);
30 if (xmlXPathStackIsNodeSet (ctxt)) {
31 xsltFunctionNodeSet (ctxt, nargs);
35 xsltTransformContextPtr tctxt = xsltXPathGetTransformContext(ctxt);
38 xmlXPathObjectPtr obj;
41 * "You can also use this function to turn a string into a text
42 * node, which is helpful if you want to pass a string to a
43 * function that only accepts a node-set."
45 fragment = xsltCreateRVT(tctxt);
46 if (fragment == NULL) {
47 xsltTransformError(tctxt, NULL, tctxt->inst,
48 "exsltNodeSetFunction: Failed to create a tree fragment.\n");
49 tctxt->state = XSLT_STATE_STOPPED;
52 xsltRegisterLocalRVT(tctxt, fragment);
54 strval = xmlXPathPopString (ctxt);
56 txt = xmlNewDocText (fragment, strval);
57 xmlAddChild((xmlNodePtr) fragment, txt);
58 obj = xmlXPathNewNodeSet(txt);
60 xsltTransformError(tctxt, NULL, tctxt->inst,
61 "exsltNodeSetFunction: Failed to create a node set object.\n");
62 tctxt->state = XSLT_STATE_STOPPED;
67 valuePush (ctxt, obj);
72 exsltObjectTypeFunction (xmlXPathParserContextPtr ctxt, int nargs) {
73 xmlXPathObjectPtr obj, ret;
76 xmlXPathSetArityError(ctxt);
84 ret = xmlXPathNewCString("string");
87 ret = xmlXPathNewCString("number");
90 ret = xmlXPathNewCString("boolean");
93 ret = xmlXPathNewCString("node-set");
96 ret = xmlXPathNewCString("RTF");
99 ret = xmlXPathNewCString("external");
102 xsltGenericError(xsltGenericErrorContext,
103 "object-type() invalid arg\n");
104 ctxt->error = XPATH_INVALID_TYPE;
105 xmlXPathFreeObject(obj);
108 xmlXPathFreeObject(obj);
109 valuePush(ctxt, ret);
114 * exsltCommonRegister:
116 * Registers the EXSLT - Common module
120 exsltCommonRegister (void) {
121 xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
122 EXSLT_COMMON_NAMESPACE,
123 exsltNodeSetFunction);
124 xsltRegisterExtModuleFunction((const xmlChar *) "object-type",
125 EXSLT_COMMON_NAMESPACE,
126 exsltObjectTypeFunction);
127 xsltRegisterExtModuleElement((const xmlChar *) "document",
128 EXSLT_COMMON_NAMESPACE,
129 (xsltPreComputeFunction) xsltDocumentComp,
130 (xsltTransformFunction) xsltDocumentElem);