2006-07-20 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
<rdar://problem/
4637807> REGRESSION: "Features & Options" page at volvocars.us fails
* xml/XSLTProcessor.cpp:
(WebCore::xsltParamArrayFromParameterMap):
Turns out parameters never worked. String parameters need to be escaped so we create a transform context,
add the parameters to it quoted and then use xsltApplyStylesheetUser which lets us pass the transform context to it.
This also works around a bug in libxslt where a hash table isn't allocated.
LayoutTests:
2006-07-20 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
<rdar://problem/
4637807> REGRESSION: "Features & Options" page at volvocars.us fails
* fast/xsl/xslt-processer-expected.txt:
This passes now.
* fast/xsl/xslt-string-parameters-expected.txt: Added.
* fast/xsl/xslt-string-parameters.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15552
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-07-20 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Geoff.
+
+ <rdar://problem/4637807> REGRESSION: "Features & Options" page at volvocars.us fails
+
+ * fast/xsl/xslt-processer-expected.txt:
+ This passes now.
+
+ * fast/xsl/xslt-string-parameters-expected.txt: Added.
+ * fast/xsl/xslt-string-parameters.html: Added.
+
2006-07-20 Maciej Stachowiak <mjs@apple.com>
Reviewed by Beth and John.
2.4 transform to same fragment twice:
Success
2.5 transformed fragment containing only text:
-****Failure**** (expected: "SUCCESS" actual: "")
+Success
2.6 fragment using passed parameters:
-****Failure**** (expected: "SUCCESS" actual: "")
+Success
3.0 DOMDocument transformToDocument(in DOMNode source):
--- /dev/null
+This tests that passing string parameters to the XSLTProcessor works as expected. If this test is successful, the text "SUCCESS" will be shown below.
+
+SUCCESS
+
--- /dev/null
+<html>
+<head>
+ <script>
+ function runTest() {
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var sourceDoc = (new DOMParser).parseFromString('<test/>', 'text/xml');
+ var sheetDoc = (new DOMParser).parseFromString('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' +
+ '<xsl:output method="text"/><xsl:param name="testParam"/>' +
+ '<xsl:template match="/test"><xsl:value-of select="$testParam"/></xsl:template></xsl:stylesheet>', 'text/xml');
+
+ var processor = new XSLTProcessor();
+ processor.importStylesheet(sheetDoc);
+
+ processor.setParameter(null, 'testParam', 'text')
+ var result = processor.transformToFragment(sourceDoc, document);
+ if (result.textContent != 'text')
+ return;
+
+ processor.setParameter(null, 'testParam', 'text with spaces')
+ var result = processor.transformToFragment(sourceDoc, document);
+ if (result.textContent != 'text with spaces')
+ return;
+
+ processor.setParameter(null, 'testParam', 'Shakespeare\'s "Twelfth Night"')
+ var result = processor.transformToFragment(sourceDoc, document);
+ if (result.textContent != 'Shakespeare\'s "Twelfth Night"')
+ return;
+
+ document.getElementById('result').innerHTML = 'SUCCESS';
+ }
+ </script>
+</head>
+<body onload="runTest()">
+ <p>This tests that passing string parameters to the XSLTProcessor works as expected. If this test is successful, the text "SUCCESS" will be shown below.</p>
+ <div id="result">FAILURE</div>
+</body>
+</html>
+2006-07-20 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Geoff.
+
+ <rdar://problem/4637807> REGRESSION: "Features & Options" page at volvocars.us fails
+
+ * xml/XSLTProcessor.cpp:
+ (WebCore::xsltParamArrayFromParameterMap):
+ Turns out parameters never worked. String parameters need to be escaped so we create a transform context,
+ add the parameters to it quoted and then use xsltApplyStylesheetUser which lets us pass the transform context to it.
+ This also works around a bug in libxslt where a hash table isn't allocated.
+
2006-07-20 Alice Liu <alice.liu@apple.com>
Reviewed by Tim Omernick.
#include "markup.h"
#include <wtf/Vector.h>
#include <libxslt/imports.h>
+#include <libxslt/variables.h>
#include <libxslt/xsltutils.h>
namespace WebCore {
bool success = false;
bool shouldFreeSourceDoc = false;
if (xmlDocPtr sourceDoc = xmlDocPtrFromNode(sourceNode, shouldFreeSourceDoc)) {
+ xsltTransformContextPtr transformContext = xsltNewTransformContext(sheet, sourceDoc);
+
+ // This is a workaround for a bug in libxslt.
+ // The bug has been fixed in version 1.1.13, so once we ship that this can be removed.
+ if (transformContext->globalVars == NULL)
+ transformContext->globalVars = xmlHashCreate(20);
+
const char **params = xsltParamArrayFromParameterMap(m_parameters);
- xmlDocPtr resultDoc = xsltApplyStylesheet(sheet, sourceDoc, params);
+ xsltQuoteUserParams(transformContext, params);
+ xmlDocPtr resultDoc = xsltApplyStylesheetUser(sheet, sourceDoc, 0, 0, 0, transformContext);
+
+ xsltFreeTransformContext(transformContext);
freeXsltParamArray(params);
+
if (shouldFreeSourceDoc)
xmlFreeDoc(sourceDoc);