How to use translate() with HTML tags in string

Discussion in 'XML' started by johkar, Feb 22, 2006.

  1. johkar

    johkar Guest

    I have a rather long unbroke string (a URL) which I would like to break
    at certain points using XSL. I can't seem to get translate() to work:

    translate(.,'/',,'<wbr>/</wbr>')

    I don't know that the <wbr> tag is valid, but if can stick something
    within the string I think I can figure out a way for it to wrap.
    johkar, Feb 22, 2006
    #1
    1. Advertising

  2. > translate(.,'/',,'&lt;wbr>/&lt;/wbr>')

    translate() performs character-to-character mapping, not
    character-to-string. See
    http://www.w3.org/TR/1999/REC-xpath-19991116#function-translate

    So as you've written it -- assuming the double comma is just a typo --
    you've said "Retrieve the text value of the current node (.), find all
    instances of '/', and replace them with the '<' character (&lt;)".

    If you're trying to replace instances of / with <wbr>/</wbr>, this won't
    do it. See recent discussions of using the substring functions, and
    recursive templates if necessary, to achieve this... and you probably
    want to insert a real <wbr> element rather text which describes one.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Feb 23, 2006
    #2
    1. Advertising

  3. johkar

    johkar Guest

    Joe Kesselman wrote:
    > > translate(.,'/',,'&lt;wbr>/&lt;/wbr>')

    >
    > translate() performs character-to-character mapping, not
    > character-to-string. See
    > http://www.w3.org/TR/1999/REC-xpath-19991116#function-translate
    >
    > So as you've written it -- assuming the double comma is just a typo --
    > you've said "Retrieve the text value of the current node (.), find all
    > instances of '/', and replace them with the '<' character (&lt;)".
    >
    > If you're trying to replace instances of / with <wbr>/</wbr>, this won't
    > do it. See recent discussions of using the substring functions, and
    > recursive templates if necessary, to achieve this... and you probably
    > want to insert a real <wbr> element rather text which describes one.
    >
    > --
    > () ASCII Ribbon Campaign | Joe Kesselman
    > /\ Stamp out HTML e-mail! | System architexture and kinetic poetry


    Thanks for the info. I found the threads on substrings and have it
    working.
    johkar, Feb 25, 2006
    #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. Mitchua
    Replies:
    1
    Views:
    7,043
    Ice Demon
    Jul 15, 2003
  2. Dean H. Saxe
    Replies:
    0
    Views:
    1,015
    Dean H. Saxe
    Jan 3, 2004
  3. Rob Nicholson
    Replies:
    3
    Views:
    671
    Rob Nicholson
    May 28, 2005
  4. Mike
    Replies:
    3
    Views:
    862
    Michael Borgwardt
    Jan 9, 2004
  5. Donald Firesmith

    html tags within meta tags allowed?

    Donald Firesmith, Jan 5, 2005, in forum: XML
    Replies:
    5
    Views:
    872
    Andy Dingley
    Jan 8, 2005
Loading...

Share This Page