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

RE: a nicer total sibling count than this

Subject: RE: a nicer total sibling count than this
From: "Macaulay,Malcolm (US)" <Malcolm.Macaulay2@xxxxxxxxx>
Date: Wed, 18 Sep 2002 15:05:44 -0500
xsl if sibling count
Hi Stewart,

You don't need all the counting stuff. If I understand you correctly, the test is simply: "is there a preceding def element?". If so then there must be 2 or more defs for the word. I.e. the following template should work just as well:

	<xsl:template match="def">
		<xsl:if test="preceding-sibling::def">
			<xsl:element name="strong">
				<xsl:number/>
				<xsl:text>&#160;</xsl:text>
			</xsl:element>
		</xsl:if>
		<xsl:apply-templates/>
	</xsl:template>

Hope that helps.

cheers

Malcolm




-----Original Message-----
From: scruss@xxxxxxxxxxxx [mailto:scruss@xxxxxxxxxxxx]
Sent: Wednesday, September 18, 2002 2:39 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  a nicer total sibling count than this


I'm working with a dictionary marked up in XML. Conventionally, one numbers definitions (def elements here)  only if there are two or more definitions for the given part of speech. 

To my surprise and delight, the following worked, producing heavy def numbers with a following non-break space:

 <xsl:template match="def">
  <xsl:if test="(count(preceding-sibling::def) +   
                 count(following-sibling::def)) >= 1">
   <xsl:element name="strong">
    <xsl:number/>
    <xsl:text>&#160;</xsl:text>
   </xsl:element>
  </xsl:if>
  <xsl:apply-templates/>
 </xsl:template>

Is there a prettier/more efficient way of doing the same thing without resorting to frankly ugly '(count(preceding-sibling::def)+count(following-sibling::def))'?

thanks,
 Stewart



 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.