How to use translate() with HTML tags in string

J

johkar

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.
 
J

Joe Kesselman

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.
 
J

johkar

Joe said:
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.

Thanks for the info. I found the threads on substrings and have it
working.
 

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

Forum statistics

Threads
474,001
Messages
2,570,255
Members
46,853
Latest member
GeorgiaSta

Latest Threads

Top