[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Expression Logic Problem
Hello Garrel,
self::node()[1] does not work, because self::node() selects the only the current node --> it's only one, so self::node()[1] is true for every node. position() does not work (I can only guess, because this part of stylesheet is missing) because you apply-templates through either <xsl:apply-templates select="*"/> or <xsl:apply-templates select="item"/> or <xsl:apply-templates select="node()"/>. So you either get only once output of 'Snow White' or nothing because text nodes are counted too. The solution to your problem is a grouping method, for example using preceding-sibling axis or Muenchian Grouping. 1. preceding-sibling: Instead of <xsl:if test="self::node()[1]"> use <xsl:if test="not(preceding-sibling::field/@id = @id)"> 2. Muenchian Grouping: <!-- this is the grouping key --> <xsl:key name="fields" match="field" use="@id"/> <!-- this one is for faster access to resultfields --> <xsl:key name="resultfields" match="resultfield" use="@id"/> <xsl:template match="record"> <xsl:apply-templates select="field[generate-id() = generate-id(key('fields', @id))]" mode="unique"/> </xsl:template> <xsl:template match="field" mode="unique"> <xsl:value-of select="key('resultfields', @id)"/>: <xsl:apply-templates select="key('fields', @id)"/> </xsl:template> <xsl:template match="field"> <xsl:value-of select="."/><br/> </xsl:template> Furthermore I would remove disable-output-escaping, because you don't need it and it's not portable: http://www.dpawson.co.uk/xsl/sect2/N2215.html Regards, Joerg Renick, Garrel wrote: Hello. I'm trying to solve an expression logic problem and I'm stumped. 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
|