using xsl to limit no of chars output

A

Andrew Fisher

Hi all,

I am building a site at the moment that as you'd expect takes an XML
file [or data from DB] and then uses XSLT to output html, wml etc.

Now the question I have has eluded me for a couple of days now and to
be honest I am pulling my hair out.

Heres what I have: Take the home page for example, it pulls out news
items from the file server [stored in xml] and then has a a "news in
brief" section which has the first 100 chars from each news articl and
a link to the actual article for more info...

so xml doc can be summarised thus:

<homepage>
...
<newsitems>
<news>
<title>the title</title>
<bodytext>some document information here that can be quite long
and can also contain tags for paras, bold and italic</bodytext>
</news>
...
<news>
<title>the title</title>
<bodytext>some document information here that can be quite long
and can also contain tags for paras, bold and italic</bodytext>
</news>
</newsitems>
...
</homepage>

Now assume from the example given above I want to limit the body text
to 15 chars output from all that is there, what XSL would I apply to
it to make it do that?

All responses very much welcomed, even speculation about how one might
do it...

Cheers
Andrew F
 
J

Johannes Koch

Andrew said:
Now assume from the example given above I want to limit the body text
to 15 chars output from all that is there, what XSL would I apply to
it to make it do that?

Have a look at the string functions in XPath.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top