Reviewed by Eric.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2006 04:32:02 +0000 (04:32 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2006 04:32:02 +0000 (04:32 +0000)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=10419
        XSLTProcessor transformToFragment fails because of an XML declaration

        Test: fast/xsl/transformToFragment-XML-declaration.html

        * xml/XSLTProcessor.cpp:
        (WebCore::XSLTProcessor::transformToString): Always inhibit XML declaration printout.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15960 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/xsl/transformToFragment-XML-declaration-expected.txt [new file with mode: 0644]
LayoutTests/fast/xsl/transformToFragment-XML-declaration.html [new file with mode: 0644]
LayoutTests/fast/xsl/xslt-extra-content-at-end-expected.checksum
LayoutTests/fast/xsl/xslt-extra-content-at-end-expected.png
LayoutTests/fast/xsl/xslt-extra-content-at-end-expected.txt
WebCore/ChangeLog
WebCore/xml/XSLTProcessor.cpp

index 25bbf9dac50d0e5acee0f98c5b7802d1b2d9b298..82ad1d5ff393aec561180aebe76d8a6fc2d980cb 100644 (file)
@@ -1,3 +1,17 @@
+2006-08-21  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Eric.
+
+        Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=10419
+        XSLTProcessor transformToFragment fails because of an XML declaration
+
+        * fast/xsl/transformToFragment-XML-declaration-expected.txt: Added.
+        * fast/xsl/transformToFragment-XML-declaration.html: Added.
+
+        * fast/xsl/xslt-extra-content-at-end-expected.checksum:
+        * fast/xsl/xslt-extra-content-at-end-expected.png:
+        * fast/xsl/xslt-extra-content-at-end-expected.txt: Updated for a changed error reporting.
+
 2006-08-21  Vladimir Olexa  <vladimir.olexa@gmail.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/xsl/transformToFragment-XML-declaration-expected.txt b/LayoutTests/fast/xsl/transformToFragment-XML-declaration-expected.txt
new file mode 100644 (file)
index 0000000..c06eee1
--- /dev/null
@@ -0,0 +1,3 @@
+Test for bug 10419: XSLTProcessor transformToFragment fails because of an XML declaration.
+
+SUCCESS
diff --git a/LayoutTests/fast/xsl/transformToFragment-XML-declaration.html b/LayoutTests/fast/xsl/transformToFragment-XML-declaration.html
new file mode 100644 (file)
index 0000000..4ed6e64
--- /dev/null
@@ -0,0 +1,37 @@
+<body>
+<p>Test for <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=10419">bug 10419</a>:
+XSLTProcessor transformToFragment fails because of an XML declaration.</p>
+
+<script>
+
+  if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+  try {
+    var xml = (new DOMParser()).parseFromString('<doc/>', 'application/xml');
+    var xsl = (new DOMParser()).parseFromString(
+        '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">' +
+        '<xsl:output method="xml" omit-xml-declaration="no"/>' +
+        ' <xsl:template match="doc"><p>1</p><p>2</p></xsl:template>' +
+        '</xsl:stylesheet>', 
+        'application/xml');
+
+    var p = new XSLTProcessor;
+    p.importStylesheet(xsl);
+
+    var ownerDocument = document.implementation.createDocument("", "doc", null);
+    var f = p.transformToFragment(xml, ownerDocument);
+    var result = (new XMLSerializer()).serializeToString(f);
+    result = result.substr(0, 16); // remove the trailing newline, if present
+
+    if (result == "<p>1</p><p>2</p>")
+        document.write('SUCCESS');
+    else
+        document.write('<xmp>FAILURE: "' + result + '"</xmp>');
+
+  } catch (ex) {
+     document.write('FAILURE: ' + ex);
+  }
+
+</script>
+</body>
index c4821896b014633c88107a4a768e4af631635705..4f78669c438487bfb6bc9bca4eb15ec31419406f 100644 (file)
@@ -1 +1 @@
-e767829d61e15e8155ff45db7850fe85
\ No newline at end of file
+5ba5d0e5f9f347549a6754088e78636f
\ No newline at end of file
index 0ec13ca9a98b9a00c59fa15fb556885833af26fc..dee3d6c63733422d015e0f2ae9ab93e182ff551a 100644 (file)
Binary files a/LayoutTests/fast/xsl/xslt-extra-content-at-end-expected.png and b/LayoutTests/fast/xsl/xslt-extra-content-at-end-expected.png differ
index 7c069b35e32276c7de6a2c6e1050f7c33681d8dd..3eab5b5aec042550f7461ec4bb1eab27a8a34b0c 100644 (file)
@@ -10,7 +10,7 @@ layer at (0,0) size 800x216
           text run at (0,0) width 324: "This page contains the following errors:"
       RenderBlock {div} at (0,40) size 800x14
         RenderText {#text} at (0,0) size 490x14
-          text run at (0,0) width 490: "error on line 2 at column 31: Extra content at the end of the document"
+          text run at (0,0) width 490: "error on line 1 at column 31: Extra content at the end of the document"
           text run at (490,0) width 0: " "
       RenderBlock {h3} at (0,72) size 800x22
         RenderText {#text} at (0,0) size 429x22
index 0a46413682139e46efce85a1e2abd6ddd88b7c25..f09ffd74744db8583898d2899900b50034d323b0 100644 (file)
@@ -1,3 +1,15 @@
+2006-08-21  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Eric.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=10419
+        XSLTProcessor transformToFragment fails because of an XML declaration
+
+        Test: fast/xsl/transformToFragment-XML-declaration.html
+
+        * xml/XSLTProcessor.cpp:
+        (WebCore::XSLTProcessor::transformToString): Always inhibit XML declaration printout.
+
 2006-08-21  David Harrison  <harrison@apple.com>
 
         Reviewed by Justin.
index f3d2b47fb42360f6283f04c42d8d0b815de282e3..96431cb9a396331d58bd79f504f447411f81ab7e 100644 (file)
@@ -308,6 +308,10 @@ bool XSLTProcessor::transformToString(Node *sourceNode, DeprecatedString &mimeTy
     bool success = false;
     bool shouldFreeSourceDoc = false;
     if (xmlDocPtr sourceDoc = xmlDocPtrFromNode(sourceNode, shouldFreeSourceDoc)) {
+        // The XML declaration would prevent parsing the result as a fragment, and it's not needed even for documents, 
+        // as the result of this function is always immediately parsed.
+        sheet->omitXmlDeclaration = true;
+
         xsltTransformContextPtr transformContext = xsltNewTransformContext(sheet, sourceDoc);
 
         // This is a workaround for a bug in libxslt.