Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 29th, 2006, 07:43 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default Variable equations

Hallo again,

I just want to know if how I can write an if statement so that I can compare the attribute value with a given value. For example I have:

<xsl:variable name="date1">Montag</xsl:variable>
<xsl:variable name="date2">Dienstag</xsl:variable>
<xsl:variable name="date3">Mittwoch</xsl:variable>
<xsl:variable name="date4">Donnerstag</xsl:variable>
<xsl:variable name="date5">Frieitag</xsl:variable>
<xsl:variable name="date6">Samstag</xsl:variable>
<xsl:variable name="date7">Sonntag</xsl:variable>

as variables and I am haväng an attribute named @Wochentag and I want to write an if statement which is equal to this (in Java)

if(Wochentag.equals(date1)) {} like

  <xsl:if test="@Wochentag='$datum1'"><xsl:value-of select="$day1"/></xsl:if>

I know this code above is wrong but I hope I could make you understand what I am trying to do.
How can I do it with <xsl:if>?

Your attitude determines your altitude
__________________
Your attitude determines your altitude
 
Old June 4th, 2006, 05:31 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<xsl:if test="@Wochentag = $date1">

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 8th, 2006, 08:48 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply. I am having a little bug (or let's say a problem) what I did is:

<xsl:template name="Datum" match="/@Wochentag">
            <Wochentag>
                <xsl:if test="@Wochentag=$datum1"><xsl:value-of select="$day1"/></xsl:if>
                 <xsl:if test="@Wochentag=$datum2"><xsl:value-of select="$day2"/></xsl:if>
                 <xsl:if test="@Wochentag=$datum3"><xsl:value-of select="$day3"/></xsl:if>
                  <xsl:if test="@Wochentag=$datum4"><xsl:value-of select="$day4"/> </xsl:if>
                  <xsl:if test="@Wochentag=$datum5"><xsl:value-of select="$day5"/></xsl:if>
                  <xsl:if test="@Wochentag=$datum6"><xsl:value-of select="$day6"/></xsl:if>
                   <xsl:if test="@Wochentag=$datum7"><xsl:value-of select="$day7"/></xsl:if>
                </Wochentag>
 </xsl:template>

---------
<xsl:template match="/">
<xsl:call-template name="Datum"/>
<div id="epoPage"><div id="epoHomeContent">
    <div id="epoWeatherTab">

    <div class="epoWeatherBorderLeft"> <a href="javascript:City('1','10866')"><xsl:if test="$wmo = '10866'"><xsl:attribute name="class" >aktive</xsl:attribute></xsl:if>Munich</a></div>
    <div class="epoWeatherBorderLeft"> <a href="javascript:City('1', '11034')"><xsl:if test="$wmo = '11034'"><xsl:attribute name="class" >aktive</xsl:attribute></xsl:if>Vienna </a></div>
    <div class="epoWeatherBorderLeft"> <a href="javascript:City('1', '06211')"><xsl:if test="$wmo = '06211'"><xsl:attribute name="class" >aktive</xsl:attribute></xsl:if>The Hague</a></div>
    <div class="epoWeatherBorderLeft"> <a href="javascript:City('1', '10384')"><xsl:if test="$wmo = '10384'"><xsl:attribute name="class" >aktive</xsl:attribute></xsl:if>Berlin</a></div></div>

  <div id="epoWeatherContent">

<xsl:for-each select="WETTERONLINE/prognosen/dreitage[@wmo = $wmo]">
   <xsl:for-each select="Tag[@Nummer = $day]">

     <tr>


              <td height="18" colspan="2" align="left" valign="top"><strong>
                   <xsl:value-of select="@Wochentag"/>

So I have 4 cities and when I call this XSL file I am still seeing the date expressions in german but when I switch between the cities then I can see the date values in english. How can I correct this?

Your attitude determines your altitude
 
Old June 8th, 2006, 05:05 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You are calling your named template with "/" (the document node) as the context node, and you are then looking at the attribute @Wochentag. But document nodes do not have attributes. You need to think about what the context node is at each stage of processing.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
assign XSLT variable to a wml variable arunagottimukkala XSLT 2 October 19th, 2007 05:15 AM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
Object variable or With block variable not set tparrish VS.NET 2002/2003 3 May 22nd, 2005 07:40 AM
Object variable or with block variable not set spacy ASP.NET 1.x and 2.0 Application Design 0 September 21st, 2004 12:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.