Subject: RE: Formatting text within an element
From: "Mark Giacobbe" <mgiacobbe@xxxxxxxxxxxxxx>
Date: Fri, 18 Aug 2000 12:52:18 -0400
|
Dhruv,
>I was interested in knowing whether it is possible
>to format specific pieces of text within an element's content using XSL
It is possible; it's all about the string functions in XSLT. See ch. 14 of
the XML bible at
http://metalab.unc.edu/xml/books/bible/updates/14.html
or XSLT Programmer's Reference, ch. 7.
For your example
>
><para>
> This publication covers the equipment found in the
> Auxiliary, Blower and Engine Cab Areas (Fig. 1). For
>repair
> or overhaul of specific equipment listed in this
>publication,
> refer to the Backshop Manual.
></para>
The following template will output '(Fig. X)' as an <a> element for Figure
#'s 1-9:
<xsl:template match="para[contains(.,'(Fig.')]">
<p>
<xsl:value-of select="substring-before(.,'(Fig.')"/>
<a>
<xsl:attribute
name="href">http://www.somewhere.org</xsl:attribute>
<xsl:value-of
select="substring(.,string-length(substring-before(.,'Fig.')),8)"/>
</a>
<xsl:value-of select="substring-after(.,')')"/>
</p>
</xsl:template>
mark giacobbe
mgiacobbe@xxxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|