Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    128
    Thanks
    0
    Thanked 0 Times in 0 Posts

    <div id="note{@style}">

    I have this xsl file

    I give a default value to a parameter pmStyle = 1

    in my xml file I have <note page="panier" num="1" style="1">

    then I want to change the style depending on this attributes

    it works but only for my first element

    with <div id="note{@style}"> I get <div id="note1">




    but others

    <div class="titreNote{@style}"> are all <div class="titreNote">

    .... the {@style} doesn't work

    do you know why ?

    thank you

    -------------------------------------------------
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xslutput method="html"/>
    <xslaram name="pmPage"/>
    <xslaram name="pmNum"/>
    <xslaram name="pmId"/>
    <xslaram name="pmTarget"/>

    <xslaram name="pmStyle">1</xslaram>

    <xsl:template match="/">

    <xsl:for-each select="//notes/note[@page=$pmPage and @num=$pmNum]">
    <div id="note{@style}">
    <xsl:if test="titre/text()">
    <div class="titreNote{@style}"><xsl:value-of select="titre"/></div>
    </xsl:if>
    <xsl:for-each select="paras/para">
    <xsl:choose>
    <xsl:when test="position()=1">
    <div class="noteH{@style}">
    <xsl:value-of select="."/>
    </div>
    </xsl:when>
    <xsl:when test="position()=last()">
    <div class="noteB{@style}">
    <xsl:value-of select="."/>
    </div>
    </xsl:when>
    <xsltherwise>
    <div class="noteM{@style}">
    <xsl:value-of select="."/>
    </div>
    </xsltherwise>
    </xsl:choose>
    </xsl:for-each>
    <xsl:for-each select="liens/lien[@id=$pmId and @target=$pmTarget]">
    <a href="{url}" class="lnkNote{@style}">
    <xsl:value-of select="texte"/>
    </a>
    </xsl:for-each>
    </div>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    variable

    into your first for_each

    <xsl:variable name="st" select="@style"/>
    <div id="note{$st}">


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •