[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Truncating output of a node

Subject: RE: Truncating output of a node
From: Jim Schmidt <JSchmidt@xxxxxxxx>
Date: Thu, 19 Apr 2001 12:20:43 -0700
RE:  Truncating output of a node
Hi Wendell and Mike,

Thanks for the responses.

At 10:35 AM 4/19/01, Mike wrote:
> > 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.

I understand the suggestion to use a recursive template to filter
the output. The problem I was having was that the sentences can
contain the <span> tags. It seems to me that the fragments that
are being processed are sometimes text and sometimes the child
tags. I guess I'm confused how the pieces an element are processed
when it has tags mixed with text.


On Thursday, April 19, 2001 6:57 AM, Wendell wrote:

>This will work assuming you have identified some dependable way to delimit 
>sentences in your data. You might assume that the presence of a character 
>"." will indicate the end of a sentence.

Your are right it would normally be difficult but the content is technical
and doesn't usually contain other types of punctuation such as ? and !. I
was thinking of using '. ' as the delimiter. If I happen to get an extra
sentence because of other punctuation it is not a problem. This template is
being used to create a short summary of a piece of a doecument. Also, the
<span> tags don't cross sentence boundaries so that huge mess is avoided.

I guess another possibility it to output n characters and add '...' at the
end to create the summary. Is that any easier?

Thanks for your help,
Jim

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.