Closed Bug 551412 Opened 15 years ago Closed 14 years ago

The EXSLT node-set function drops text nodes if they appear last in a rtf

Categories

(Core :: XSLT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a5

People

(Reporter: andreas.wictor, Assigned: peterv)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a3pre) Gecko/20100310 Minefield/3.7a3pre
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a3pre) Gecko/20100310 Minefield/3.7a3pre

Text nodes that appear last in a result tree fragment is never written 
to the document fragment that is used to construct nodes because endDocument 
is newer called on the txMozillaXMLOutput handler.

Reproducible: Always

Steps to Reproduce:
Use this html file

<html>
<head>
<title>exsl node-set bug</title>
</head>
<body>
<div id="result"></div>
<script type="text/javascript">
var xslStr =
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"' +
'                xmlns:exsl="http://exslt.org/common"' +
'                version="1.0">' +
'  <xsl:output method="html"/>' +
'  <xsl:variable name="rtf">1 <b>2</b> 3</xsl:variable>' +
'  <xsl:template match="/">' +
'    <xsl:copy-of select="exsl:node-set($rtf)"/>' +
'  </xsl:template>' +
'</xsl:stylesheet>';

var parser = new DOMParser();
var xslDoc = parser.parseFromString(xslStr, "text/xml");
var xmlDoc = parser.parseFromString("<root/>", "text/xml");

var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xslDoc);

var fragment = xsltProcessor.transformToFragment(xmlDoc, document);

document.getElementById("result").appendChild(fragment);
</script>
</body>
</html>

Actual Results:  
It displays: 1 2

Expected Results:  
It should display: 1 2 3
Attached patch v2Splinter Review
Thanks for the testcase and patch, and sorry for the long delay. I don't think calling startDocument and endDocument is the right thing to do. endDocument in particular does a bunch of things to the ownerDocument of the DocumentFragment (SetReadyStateInternal, SetupRefreshURIFromHeader), we don't want transforming to a fragment to change the state of its ownerDocument. We should instead just add a call to closePrevious after flushing, similar to what endDocument does.
Assignee: nobody → peterv
Attachment #431596 - Attachment is obsolete: true
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #443118 - Flags: review?(jonas)
Attachment #431596 - Flags: review?(peterv)
http://hg.mozilla.org/mozilla-central/rev/5d60184d9e98
http://hg.mozilla.org/mozilla-central/rev/8126303a7773
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: