[xsl] choose an "artificial" root node

Subject: [xsl] choose an "artificial" root node
From: "Fr\id\iric SCHWEBEL" <schwebel@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Feb 2001 18:00:26 +0100
Hi folks,

Thanks a lot for all your quick replies. I have a last question (today :o) )
: in my xml files, the root node is always <theme>, with a <title> child and
many other. Let's say it's a math lesson, there's a math <theorem> that
comes along with its <demonstration> and 2 <examples>. If the user has
choosen "full presentation", no problem, everything is displayed, I can
handle it :) but if he has chosen "minimal presentation", only what's really
important is displayed (so, only the theorem itself) and the examples and
the demo are links and should be displayed in another window when the user
clicks on it.

So I thought this would work :

<xsl:template match="theme">
        <xsl:when test="not($id)">
            <CENTER><H1><xsl:apply-templates select="titre" /></H1></CENTER>
            <xsl:apply-templates select="*[not(self::titre)]" />
            <xsl:apply-templates select="//*[generate-id()=$id]" />
<xsl:template match="demonstration">
    <xsl:variable name="demoid">
        <xsl:value-of select="generate-id()" />

        <xsl:when test="$id=$demoid">
            <xsl:apply-templates />
            <xsl:if test="$contenu='complet'">
                <xsl:apply-templates />
            <xsl:if test="$contenu!='complet'">
                <P><A HREF="{$NomDoc}?id={$demoid}"


So, as you see, when there's no "id" param in the URL, the <demonstration>
tag becomes a link to the same URL with its id as a parameter. And when the
url as an id param, the <theme> tag applies the templates for the node which
generate-id () is equal to the $id param.

I thought it would work.... but the generated id is different each time the
document is loaded ! What is an id good for if it changes everytime ? And do
you know how I could achieve what I want ?

Thanks a lot for any reply.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread