Closed Bug 190631 Opened 22 years ago Closed 22 years ago

value-of creates a textnode even if stringvalue is an empty string

Categories

(Core :: XSLT, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: sicking, Assigned: sicking)

Details

Attachments

(1 file)

We call resulthandler->characters in the code for xsl:value-of even if the calculated stringvalue is an empty string. This has two effects: 1. In the standalone-outputhandlers the following stylesheet <out><xsl:value-of select="''"/></out> gives the output "<out></out>" rather then "<out/>". This makes us fail a lot of the string tests in xalan. 2. The following stylesheet <out><xsl:value-of select="''"/><xsl:attribute name="foo"/></out> will not create the attribute since we "close" the element when executing the xsl:value-of. The spec says on xsl:attribute: "The following are all errors: Adding an attribute to an element after children have been added to it..." And on xsl:value-of: "The string specifies the string-value of the created text node. If the string is empty, no text node will be created." So it's clear that we are doing the wrong thing. There are two ways to solve this. Either we teach all the output-handlers to ignore ::characters/::charactersNoOutputEscaping being called with an empty string, or we make xsl:value-of not call the resulthandler if the string is empty. I've done the latter since that's what the spec says.
Attached patch patch to fixSplinter Review
i also included a small fix to get rid of a warning in the HTML-output-handler where we were peek()-ing an empty stack
Attachment #112646 - Flags: superreview?(peterv)
Attachment #112646 - Flags: review?(axel)
Comment on attachment 112646 [details] [diff] [review] patch to fix if you believe it or not, r=axel@pike.org ;-)
Attachment #112646 - Flags: review?(axel) → review+
Attachment #112646 - Flags: superreview?(peterv) → superreview+
Comment on attachment 112646 [details] [diff] [review] patch to fix this is a very lowrisk patch since it hardly changes any logic. It's fully contained to XSLT, no other pages will be affected.
Attachment #112646 - Flags: approval1.3b?
Comment on attachment 112646 [details] [diff] [review] patch to fix a=asa (on behalf of drivers) for checkin to 1.3beta.
Attachment #112646 - Flags: approval1.3b? → approval1.3b+
checked in. thanks for reviews
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
mass verifying
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: