Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    1,202

    [XSLT] Confronto dinamico

    Ciao, ho un file xsl con un parametro, e ho necessità di fare un confronto (usando xsl:if o qualunque altra cosa) con il valore di questo parametro.
    Il problema è che non posso utilizzare xsl:value-of nel confronto, e nemmeno le parantesi graffe...
    Come posso fare?

    Esempio:
    codice:
    <xsl:param name="chiave" select="'default value'"/>
    
    <xsl:template match="/">
    	
    
    	Qui mi restituisce il valore: <xsl:value-of select="$chiave"/>
    	
    
    	Qui invece no:
            <xsl:apply-templates select="database/album[nome = '{$chiave}']" />
    </xsl:template>
    Stessa cosa se uso <xsl:if test="nome='{$chiave}'">

    Grazie
    Debian GNU/Linux sid
    Publishing a theory should not be the end of one's conversation with the universe, but the beginning. (Eric S. Raymond)
    Kernel 2.6.14-ck1

  2. #2
    Le { } sono un modo alternativo per assegnare attributi, anzichè usare xsl:attribute. In questo caso non vanno usate. Quindi:
    <xsl:apply-templates select="database/album[nome = $chiave]" />
    <xsl:if test="nome = $chiave">

    Controlla anche che non si debba scrivere
    <xslaram name="chiave">default value</xslaram> anzichè
    <xslaram name="chiave" select="'default value'"/> (non mi ricordo...)

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    1,202
    Grazie mille, funziona
    Debian GNU/Linux sid
    Publishing a theory should not be the end of one's conversation with the universe, but the beginning. (Eric S. Raymond)
    Kernel 2.6.14-ck1

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.