xsl-list
[Top] [All Lists]

Re: [xsl] Connecting the Source and Destination fields

2007-08-20 01:51:53
On 8/20/07, Yaswanth <yaswanth(_dot_)mtrx(_at_)gmail(_dot_)com> wrote:

Hi Ronan and Andrew,
Thanks for the Help.
I am able to get the exact result .
I am working on it . I think I need to understand XSL:Key ..
I will look into it..
Ronan , Thanks for the brilliant solution !

If you did want to use a  key then all you need to do is define the key:

<xsl:key name="conn-by-source" match="connection" use="@source"/>

then put this wherever you want your output:

<xsl:text>event.0</xsl:text>
<xsl:apply-templates select="key('conn-by-source', 'event.0')"/>

and have this template:

<xsl:template match="connection">
        <xsl:text> -> </xsl:text>
        <xsl:value-of select="@destination"/>
        <xsl:apply-templates select="key('conn-by-source', @destination)"/>
</xsl:template>

and thats it - no need for recursive named templates: the "recursion"
stops when the key doesn't return an element for a given string.

-- 
http://andrewjwelch.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--