|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
character
* a space after the normalized string if there is a normalized
string and the original string had whitespace as its last
character
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:if>
<xsl:value-of select="$normalizedString" />
<xsl:if test="not(normalize-space(substring(., string-length())))">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
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]" />
</xsl:template>
(assuming that link elements don't nest inside each other, or if they
do you want them sequentially numbered)
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
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
|

Cart








