This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Truncating output of a node
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Truncating output of a node
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Thu, 19 Apr 2001 10:35:07 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
> I am trying to output the first n sentences of a node. I have
> tried using
> for-each with a conditional to stop output but have had no luck.
>
> Given the following XML fragment, what is the best way to
> output only the
> first n sentences? Note that the node has both text and child nodes.
>
Write a recursive template that takes the text and n as parameters; in this
template,
if n>0, output the first sentence (using substring-before), then make a
recursive call on the the same template, passing the remaining text (using
substring-after) and n-1 as the parameters.
Mike Kay
Software AG
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list