[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Lookup, eliminating duplicates and sorting
Dimitre's solution is brilliant..
Here is a solution using the node-set extension function: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:common="http://exslt.org/common" exclude-result-prefixes="common"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/a"> <e3> <xsl:variable name="rtf"> <xsl:for-each select="e1/b"> <b> <xsl:choose> <xsl:when test="../../e2/f/@c = ."> <xsl:value-of select="../../e2/f[@c = current()]/@b1" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="." /> </xsl:otherwise> </xsl:choose> </b> </xsl:for-each> </xsl:variable> <xsl:for-each select="common:node-set($rtf)/b[not(. = preceding-sibling::b)]"> <xsl:sort select="." /> <b2><xsl:value-of select="." /></b2> </xsl:for-each> </e3> </xsl:template> </xsl:stylesheet> Regards, Mukul On 7/20/06, Manfred Staudinger <manfred.staudinger@xxxxxxxxx> wrote: Hi list, xslt 1.0 - I've a set of nodes, for which I want a. to replace some values (most will not change), then b. eliminate the duplicates and sort them. Sample input xml: <?xml version="1.0" encoding="UTF-8" ?> <a> <e1> <b>abc</b> <b>abd</b> <b>abe</b> <b>abf</b> <b>abg</b> <b>abh</b> <b>abd</b> </e1> <e2> <f c="abe" b1="abc"/> <f c="abf" b1="abj"/> <f c="abg" b1="abi"/> <f c="abh" b1="abi"/> </e2> </a> The input table _e1_ will be transformed using _f_ to <e1> <b>abc</b> <b>abd</b> <b>abc</b> <b>abj</b> <b>abi</b> <b>abi</b> <b>abd</b> </e1> and finally should become === what I would like to have === <e3> <b2>abc</b2> <b2>abd</b2> <b2>abi</b2> <b2>abj</b2> </e3> The text nodes represent URI's and are then used to create html links. So far I was only able to write in 2 different task what should be done in one:
|
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
|