I'm trying to clean up the readability of my code. Using v1. Any help on what I'm doing wrong is greatly appreciated.
XML code that I have:
...
<trusted-servers>mark mike sally</trusted-servers>
...
I want it to display the following way:
mark
mike
sally
Originally, it's displaying in this way using (<xsl:value-of select="trusted-servers"/>
):
mark mike sally
What I have tried is:
<xsl:value-of select="string-length(substring-before(trusted-servers, concat(' ', trusted-servers, '<xsl:text disable-output-escaping="yes"><![CDATA[<br />]]></xsl:text>')))" data-type="string"/>
But it throws an error saying that unescaped character <
isn't allowed. I tried taking out the <xsl:text disable-output-escaping="yes"><![CDATA[<br />]]></xsl:text>
part and replacing it with <br/>
but still have the same error. I'm clueless in any other ways of doing it.
Assuming xsltproc you have http://exslt.org/str/functions/tokenize/index.html so you can do
where you declare
xmlns:str="http://exslt.org/strings"
on thexsl:stylesheet
.Generally speaking,
<xsl:text disable-output-escaping="yes">
should be avoided as much as possible!Since you're using XSLT 1.0, the best solution is to write a template which will recursively replace the first space encountered by a
<br>
, for instance: