Middle of word

Discussion in 'XML' started by N9, May 13, 2008.

  1. N9

    N9 Guest

    Hi

    It's possible to substring middle ??

    text = "Here are a story about a boy, who like to play baseball"

    I split on word "who", with 10 char to left and 10 char til right,
    that the result gone be.

    text = "out a boy who, like to "

    Hope some one could help me.

    Thanks

    //N9
    N9, May 13, 2008
    #1
    1. Advertising

  2. N9 wrote:
    > It's possible to substring middle ??


    Your example doesn't seem to have anything to do with XSLT, unless test
    is an attribute.
    Joseph J. Kesselman, May 13, 2008
    #2
    1. Advertising

  3. N9

    Ken Starks Guest

    N9 wrote:
    > Hi
    >
    > It's possible to substring middle ??
    >
    > text = "Here are a story about a boy, who like to play baseball"
    >
    > I split on word "who", with 10 char to left and 10 char til right,
    > that the result gone be.
    >
    > text = "out a boy who, like to "
    >
    > Hope some one could help me.
    >
    > Thanks
    >
    > //N9

    You should look up XPath rather than XSLT, and you will
    want the string functions:

    substring-before, substring-after, substring, string-length

    and possibly 'concat' and 'contains'


    for example:

    substring(substring-after("Here is a story about a boy, who likes to
    play baseball","who"),4,11)

    evaluates to 'kes to play'

    Note that the second parameter is a request for a length od substring,
    not the final position.

    Assuming the source text is the content of an xml element, you would use
    <xsl:value-of>, possibly normalise spaces, and almost certainly wish to
    use a variable.

    Also not thet the 'substring-before' and 'substring-after' functions
    only return the first match,
    Ken Starks, May 13, 2008
    #3
    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. Laura
    Replies:
    1
    Views:
    505
    Gunnar Hjalmarsson
    Jun 5, 2004
  2. Stephen Witter

    opening a word doc in word not browser

    Stephen Witter, May 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    461
    Stephen Witter
    May 18, 2004
  3. Luis Esteban Valencia
    Replies:
    2
    Views:
    2,917
    sanjupillai
    Sep 26, 2008
  4. Sharon
    Replies:
    0
    Views:
    584
    Sharon
    Jul 27, 2005
  5. Franck
    Replies:
    1
    Views:
    4,784
Loading...

Share This Page