[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] choose an "artificial" root node
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:choose> <xsl:when test="not($id)"> <CENTER><H1><xsl:apply-templates select="titre" /></H1></CENTER> <xsl:apply-templates select="*[not(self::titre)]" /> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="//*[generate-id()=$id]" /> </xsl:otherwise> </xsl:choose> </xsl:template> .............. <xsl:template match="demonstration"> <xsl:variable name="demoid"> <xsl:value-of select="generate-id()" /> </xsl:variable> <xsl:choose> <xsl:when test="$id=$demoid"> <H1>Demo</H1> <xsl:apply-templates /> </xsl:when> <xsl:otherwise> <xsl:if test="$contenu='complet'"> <xsl:apply-templates /> </xsl:if> <xsl:if test="$contenu!='complet'"> <P><A HREF="{$NomDoc}?id={$demoid}" TARGET="_blank">Demonstration</A></P> </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:template> ................ 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. Frédéric 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
|