Bug 56184 - Problem in substring-before() and substring-after() XPath methods
Summary: Problem in substring-before() and substring-after() XPath methods
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-11 06:34 PST by Yusuf Koseoglu
Modified: 2023-04-27 12:53 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuf Koseoglu 2011-03-11 06:34:59 PST
<xsl:template name="createRadioButton">
        <xsl:param name="list" /><!-- something like : true|false|bla|bla -->
        <xsl:param name="delimiter" /> <!-- "|" -->
        <xsl:param name="nameofradio" /> <!-- sampleName -->
        <xsl:param name="valueofradio" /> <!-- sampleValue -->
        <xsl:variable name="newlist">
              <xsl:choose>
                  <xsl:when test="contains($list, $delimiter)">
                    <xsl:value-of select="normalize-space($list)" />
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="concat(normalize-space($list), $delimiter)"/>
                  </xsl:otherwise>
              </xsl:choose>
          </xsl:variable>
          <!-- problem is these two lines. When I assign something else it works.-->
          <xsl:variable name="first" select="substring-before($newlist, $delimiter)" />
          <xsl:variable name="remaining" select="substring-after($newlist, $delimiter)" />
          <xsl:element name="input">
            <xsl:attribute name="type">radio</xsl:attribute>
            <xsl:attribute name="name"><xsl:value-of select="$nameofradio"/></xsl:attribute>
            <xsl:attribute name="value"><xsl:value-of  select="$first"/></xsl:attribute>
            <xsl:choose>
                <xsl:when test="@hassection='true'">
                    <xsl:attribute name="onclick">showHiddenTable(this.value);validateFormElement(this.name,this.value);</xsl:attribute>        
                </xsl:when>
                <xsl:when test="$valueofradio = $first">
                    <xsl:attribute name="checked">checked</xsl:attribute>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:attribute name="onclick">validateFormElement(this.name,this.value)</xsl:attribute>        
                </xsl:otherwise>
            </xsl:choose>

          </xsl:element>
          <xsl:value-of select="$first" />
          <xsl:if test="$remaining">
              <xsl:call-template name="createRadioButton">
                  <xsl:with-param name="list" select="$remaining" />
                  <xsl:with-param name="delimiter"><xsl:value-of select="$delimiter"/></xsl:with-param>
                  <xsl:with-param name="nameofradio"><xsl:value-of select="$nameofradio"/></xsl:with-param>
                  <xsl:with-param name="valueofradio"><xsl:value-of select="$valueofradio"/></xsl:with-param>
              </xsl:call-template>
          </xsl:if>
    </xsl:template> 

This simple code does not work on WebKit version: 532.4

When i assign static values to "first" and "remaining" variables, there is no problem. But when it comes to substring-before or substring-after, there comes problem. You can see stackoverflow question for detailed answers. It has been tried in 9 different XSLT processors by Dimitre Novatchev, and again there is no problem.
http://stackoverflow.com/questions/5271266/substring-before-and-substring-after-problem-in-webkit-engine-based-browser

Thanks
Yusuf Koseoglu
Comment 1 Alexey Proskuryakov 2011-03-11 11:56:33 PST
Could you please attach a full test case that one could just open in a browser to see if it fails or passes?

Also, WebKit just uses libxslt - can you reproduce this with command line xsltproc?
Comment 2 Ahmad Saleem 2023-04-27 12:53:56 PDT
We do have now tests for substring-before() and substring-after() in WPT and STP168 passes them:

https://wpt.fyi/results/domxpath?label=master&label=experimental&aligned&q=xpath

It might be genuine issue but I think now without reproducible testcase, it would be difficult to track and fix.

@ap - should we mark this as "RESOLVED LATER" or 'RESOLVED WONTFIX'?