Open
Bug 296094
Opened 20 years ago
Updated 2 years ago
XSLT Transform does not behave correctly for <xsl:value-of select='text()'/>
Categories
(Core :: XSLT, defect)
Tracking
()
NEW
People
(Reporter: gerald-butler, Assigned: peterv)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b) Gecko/20050217
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b) Gecko/20050217
If you have an XML document with a tag that contains text and you wish to use
the <xsl:value-of select='text()'/> in the XSLT, it does not select ALL the text
contained in the tag. It truncates the text at an arbitrary point.
Reproducible: Always
Steps to Reproduce:
1. Create an XML document with a tag as follows:
<loadingscript>
var ds = ximple.instances.objects.resultsetbase.docs;
ds.appendrow( { field1 : "Value 1a", field2 : "Value 2a", field3 :
"Value 3a", field4 : "Value 4a", field5 : "Value 5a", field6 : "Value 6a",
field7 : "Value 7a" } );
ds.appendrow( { field1 : "Value 1b", field2 : "Value 2b", field3 :
"Value 3b", field4 : "Value 4b", field5 : "Value 5b", field6 : "Value 6b",
field7 : "Value 7b" } );
ds.appendrow( { field1 : "Value 1c", field2 : "Value 2c", field3 :
"Value 3c", field4 : "Value 4c", field5 : "Value 5c", field6 : "Value 6c",
field7 : "Value 7c" } );
ds.appendrow( { field1 : "Value 1d", field2 : "Value 2d", field3 :
"Value 3d", field4 : "Value 4d", field5 : "Value 5d", field6 : "Value 6d",
field7 : "Value 7d" } );
ds.appendrow( { field1 : "Value 1e", field2 : "Value 2e", field3 :
"Value 3e", field4 : "Value 4e", field5 : "Value 5e", field6 : "Value 6e",
field7 : "Value 7e" } );
ds.appendrow( { field1 : "Value 1f", field2 : "Value 2f", field3 :
"Value 3f", field4 : "Value 4f", field5 : "Value 5f", field6 : "Value 6f",
field7 : "Value 7f" } );
ds.appendrow( { field1 : "Value 1g", field2 : "Value 2g", field3 :
"Value 3g", field4 : "Value 4g", field5 : "Value 5g", field6 : "Value 6g",
field7 : "Value 7g" } );
ds.appendrow( { field1 : "Value 1h", field2 : "Value 2h", field3 :
"Value 3h", field4 : "Value 4h", field5 : "Value 5h", field6 : "Value 6h",
field7 : "Value 7h" } );
ds.appendrow( { field1 : "Value 1i", field2 : "Value 2i", field3 :
"Value 3i", field4 : "Value 4i", field5 : "Value 5i", field6 : "Value 6i",
field7 : "Value 7i" } );
ds.appendrow( { field1 : "Value 1j", field2 : "Value 2j", field3 :
"Value 3j", field4 : "Value 4j", field5 : "Value 5j", field6 : "Value 6j",
field7 : "Value 7j" } );
ds.appendrow( { field1 : "Value 1k", field2 : "Value 2k", field3 :
"Value 3k", field4 : "Value 4k", field5 : "Value 5k", field6 : "Value 6k",
field7 : "Value 7k" } );
ds.appendrow( { field1 : "Value 1l", field2 : "Value 2l", field3 :
"Value 3l", field4 : "Value 4l", field5 : "Value 5l", field6 : "Value 6l",
field7 : "Value 7l" } );
ds.appendrow( { field1 : "Value 1m", field2 : "Value 2m", field3 :
"Value 3m", field4 : "Value 4m", field5 : "Value 5m", field6 : "Value 6m",
field7 : "Value 7m" } );
ds.appendrow( { field1 : "Value 1aa", field2 : "Value 2aa", field3 :
"Value 3aa", field4 : "Value 4aa", field5 : "Value 5aa", field6 : "Value 6aa",
field7 : "Value 7aa" } );
ds.appendrow( { field1 : "Value 1bb", field2 : "Value 2bb", field3 :
"Value 3bb", field4 : "Value 4bb", field5 : "Value 5bb", field6 : "Value 6bb",
field7 : "Value 7bb" } );
ds.appendrow( { field1 : "Value 1cc", field2 : "Value 2cc", field3 :
"Value 3cc", field4 : "Value 4cc", field5 : "Value 5cc", field6 : "Value 6cc",
field7 : "Value 7cc" } );
ds.appendrow( { field1 : "Value 1dd", field2 : "Value 2dd", field3 :
"Value 3dd", field4 : "Value 4dd", field5 : "Value 5dd", field6 : "Value 6dd",
field7 : "Value 7dd" } );
ds.appendrow( { field1 : "Value 1ee", field2 : "Value 2ee", field3 :
"Value 3ee", field4 : "Value 4ee", field5 : "Value 5ee", field6 : "Value 6ee",
field7 : "Value 7ee" } );
ds.appendrow( { field1 : "Value 1ff", field2 : "Value 2ff", field3 :
"Value 3ff", field4 : "Value 4ff", field5 : "Value 5ff", field6 : "Value 6ff",
field7 : "Value 7ff" } );
ds.appendrow( { field1 : "Value 1gg", field2 : "Value 2gg", field3 :
"Value 3gg", field4 : "Value 4gg", field5 : "Value 5gg", field6 : "Value 6gg",
field7 : "Value 7gg" } );
ds.appendrow( { field1 : "Value 1hh", field2 : "Value 2hh", field3 :
"Value 3hh", field4 : "Value 4hh", field5 : "Value 5hh", field6 : "Value 6hh",
field7 : "Value 7hh" } );
ds.appendrow( { field1 : "Value 1ii", field2 : "Value 2ii", field3 :
"Value 3ii", field4 : "Value 4ii", field5 : "Value 5ii", field6 : "Value 6ii",
field7 : "Value 7ii" } );
ds.appendrow( { field1 : "Value 1jj", field2 : "Value 2jj", field3 :
"Value 3jj", field4 : "Value 4jj", field5 : "Value 5jj", field6 : "Value 6jj",
field7 : "Value 7jj" } );
</loadingscript>
2. Create XSLT as follows:
<xsl:template match='loadingscript'>
<script type='text/javascript'>
<xsl:value-of select='text()'/>
</script>
</xsl:template>
3. Reference the XSLT in the XML document and load normally.
4. It WILL NOT copy the full text from the 'loadingscript' taq into the
destination 'script' tag (use DOM to verify)
Actual Results:
Invalid script create in the <script> tag
Expected Results:
Copied the the entire text node contents from the <loadingscript> tag into the
<script> node
Updated•20 years ago
|
Assignee: general → peterv
Component: General → XSLT
Product: Mozilla Application Suite → Core
QA Contact: general → keith
Version: unspecified → Trunk
Gerald: Please attach testcases as files rather then just include the test testcase in a comment. Read the guide at http://www.mozilla.org/projects/xslt/bug-reporting.html for how to report XSLT bugs. What's probably happening here is that we end up with two textnodes as child of the <loadingscript> element (iirc we split 'too long' textnodes in the sink). But I'd need a real testcase to confirm that. If that is the problem though, you can use <xsl:value-of select="."> to get the value of the element instead of its first textnode. That should work fine in this example. The easy fix for this is to stop doing that splitting. bz, I know we've talked about this before, but I don't remember what, if anything, is stopping us from removing that splitting. That said, the XSLT code needs to be able to handle a DOM like this. It can happen when we're called from javascript, and it can even happen if CDATA sections are mixed with normal text.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 2•20 years ago
|
||
> but I don't remember what, if anything, is stopping us from
> removing that splitting.
I believe the main problem(s) are having to keep realloc'ing as more data comes
in and possible O(N^2) reflow issues. I _think_ those are it, but I'm not
completely sure.The reallocing could be somewhat avoided, we could just allocate new buffers and stick the existing one at the end of an array once a buffer reaches, say, 4k. It's a bit of a hassle to get a split string like that into the nextnode, but it's doable. But is this really a big issue, if we double the buffersize every time we hit its limit we'd only realloc a handfull of times even for a nextnodes several megs big. Layout issues might be harder to fix though.
Comment 4•20 years ago
|
||
> if we double the buffersize every time we hit its limit
That could be pretty wasteful of memory, no?
The multi-buffer approach may work; layout would need to be taught about it, though.
Comment 5•19 years ago
|
||
(In reply to comment #1) <snip> > What's probably happening here is that we end up with two textnodes as child of > the <loadingscript> element (iirc we split 'too long' textnodes in the sink). > But I'd need a real testcase to confirm that. If that is the problem though, you > can use <xsl:value-of select="."> to get the value of the element instead of its > first textnode. That should work fine in this example. <snip> Yes, this works when you have only text nodes as children of the current node. However, if the current node has both text nodes and elements as children and those child elements contain text /that you do not want to display/, this approach fails, because the value-of of a node set is the value of all it's text nodes and descendant text nodes concatenated. This does work in such a case: <xsl:for-each select="test"><xsl:value-of select="."/></xsl:for-each> I still feel this sould not be necessary, though it does work (and even gives the same results in FF and IE for my test case).
Updated•15 years ago
|
QA Contact: keith → xslt
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•