Re: [xsl] variable outside a for-each loop: second try

Subject: Re: [xsl] variable outside a for-each loop: second try
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 21 Sep 2007 15:51:32 +0200
Mathieu Malaterre wrote:

Thanks,


This should close the thread. I don't think I was able to describe
my problem correctly using both your solution and the xsl:transform I
am not getting what I called the 'last' preceeding entry.

I think you described it fine. My code is just buggy. Here's a solution. But it doesn't "feel" as the correct (i.e., best or xslt-like) solution, it perfectly fits the task:


<xsl:template match="row">
<entry ie="{
(entry[1]/para[. != ''] , reverse(preceding-sibling::row/entry[1]/para[. != ''])[1])[1]}"
module="{entry[2]/para}" reference="{entry[3]/para}"
usage="{entry[4]/para}"/>
</xsl:template>


It will output the following:

<table>
  <entry ie="Col1 A" module="Col2 A" reference="" usage=""/>
  <entry ie="Col1 A" module="Col2 B" reference="" usage=""/>
  <entry ie="Col1 A" module="Col2 C" reference="" usage=""/>
  <entry ie="Col1 D" module="Col2 D" reference="" usage=""/>
  <entry ie="Col1 E" module="Col2 E" reference="" usage=""/>
  <entry ie="Col1 E" module="Col2 F" reference="" usage=""/>
  <entry ie="Col1 E" module="Col2 G" reference="" usage=""/>
</table>


That's the problem with document order. Most of the times that does precisely what you want, but sometimes you want it the other way. Hence the reverse() keyword.


And I just found out that Saxon (i.e., Java JVM) easily does https. All I did was replacing the previous variable I had with a reference to your document online. Now is this versatile or what!

<xsl:variable name="input" select="document('https://gdcm.svn.sourceforge.net/svnroot/gdcm/Sandbox/xslt/dummy.xml')" />

Don't you just love XSLT / XPath! :D

Cheers,
-- Abel Braaksma

Current Thread