[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Replace blank rows
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|