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

RE: Conditional processing for first and last of a set

Subject: RE: Conditional processing for first and last of a set of elements
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 10 Mar 2004 23:06:50 -0000
xsl last first
I have to admit I'm a little bit sympathetic to you tackling this problem
with disable-output-escaping - it's a gross abuse of the XSLT processing
model, but this is a tough problem to crack if you do it the correct way
with a tree-to-tree transformation, especially for an inexperienced XSLT
developer.

Having said that, your test conditions are obvious nonsense:

test="position()=//br[text()='LineNumberHolder'][position()=1]

What do you expect to achieve by comparing a position (which is always a
number) to a <br/> node (which is always empty)?. And why are you looking
for a <br> element containing the text "LineNumberHolder" - if the input is
XHTML, as you tell us, then no br elements will contain this text. Also, you
are comparing the position not just to the current br element, but to every
br element in the document.

Michael Kay

# -----Original Message-----
# From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-
# list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Munna D
# Sent: 10 March 2004 11:53
# To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
# Subject:  Conditional processing for first and last of a set of
# elements
# 
# Hi everyone,
# I have a series of br elements scattered throughout an xhtml document. I
# would like to change the very first <br> to '<tr><td>', the intervening
# ones to '</td></tr><tr><td>', and the last one to '</td></tr>'
# I have got this template at teh moment
#   <xsl:template match="//br[text()='LineNumberHolder']">
#     <xsl:choose>
#     <xsl:when
# test="position()=//br[text()='LineNumberHolder'][position()=1]">
# 	    <xsl:text disable-output-
# escaping="yes">&lt;tr>&lt;td></xsl:text>
#     </xsl:when>
#     <xsl:when test="position()=//br[text()='LineNumberHolder'][last()]">
# 	    <xsl:text disable-output-
# escaping="yes">&lt;\td>&lt;\tr></xsl:text>
#     </xsl:when>
#     <xsl:otherwise>
# 	    <xsl:text disable-output-
# escaping="yes">&lt;\td>&lt;\tr>&lt;tr>&lt;td></xsl:text>
#     </xsl:otherwise>
#     </xsl:choose>
#   </xsl:template>
# 
# However, it changes all <br> tags to '<\td><\tr><tr><td>'
# Please could someone tell me what I'm doing wrong?
# Thanks,
# Munna
# --
# _______________________________________________
# Get your free email from http://www.iname.com
# 
# 
#  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 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.