RE: [xsl] Forgive the noob

Subject: RE: [xsl] Forgive the noob
From: "Bordeman, Chris" <Chris.Bordeman@xxxxxxxxxxxxxxxxx>
Date: Fri, 8 Aug 2008 15:47:54 -0500
Ok, that clears things up a lot.  Thanks Michael.

Chris Bordeman

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Friday, August 08, 2008 3:43 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Forgive the noob

There's no "up front" in XSLT: no after, no before, no concept of time
at all. It's a stateless language. Concepually, everything happens at
once.
Accordingly, there's no concept of writing to a variable "at the start"
and reading it "later".

Your two <xsl:variable name="buyerfullname"/> instructions are declaring
completely unrelated variables, the only thing they have in common is
that they both have the same name.

Just do the initialisation within the declaration of the global
variable:

<xsl:variable name="buyer"
> select="Contract/Borrowers/Borrower[NumOrder='1']"/>

<xsl:variable name="buyerfullname"
  select="fn:borrowerfullname($buyer)"/>

You could make that

<xsl:variable name="buyerfullname"
  select="if ($buyer) then fn:borrowerfullname($buyer) else ()"/>

but I would personally put the logic for that inside the function.

Current Thread