OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2001-2002 Thomas Broyer, Charlie Bozeman and Daniel Veillard. | 2 * Copyright (C) 2001-2002 Thomas Broyer, Charlie Bozeman and Daniel Veillard. |
3 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
4 * | 4 * |
5 * Permission is hereby granted, free of charge, to any person obtaining a copy | 5 * Permission is hereby granted, free of charge, to any person obtaining a copy |
6 * of this software and associated documentation files (the "Software"), to deal | 6 * of this software and associated documentation files (the "Software"), to deal |
7 * in the Software without restriction, including without limitation the rights | 7 * in the Software without restriction, including without limitation the rights |
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9 * copies of the Software, and to permit persons to whom the Software is fur- | 9 * copies of the Software, and to permit persons to whom the Software is fur- |
10 * nished to do so, subject to the following conditions: | 10 * nished to do so, subject to the following conditions: |
11 * | 11 * |
12 * The above copyright notice and this permission notice shall be included in | 12 * The above copyright notice and this permission notice shall be included in |
13 * all copies or substantial portions of the Software. | 13 * all copies or substantial portions of the Software. |
14 * | 14 * |
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- | 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- |
17 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 17 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18 * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | 18 * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- | 19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- |
20 * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 20 * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
21 * | 21 * |
22 * Except as contained in this notice, the name of the authors shall not | 22 * Except as contained in this notice, the name of the authors shall not |
23 * be used in advertising or otherwise to promote the sale, use or other deal- | 23 * be used in advertising or otherwise to promote the sale, use or other deal- |
24 * ings in this Software without prior written authorization from him. | 24 * ings in this Software without prior written authorization from him. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/xml/XSLTExtensions.h" |
28 | 29 |
29 #include "core/xml/XSLTExtensions.h" | |
30 #include "platform/RuntimeEnabledFeatures.h" | 30 #include "platform/RuntimeEnabledFeatures.h" |
31 #include "wtf/Assertions.h" | 31 #include "wtf/Assertions.h" |
32 | |
33 #include <libxml/xpathInternals.h> | 32 #include <libxml/xpathInternals.h> |
34 | |
35 #include <libxslt/extensions.h> | 33 #include <libxslt/extensions.h> |
36 #include <libxslt/extra.h> | 34 #include <libxslt/extra.h> |
37 #include <libxslt/xsltutils.h> | 35 #include <libxslt/xsltutils.h> |
38 | 36 |
39 namespace WebCore { | 37 namespace WebCore { |
40 | 38 |
41 // FIXME: This code is taken from libexslt 1.1.11; should sync with newer versio
ns. | 39 // FIXME: This code is taken from libexslt 1.1.11; should sync with newer |
| 40 // versions. |
42 static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs) | 41 static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs) |
43 { | 42 { |
44 xmlChar *strval; | 43 xmlChar* strval; |
45 xmlNodePtr retNode; | 44 xmlNodePtr retNode; |
46 xmlXPathObjectPtr ret; | 45 xmlXPathObjectPtr ret; |
47 | 46 |
48 if (nargs != 1) { | 47 if (nargs != 1) { |
49 xmlXPathSetArityError(ctxt); | 48 xmlXPathSetArityError(ctxt); |
50 return; | 49 return; |
51 } | 50 } |
52 | 51 |
53 if (xmlXPathStackIsNodeSet(ctxt)) { | 52 if (xmlXPathStackIsNodeSet(ctxt)) { |
54 xsltFunctionNodeSet(ctxt, nargs); | 53 xsltFunctionNodeSet(ctxt, nargs); |
55 return; | 54 return; |
56 } | 55 } |
57 | 56 |
58 strval = xmlXPathPopString(ctxt); | 57 strval = xmlXPathPopString(ctxt); |
59 retNode = xmlNewDocText(NULL, strval); | 58 retNode = xmlNewDocText(0, strval); |
60 ret = xmlXPathNewValueTree(retNode); | 59 ret = xmlXPathNewValueTree(retNode); |
61 | 60 |
62 // FIXME: It might be helpful to push any errors from xmlXPathNewValueTree | 61 // FIXME: It might be helpful to push any errors from xmlXPathNewValueTree |
63 // up to the Javascript Console. | 62 // up to the Javascript Console. |
64 if (ret != NULL) | 63 if (ret) |
65 ret->type = XPATH_NODESET; | 64 ret->type = XPATH_NODESET; |
66 | 65 |
67 if (strval != NULL) | 66 if (strval) |
68 xmlFree(strval); | 67 xmlFree(strval); |
69 | 68 |
70 valuePush(ctxt, ret); | 69 valuePush(ctxt, ret); |
71 } | 70 } |
72 | 71 |
73 void registerXSLTExtensions(xsltTransformContextPtr ctxt) | 72 void registerXSLTExtensions(xsltTransformContextPtr ctxt) |
74 { | 73 { |
75 ASSERT(RuntimeEnabledFeatures::xsltEnabled()); | 74 ASSERT(RuntimeEnabledFeatures::xsltEnabled()); |
76 xsltRegisterExtFunction(ctxt, (const xmlChar*)"node-set", (const xmlChar*)"h
ttp://exslt.org/common", exsltNodeSetFunction); | 75 xsltRegisterExtFunction(ctxt, (const xmlChar*)"node-set", (const xmlChar*)"h
ttp://exslt.org/common", exsltNodeSetFunction); |
77 } | 76 } |
78 | 77 |
79 } // namespace WebCore | 78 } // namespace WebCore |
OLD | NEW |