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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.