# If you apply the function string() to the node "elements" the
# result is "text1text2text3"
#
# string(//elements) = "text1text2text3"
#
# Yov(_at_)nis
You are right, but I'm not sure how this information is relevant.
Michael Kay
#
# -----Original Message-----
# From: Michael Kay [mailto:mhk(_at_)mhk(_dot_)me(_dot_)uk]
# Sent: Wednesday, March 24, 2004 8:56 AM
# To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
# Subject: RE: [xsl] xsl:key use attribute using string()
# causes missing all matches except the first one
#
# When you apply string() to a node-set containing more than
# one node it returns the string value of the first node in the
# node-set.
#
# Michael Kay
#
# # -----Original Message-----
# # From: Xiaocun Xu [mailto:xiaocunxu(_at_)yahoo(_dot_)com] # Sent: 24
# March 2004 16:42 # To: xsl-list # Subject: [xsl] xsl:key use
# attribute using string() causes # missing all matches except
# the first one # # Hi, # # I recently had an interesting
# discovery with xsl:key use # attribute using string().
# # I been using string() in xsl:key use attribute extensively
# # since it allows me to retrieve records using the key value
# # "". But in the following example, using string() caused me
# # to miss all matches except the first one. I am not sure
# what # is the reason for this, would appreciate if anyone
# could shed # light on this behavior. Example input XML and
# XSLT below.
# #
# # thanks,
# # Xiaocun
# #
# # input XML:
# # <range>
# # <row row="16">
# # <cell column="1">supplier</cell>
# # <cell column="2">s3</cell>
# # <cell column="3">item</cell>
# # <cell column="4">
# # <subcell>item1</subcell>
# # <subcell>item2</subcell>
# # <subcell>item3</subcell>
# # </cell>
# # <cell column="5">s3_AM1</cell>
# # <cell column="6">accepted</cell>
# # </row>
# # <row row="17">
# # <cell column="1">supplier</cell>
# # <cell column="2">s4</cell>
# # <cell column="3">item</cell>
# # <cell column="4">
# # <subcell>item1</subcell>
# # <subcell>item2</subcell>
# # <subcell>item4</subcell>
# # </cell>
# # <cell column="5">s4_AM1</cell>
# # <cell column="6">accepted</cell>
# # </row>
# # <row row="18">
# # <cell column="1">supplier</cell>
# # <cell column="2">s5</cell>
# # <cell column="3">item</cell>
# # <cell column="4">item1</cell>
# # <cell column="5">s5_AM1</cell>
# # <cell column="6">accepted</cell>
# # </row>
# # </range>
# #
# # complete XSLT without using string():
# # <xsl:stylesheet version="1.0"
# # xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
# # xmlns:fo="http://www.w3.org/1999/XSL/Format">
# # <xsl:key name="itemInvitesKey"
# # match="//row[cell[(_at_)column=3] = 'item']"
# # use="cell[(_at_)column=4]"/>
# # <xsl:key name="itemInvitesKey"
# # match="//row[cell[(_at_)column=3] = 'item']"
# # use="(cell[(_at_)column=4]/subcell)"/>
# # <xsl:template match="/">
# # <xsl:apply-templates select="range"/>
# # </xsl:template>
# # <xsl:template match="range">
# # <xsl:text>item1
</xsl:text>
# # <xsl:for-each select="key('itemInvitesKey', 'item1')">
# # <xsl:value-of select="cell[(_at_)column=2]"/>
# # <xsl:text>
</xsl:text>
# # </xsl:for-each>
# # <xsl:text>
</xsl:text>
# # <xsl:text>item2
</xsl:text>
# # <xsl:for-each select="key('itemInvitesKey', 'item2')">
# # <xsl:value-of select="cell[(_at_)column=2]"/>
# # <xsl:text>
</xsl:text>
# # </xsl:for-each>
# # </xsl:template>
# # </xsl:stylesheet>
# #
# # correct output:
# # item1
# # s5
# # s3
# # s4
# #
# # item2
# # s3
# # s4
# #
# # Exact same XSLT as above, except xsl:key use attribute
# using string():
# # <xsl:key name="itemInvitesKey"
# # match="//row[cell[(_at_)column=3] = 'item']"
# # use="string(cell[(_at_)column=4]/subcell)"/>
# #
# # Output: same as above, except no matches were returned
# except # for the first key (item1) # item1 # s5 # s3 # s4 # #
# item2 # # __________________________________
# # Do you Yahoo!?
# # Yahoo! Finance Tax Center - File online. File on time.
# # http://taxes.yahoo.com/filing.html
# #
# #
# --+------------------------------------------------------------------
# # XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
# # You are subscribed as: mhk(_at_)mhk(_dot_)me(_dot_)uk
# # To unsubscribe, go to:
# #
http://lists.mulberrytech.com/unsub.php/xsl-list/mhk(_at_)mhk(_dot_)me(_dot_)uk
# # or e-mail:
# #
<mailto:xsl-list-unsubscribe-mhk=mhk(_dot_)me(_dot_)uk(_at_)lists(_dot_)mulberrytech(_dot_)com>
# # --+--
# #
# #
#
#
# --+------------------------------------------------------------------
# XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
# You are subscribed as: yovanis(_at_)cimex(_dot_)com(_dot_)cu To unsubscribe,
go to:
#
http://lists.mulberrytech.com/unsub.php/xsl-list/yovanis(_at_)cimex(_dot_)com(_dot_)cu
# or e-mail:
#
<mailto:xsl-list-unsubscribe-yovanis=cimex(_dot_)com(_dot_)cu(_at_)lists(_dot_)mulber
# rytech.com
# >
# --+--
#
#
#
#
# --+------------------------------------------------------------------
# XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
# You are subscribed as: mhk(_at_)mhk(_dot_)me(_dot_)uk
# To unsubscribe, go to:
#
http://lists.mulberrytech.com/unsub.php/xsl-list/mhk(_at_)mhk(_dot_)me(_dot_)uk
# or e-mail:
#
<mailto:xsl-list-unsubscribe-mhk=mhk(_dot_)me(_dot_)uk(_at_)lists(_dot_)mulberrytech(_dot_)com>
# --+--
#
#