[xsl] Get value from $Variable

Subject: [xsl] Get value from $Variable
From: XSL-List <xsl-list@xxxxxxxxxx>
Date: Tue, 17 Mar 2009 10:45:44 +0100
Hi there,

I'm currently trying to make my code smarter, and sometimes template
calls are okay, but other times its just too much.

I have the following (sample XSL):

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output method="html" omit-xml-declaration="yes"
encoding="UTF-8" indent="yes"/>
    <xsl:param name="Internal_CSS"/>
    <xsl:param name="Is_Voucher"/>

    <xsl:variable name="Language_Id" select="Fee_Root/Fees/@Language_Id"/>
    <xsl:variable name="Language"
select="document('language.xml')/Languages/Language[@Language_Id=$Language_Id]"/>
    <xsl:template match="/">

    ......

    </xsl:template>
</xsl:stylesheet>

As you can see i declare a global variable called Language_Id based on
the input XML, and then I declare another variable called Language based
on an external file and the Language_Id variable.

This works like a charm!

However, later in the code i use this template:

    <xsl:for-each select="Weekdays/Day">
         <xsl:call-template name="tplWeekday">
              <xsl:with-param name="Id" select="@Id"/>
              <xsl:with-param name="current" select="position()"/>
              <xsl:with-param name="maximum" select="count(../Days)"/>
         </xsl:call-template>
    </xsl:for-each>

    ...........

    <xsl:template name="tplWeekday">
        <xsl:param name="Id"/>
        <xsl:param name="current"/>
        <xsl:param name="maximum"/>
        <xsl:value-of select="$Language/Weekdays/Weekday[@Id = $Id]"/>
        <xsl:if test="$current &lt; $maximum">,</xsl:if>
    </xsl:template>
 
This code was crappy and has been changed to this:

     <xsl:for-each select="Weekdays/Day">
          <xsl:variable name="Current_Id" select="@Id"/>
          <xsl:value-of select="$Language/Weekdays/Weekday[@Wd_Id =
$Current_Id]"/><xsl:if test="following-sibling::*[1]">, </xsl:if>
     </xsl:for-each>

But I would like to skip the Current_Id variable, but when I do like this:

     <xsl:for-each select="Weekdays/Day">
          <xsl:value-of select="$Language/Weekdays/Weekday[@Wd_Id =
@Id]"/><xsl:if test="following-sibling::*[1]">, </xsl:if>
     </xsl:for-each>

I get the same day of the week (1) with this query. Is it possible to
get it some other way without the Variable?


Med venlig hilsen/Best regards
Michael Nielsen

Se min fotoblog pe:

www.photofolio.dk - A study in photography
<http://feeds.feedburner.com/%7Er/photofoliodk/%7E6/1>


Szabo, Patrick (LNG-VIE) wrote:
> Hi XSLT-List, 
>
> I4m using XSLT 2.0 and Saxon 9...
>
> I have an xml file which includes base64-strings.
> I want to serialize these strings to PDF-files. I4ve got a java-class to do that (dind4t write it myself), but i can4t figure out how i should implement it into my xslt.
>
> The package that includes the class ist called "GLP"
> The class is called "Base64DecodeFromXML"
>
> What i4ve already done:
>
> -Set the classpath to R:\Produktion\Tools\JTDS\jtds-1.2.jar; R:\Produktion\Tools\LexisNexis\GLP.jar
>
> -Namespace created in my xsl: xmlns:myTest="GLP.Base64DecodeFromXML"
>
> -calling class in my xsl: <xsl:value-of select="myTest:main($arg1, $arg2, $arg3)"/>
>
> It tells me: "Cannot find a mathing 3-argument function named {GLP.Base64DecodeFromXML}main()"
>
> I4ve already checked saxonica.com but...
>
> Help anyone ?!
>
> cheers 
>  
>
> Patrick Szabo
> EPD / XSLT Konvertierung
> Tel.: +43-1-534 52-1573
> Fax.: +43-1-534 52-1573
> patrick.szabo@xxxxxxxxxxxxx
>
> LexisNexis Verlag ARD Orac GmbH & Co KG
> Marxergasse 25, 1030 Wien
> FN 8333f, Handelsgericht Wien
> www.lexisnexis.at <http://www.lexisnexis.at/> 
>
>  <file://C:\Dokumente und Einstellungen\szaboP\Anwendungsdaten\Microsoft\Signatures\LN Vienna signature-Dateien\image001.jpg> 

Current Thread