XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Peter LarbalestierSubject: position()=last()
Author: Peter Larbalestier
Date: 09 Aug 2004 06:38 PM
I do not understand why the line of the code is NOT being tested
as TRUE.

Refer lines 153: in the XSLT

<xsl:when test="position()=last()">
<u>
<xsl:value-of select="n:Total"/>
</u>
</xsl:when>

I want the "underline" to appear in my HTML output.

Files attached.

Thanks

Peter


DocumentXSLT.zip

Postnext
Ivan PedruzziSubject: position()=last()
Author: Ivan Pedruzzi
Date: 09 Aug 2004 09:44 PM

Because the xsl:choose instruction is embedded inside an outer xsl:when (xsl:when test="n:Type='D' and n:Text != 'Total' ")
In other words, in the last loop interaction (position()=last()) the last element <n:FeeLine> has n:Type = GT so it gets never evaluated.

Hope this helps
Ivan

Postnext
Peter LarbalestierSubject: position()=last()
Author: Peter Larbalestier
Date: 09 Aug 2004 09:52 PM
Thanks for the Help Ivan.

The XML value that I want underlined, and which gets evaluated is:

<n:Text>Filing Fee:</n:Text>
<n:Total>320.00</n:Total>
<n:Type>D</n:Type>

This element is part of the inner test.

So I must be misunderstanding the function "position()=last()"

meaning, becuase I test="where n:Type='D' and n:Text !='Total'

with this test I should only return 2 elements.

Thereby last() should return me

<n:Text>Filing Fee:</n:Text>
<n:Total>320.00</n:Total>
<n:Type>D</n:Type>

Am I missing something here with those functions?

test="where n:Type='D' and n:Text !='Total'

Anoth example if I did count(.), I would guess that this should return
2 ?


Thanks

Pete

Postnext
Ivan PedruzziSubject: position()=last()
Author: Ivan Pedruzzi
Date: 10 Aug 2004 02:16 AM

The xsl:choose doesn't restrict the number of time you execute the loop.

You need you apply a predicate to do so

<xsl:for-each select="n:TaxInvoices/n:Invoice/n:Fees/n:FeeLine[n:Type='D' and n:Text != 'Total']" xml:space="">
<tr>
<td colSpan="96"><xsl:value-of select="n:Text"/></td>
<td align="right" colSpan="4">
<xsl:choose>
<xsl:when test="position()=last()">
<u><xsl:value-of select="n:Total"/></u>
</xsl:when>
<xsl:otherwise><xsl:value-of select="n:Total"/></xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>

Most of your loops that extract totals can be re-written as single instruction like that:

<tr>
<td colSpan="96"/>
<td align="right" colSpan="4">
<xsl:value-of select="n:TaxInvoices/n:Invoice/n:Fees/n:FeeLine[n:Type='P' and n:Text = 'Total']/n:Total"/>
</td>
</tr>


Posttop
Peter LarbalestierSubject: position()=last()
Author: Peter Larbalestier
Date: 10 Aug 2004 03:12 AM
brilliant, I will test your answer

Yes, I thought that my loops were not good but I did not have the
answer.

Pete

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.