| 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: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 if (nargs != 1) { | 45 if (nargs != 1) { |
| 46 xmlXPathSetArityError(ctxt); | 46 xmlXPathSetArityError(ctxt); |
| 47 return; | 47 return; |
| 48 } | 48 } |
| 49 | 49 |
| 50 if (xmlXPathStackIsNodeSet(ctxt)) { | 50 if (xmlXPathStackIsNodeSet(ctxt)) { |
| 51 xsltFunctionNodeSet(ctxt, nargs); | 51 xsltFunctionNodeSet(ctxt, nargs); |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // node-set can also take a string and turn it into a singleton node |
| 56 // set with one text node. This may null-deref if allocating the |
| 57 // document, text node, etc. fails; that behavior is expected. |
| 58 |
| 59 // Create a document to hold the text node result. |
| 60 xsltTransformContextPtr tctxt = xsltXPathGetTransformContext(ctxt); |
| 61 xmlDocPtr fragment = xsltCreateRVT(tctxt); |
| 62 xsltRegisterLocalRVT(tctxt, fragment); |
| 63 |
| 64 // Create the text node and wrap it in a result set. |
| 55 strval = xmlXPathPopString(ctxt); | 65 strval = xmlXPathPopString(ctxt); |
| 56 retNode = xmlNewDocText(0, strval); | 66 retNode = xmlNewDocText(fragment, strval); |
| 57 ret = xmlXPathNewValueTree(retNode); | 67 xmlAddChild(reinterpret_cast<xmlNodePtr>(fragment), retNode); |
| 58 | 68 ret = xmlXPathNewNodeSet(retNode); |
| 59 // FIXME: It might be helpful to push any errors from xmlXPathNewValueTree | 69 CHECK(ret); |
| 60 // up to the Javascript Console. | |
| 61 if (ret) | |
| 62 ret->type = XPATH_NODESET; | |
| 63 | 70 |
| 64 if (strval) | 71 if (strval) |
| 65 xmlFree(strval); | 72 xmlFree(strval); |
| 66 | 73 |
| 67 valuePush(ctxt, ret); | 74 valuePush(ctxt, ret); |
| 68 } | 75 } |
| 69 | 76 |
| 70 void registerXSLTExtensions(xsltTransformContextPtr ctxt) { | 77 void registerXSLTExtensions(xsltTransformContextPtr ctxt) { |
| 71 DCHECK(RuntimeEnabledFeatures::xsltEnabled()); | 78 DCHECK(RuntimeEnabledFeatures::xsltEnabled()); |
| 72 xsltRegisterExtFunction(ctxt, (const xmlChar*)"node-set", | 79 xsltRegisterExtFunction(ctxt, (const xmlChar*)"node-set", |
| 73 (const xmlChar*)"http://exslt.org/common", | 80 (const xmlChar*)"http://exslt.org/common", |
| 74 exsltNodeSetFunction); | 81 exsltNodeSetFunction); |
| 75 } | 82 } |
| 76 | 83 |
| 77 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |