using xsl to limit no of chars output

Discussion in 'XML' started by Andrew Fisher, Nov 13, 2003.

  1. 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
     
    Andrew Fisher, Nov 13, 2003
    #1
    1. Advertising

  2. Andrew Fisher wrote:
    > 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.
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
     
    Johannes Koch, Nov 13, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TSBL?=

    Limit asp:textarea to 100 chars on client side?

    =?Utf-8?B?TSBL?=, Nov 17, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    5,708
    Kevin Spencer
    Nov 17, 2004
  2. Replies:
    1
    Views:
    3,689
    A. Bolmarcich
    May 27, 2005
  3. Kosio

    Floats to chars and chars to floats

    Kosio, Sep 16, 2005, in forum: C Programming
    Replies:
    44
    Views:
    1,344
    Tim Rentsch
    Sep 23, 2005
  4. Hongyu
    Replies:
    9
    Views:
    967
    James Kanze
    Aug 8, 2008
  5. M.Posseth

    receiving ??? chars instead of "special" chars

    M.Posseth, Nov 15, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    286
    Dan Rogers
    Nov 16, 2004
Loading...

Share This Page