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

Replace blank rows

Subject: Replace blank rows
From: "Kim Tran" <tav1210@xxxxxxxxxxx>
Date: Mon, 07 Apr 2003 14:11:17 -0700
kim tran
Hi,Can somebody help me with the following issue: I want to replace my blank rows with the values from the preceeding non-blank rows. A blank row is a row containing all empty cells.

My xml is as follows:
<row>
 <column name="firstname">K1</column>
 <column name="lastname">L1</column
</row>
<row>                               --> Empty Row contains empty cells
 <column name="firstname></column>  --> These should be replaced by
 <column name="lastname></column>   --> "K1" and "L1" from prev. row.
</row>
<row>                                --> Empty row again.
 <column name="firstname></column>
 <column name="lastname></column>
</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?

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 version="1.0">

<xsl:output method="xml"/>

<xsl:param name="fillCell" select="'N'"/>

<xsl:template match="/">
<Document>
<xsl:for-each select="Document/row">
<!-- To determine whether the row contains all empty cells. If so, STR must be returned as '' --->
<xsl:variable name="STR">
<xsl:apply-templates select="column" mode="row"/>
</xsl:variable>


 <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]"/>
   </xsl:when>
 </xsl:choose>

</xsl:for-each>
</Document>

</xsl:template>

<xsl:template match="text()" mode="row">
<xsl:value-of select="."/>
</xsl:template>


</xsl:stylesheet>




_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus



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.