This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Checking the text nodes just preceding the context
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Checking the text nodes just preceding the context
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Thu, 27 Sep 2001 13:01:36 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
> I have a series of prose documents that have some semantic
> markup that will
> be replaced with a string. Since I need to maintain proper
> capitalization I
> need to check the text that immediately precedes the context
> to see if it
> ends in a period ( or a period and a space).
>
> Any ideas how to do this?
>
<xsl:template match="foo">
<xsl:variable name="prev"
select="normalize-space(preceding-sibling::text())"/>
<xsl:choose>
<xsl:when test="substring($prev, $string-length($prev), 1)='.'">
<xsl:text>Foo</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>foo</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list