[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: sorting and selecting the last value
Hello Ming,
there is a difference between <xsl:variable name="foo" select="bar"/> and <xsl:variable name="foo"> <xsl:value-of select="bar"/> </xsl:variable> The first variable stores a node set, the second one a Result Tree Fragment (RTF). You have The same problem with your variable declaration. You can use an extension function to convert a RTF to a node set. If you really only want to have the last node, you can do <xsl:variable name="last-field-value"> <xsl:for-each select="$full_path[contains($dbs_searched, @db)]/*"> <xsl:sort select="."/> <xsl:if test="position()=last()"> <xsl:copy-of select="."/> </xsl:if> </xsl:for-each> </xsl:variable> You create a RTF too, but can access the value through <xsl:value-of select="$last-field-value"/> and copy the node to the output via <xsl:copy-of select="$last-field-value"/>. You can't do node set functions on a RTF. What are you trying with <xsl:for-each select="self::node()[not(.=following::node())]">?? If you sort them and you want to have the last one, you don't need that. If you want to have unique nodes, you can do <xsl:if test="not(. = following-sibling::*)"> to reach the same. If you really need the current content of $field-value as you have it, only as node set, you should think about rearranging your code to use a "correct" grouping method (preceding/following-sibling axis or Muenchian Method). Don't do two things (sorting + grouping) in one step. Regards, Joerg Ming wrote: Hi, XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|