This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: a nicer total sibling count than this


Stewart,

At 03:39 PM 9/18/2002, you wrote:
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))'?
Sure:

<xsl:if test="count(../def) > 1">

just counts the def children of the parent. If there are more than the current def, the test passes.

Cheers,
Wendell


======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]