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

Re: Continuing problem

Subject: Re: Continuing problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 1 Nov 2001 16:20:58 +0000
Re:  Continuing problem
Hi John,

> Anyway I rearranged my template to look like the above and it works
> fine. But In my larger work I need to have an template that matches
> "link".

Ah. OK, then you need the info template to just apply templates to
all its children as before, and you need to do some clever business
within the text() template to work out what to do. I think that the
rules are that it should emit the normalized string, plus:

  * a space before the normalized string if there is a normalized
    string and the original string had whitespace as its first

  * a space after the normalized string if there is a normalized
    string and the original string had whitespace as its last

This gives you a template like:

<xsl:template match="text()">
  <xsl:variable name="normalizedString" select="normalize-space()" />
  <xsl:if test="not(normalize-space(substring(., 1, 1)))">
    <xsl:text> </xsl:text>
  <xsl:value-of select="$normalizedString" />
  <xsl:if test="not(normalize-space(substring(., string-length())))">
    <xsl:text> </xsl:text>

By the way:

> <xsl:template match="link">
>   <xsl:apply-templates/>
>   <xsl:text>[</xsl:text>
>   <xsl:value-of select="count(preceding::link)+1"/>
>   <xsl:text>]</xsl:text>
> </xsl:template>

Could be more neatly written as:

<xsl:template match="link">
  <xsl:apply-templates />
  <xsl:number level="any" format="[1]" />

(assuming that link elements don't nest inside each other, or if they
do you want them sequentially numbered)

I hope that helps,


Jeni Tennison

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

Current Thread


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.
First Name
Last Name
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.