xsl-list
[Top] [All Lists]

Re: Reusing XML content as I publish

2005-01-28 09:59:56
Tempore 17:37:18, die 01/28/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Nicola Harlow <Nicola(_dot_)Harlow(_at_)pm-group(_dot_)com>:

What I want to do is pick up the text from one of the terms and reuse it
elsewhere in the document by referencing just the glossary item "name",
and getting the term and definition as part of a 'tooltip.'

So you want to create:
<html><body>
You can then <a href="#" class="tooltip Allocate">Allocate Stuff<span>Stuff about allocations</span></a> resources
</body></html>

from input xml:
<root>
<glossary>
<alphagroup>
<alphahead>A</alphahead>
<glossaryitem name="Allocate">
        <term>Allocate Stuff</term>
        <definition>
                <para>Stuff about allocations</para>
        </definition>
</glossaryitem>
</alphagroup>
</glossary>
<body>
You can then <glossarytt name="Allocate"
width="200">Allocate</glossarytt> resources
</body>
</root>


That can easily be done with a 'key':

e.g.
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method = "html" indent = "yes"/>

<xsl:key name="glossary" match="glossaryitem" use="@name"/>

<xsl:template match="/">
<html>
        <body>
                <xsl:apply-templates select="root/body"/>
        </body>
</html>
</xsl:template>

<xsl:template match="glossarytt ">
        <xsl:apply-templates select="key('glossary',@name)"/>
</xsl:template>

<xsl:template match="glossaryitem">
<a href="#" class="tooltip {(_at_)name}">
        <xsl:value-of select="term"/>
        <span>
                <xsl:apply-templates select="definition"/>
        </span>
</a>
</xsl:template>

</xsl:stylesheet>

I hope I got it right now...


regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Deserta faciunt et innovationem appelant

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>