473,224 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Unable to update variable

I am having difficulty updating a variable page-time-stamp in the
following snippit. The variable time-stamp is initialized from the
attribute time-stamp from the log element. Some of the page elements
(children of log) in my XML source have a time-stamp attribute, so I
want to use the time-stamp from the page for the page-time-stamp
value. I use an xsl:choose/xsl:when/xsl:otherwise combination to setup
an if/else statement to select the page-time-stamp value. When I run
this template, the page-time-stamp value never changes. I only
displays the initial time-stamp value from the log element. Can anyone
help me?

Kevin

<xsl:template match="log">

<xsl:variable name="application-name" select="@application-name"/>
<xsl:variable name="application-version" select="@application-
version"/>
<xsl:variable name="time-stamp" select="@time-stamp"/>

<xsl:variable name="application-string">
<xsl:value-of select="$application-name"/><xsl:textv</
xsl:text><xsl:value-of select="$application-version"/>
</xsl:variable>

<fo:root>

<fo:layout-master-set>
<fo:simple-page-master master-name="standard-page" page-
height="8.5in" page-width="11.0in" margin-top="0.5in" margin-
bottom="0.5in" margin-left="0.5in" margin-right="0.5in">
<fo:region-body region-name="xsl-region-body" margin-top="0.25in"/
>
<fo:region-before region-name="xsl-region-before" extent="0.25in"/
>
</fo:simple-page-master>
</fo:layout-master-set>

<xsl:for-each select="page">

<xsl:variable name="page-number" select="position()"/>

<xsl:choose>
<xsl:when test="@time-stamp">
<xsl:variable name="page-time-stamp" select="@time-stamp"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="page-time-stamp" select="$time-stamp"/>
</xsl:otherwise>
</xsl:choose>

<fo:page-sequence master-reference="standard-page">

<xsl:if test="$page-number &gt; 1">
<fo:static-content flow-name="xsl-region-before">
<fo:table font-family="Helvetica, sans-serif" font-
size="8pt" inline-progression-dimension="100%" table-layout="fixed">
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="left">
<fo:block><xsl:value-of
select="$application-string"/></fo:block>
</fo:table-cell>
<fo:table-cell text-align="center">
<fo:block><xsl:value-of select="$page-
time-stamp"/></fo:block>
</fo:table-cell>
<fo:table-cell text-align="right">
<fo:block>Page <xsl:value-of
select="$page-number"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
</xsl:if>
Jun 27 '08 #1
2 2984
On Jun 3, 11:35 am, Kevin <Kevin.S.Par...@alumni.utexas.netwrote:
I am having difficulty updating a variable page-time-stamp in the
following snippit. The variable time-stamp is initialized from the
attribute time-stamp from the log element. Some of the page elements
(children of log) in my XML source have a time-stamp attribute, so I
want to use the time-stamp from the page for the page-time-stamp
value. I use an xsl:choose/xsl:when/xsl:otherwise combination to setup
an if/else statement to select the page-time-stamp value. When I run
this template, the page-time-stamp value never changes. I only
displays the initial time-stamp value from the log element. Can anyone
help me?

Kevin

<xsl:template match="log">

<xsl:variable name="application-name" select="@application-name"/>
<xsl:variable name="application-version" select="@application-
version"/>
<xsl:variable name="time-stamp" select="@time-stamp"/>

<xsl:variable name="application-string">
<xsl:value-of select="$application-name"/><xsl:textv</
xsl:text><xsl:value-of select="$application-version"/>
</xsl:variable>

<fo:root>

<fo:layout-master-set>
<fo:simple-page-master master-name="standard-page" page-
height="8.5in" page-width="11.0in" margin-top="0.5in" margin-
bottom="0.5in" margin-left="0.5in" margin-right="0.5in">
<fo:region-body region-name="xsl-region-body" margin-top="0.25in"/

<fo:region-before region-name="xsl-region-before" extent="0.25in"/

</fo:simple-page-master>
</fo:layout-master-set>

<xsl:for-each select="page">

<xsl:variable name="page-number" select="position()"/>

<xsl:choose>
<xsl:when test="@time-stamp">
<xsl:variable name="page-time-stamp" select="@time-stamp"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="page-time-stamp" select="$time-stamp"/>
</xsl:otherwise>
</xsl:choose>

<fo:page-sequence master-reference="standard-page">

<xsl:if test="$page-number &gt; 1">
<fo:static-content flow-name="xsl-region-before">
<fo:table font-family="Helvetica, sans-serif" font-
size="8pt" inline-progression-dimension="100%" table-layout="fixed">
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="left">
<fo:block><xsl:value-of
select="$application-string"/></fo:block>
</fo:table-cell>
<fo:table-cell text-align="center">
<fo:block><xsl:value-of select="$page-
time-stamp"/></fo:block>
</fo:table-cell>
<fo:table-cell text-align="right">
<fo:block>Page <xsl:value-of
select="$page-number"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
</xsl:if>
I figured it out. I needed to restructure the variable definition of
page-time-stamp.
<xsl:variable name="page-time-stamp">
<xsl:choose>
<xsl:when test="@time-stamp">
<xsl:value-of select="@time-stamp"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$time-stamp"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Jun 27 '08 #2
Kevin wrote:
I figured it out. I needed to restructure the variable definition of
page-time-stamp.
Exactly. XSLT variables are single-assignment and their scope is limited
to the descendants of their parent element. To use conditionals when
setting a variable, you have to make the value conditional, not the
assignment.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update...
5
by: Wing | last post by:
Hi all, I am writing a function that can change the value "Quantity" in the selected row of MS SQL table "shoppingCart", my code is showing below ...
1
by: xaime | last post by:
Hi all, I have the code below. This is doing what I want, but always has the following exception: Update unable to find TableMapping or Datatable 'mytable' The code I'm using is: Try
4
by: René Kabis | last post by:
People, I am at my wit's end. I am using the exact code from http://aspnet.4guysfromrolla.com/articles/071002-1.aspx And yet, the code does not manage to update the database. When I go to...
17
by: rdemyan via AccessMonster.com | last post by:
With A2003, I'm having trouble accessing files in a folder on another computer where back-end files, update files, etc are located. Here's the scenario: 1) Computer #1 - A2003 2) Computer #2 -...
9
by: Jim in Arizona | last post by:
I get this error: Unable to cast object of type 'System.Web.UI.HtmlControls.HtmlInputText' to type 'System.Web.UI.WebControls.TextBox'. Using this code: Dim test3 As TextBox test3 =...
0
by: Pieter | last post by:
Hi, I'm using NHibernate 1.2 (CR1), and I'm using a custom list (inherited from BindingList(Of T) ) for all my lists. The NHibernate documentation told me that I had to implement...
2
by: kashigal | last post by:
<? session_start(); require("db.php"); mysql_connect(MACHINE, USER, ''); mysql_select_db(DBNAME); $username = $_SESSION; $pwd =$_SESSION;
1
by: Markw | last post by:
Hi folks I think I've got a variable problem but not 100% sure. Background: I took the CMS example from chapter 6 in "Build your Own Database Driven Website Using PHP&MySQL" and have attempted to...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.