[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Replace blank rows

Subject: RE: Replace blank rows
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Mon, 7 Apr 2003 16:44:19 -0500
find first empty row
> here is my xslt file.  It works for the first empty non-row.  
> However, since 
> I always replaced it with row[$position-1] (i.e. immediate 
> preceeding row), 
> if there were 2 blank rows together, the second blank row was 
> not replaced 
> correctly because the preceeding row was still empty.
> 
> I have this for-loop.  So, how can I save the non-blank row position?
...
>   <xsl:choose>
>     <xsl:when test="$STR != ''">
>       <xsl:copy-of select="."/>
>     </xsl:when>
>     <xsl:when test="$STR = '' and position() > 0 and $fillCell = 'Y'">
>       <xsl:variable name="pos" select="position() -1"/>
>          <xsl:copy-of select="//Document/row[$pos]"/>

I would not use the $pos variable, but instead,
        <xsl:copy-of select="preceding-sibling::row[string()][1]" />

The [string()] predicate makes sure we select only preceding row nodes
whose string value is not ''.  [1] lets us select the first one, in
reverse-document order from the current node.
I haven't tested this, and I'm afraid of pitfalls related to current
node list and the binding precedence of [], but it seems like it should work.

>     </xsl:when>
>   </xsl:choose>

Lars


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.