I am hoping this is a simple one, though it seems it often isn't...
I am working with XLST 1.0 and I have a string which I need to translate
. This string is a user-entered text field. It contains several smaller strings separated by a delimiter. (In this case, it's "|".) The length of this string and the number of special characters varies widely.
(This field is similar to a CSV list, however, rather than using a comma as the delimiter, the "|" is the delimiter.)
I need to learn how to change this delimiter to <br>
.
I've tried using the following XSL to achieve this:
<xsl:variable name="stringtotrans">
<xsl:text>String1|String2|String3</xsl:text>
</xsl:vairable>
<!-- In the actual XML document, this variable grabs the value of an attribute. -->
<!-- For this example, it's being entered manually. -->
<!-- The number and length of the individual strings varies widely. -->
<xsl:value-of select="translate($stringtotrans, '|', '

')"/>
When this code is run, the output is:
String1String2String3
The expected/desired output is:
String1
String2
String3
Any and all help with this would be greatly appreciated!
`. For this, you would need a recursive template such as the one shown here: http://stackoverflow.com/questions/30339128/how-to-replace-single-quote-to-double-single-quote-in-xslt/30339654#30339654 – michael.hor257k Mar 07 '16 at 22:41
, or other such character.*" That's ambiguous. If your result is text, then `newline` can mean CR (Mac), LF (Unix) or CRLF (Windows). The first two are single characters, and thus *can* be produced by `translate()`. The last one is not and cannot. If your result is HTML, then you need `
`. That's not a character, and of course it cannot be returned by the `translate()` function. Given such disparity, you will understand that "*other such character*" is meaningless. – michael.hor257k Mar 07 '16 at 23:26
, as the final output is in HTML. However, if an intermediary was available that would produce the desired end result using another character, I would like to learn of this as well. For the time being, I'll try implementing your previously suggested method. – Simcik Mar 08 '16 at 14:11
*" I have posted an answer showing how to do that. "*if an intermediary was available that would produce the desired end result using another character*" If it's a single character, then use `translate()`; if it's a string of more than one character, then use the `replace` template I linked to earlier. – michael.hor257k Mar 08 '16 at 14:45