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]

RE: Checking the text nodes just preceding the context


> 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


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