title: How have xsl:function return a string value including html tags
body: <p>I am attempting to transpose a java function to an xsl:function spec.
  The function basically places html tags around substrings.
  I now bump into difficulties: using the java inline code this works perfectly, but I am unable to figure out how to prevent output escaping when using the xsl:function.
  How can I achieve the output to contain the wanted html tags?</p>
  
  <p>A simplified example of what I am trying to achieve is the following:
  input parameter value "AB" should lead to a string A&lt;b&gt;B&lt;/b&gt;, shown in html browser as  A<b>B</b> of course.</p>
  
  <p>Example function I tried is the below; but then the resulting string is A&amp;lt ;b&amp;gt ;B&amp;lt ;/b&amp;gt ; (note that I had to add blanks to prevent the entities from getting interpreted in this editor), which of course shows up in browers as A&lt;b&gt;B&lt;/b&gt;.</p>
  
  <p>Note that xsl:element cannot be used in the xsl:function code, because that has no effect; I want the string result of the function call to contain &lt; and > characters, and then add the string result to the output result file.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet
      version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:custom="http://localhost:8080/customFunctions"&gt;
  
      &lt;xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/&gt;
  
      &lt;xsl:function name="custom:test"&gt;
          &lt;xsl:param name="str"/&gt; 
  
          &lt;xsl:value-of select="substring($str,1,1)"/&gt;
          &lt;xsl:text disable-output-escaping="yes"&gt;&lt;![CDATA[&lt;b&gt;]]&gt;&lt;/xsl:text&gt;
          &lt;xsl:value-of select="substring($str,2)"/&gt;
          &lt;xsl:text disable-output-escaping="yes"&gt;&lt;![CDATA[&lt;/b&gt;]]&gt;&lt;/xsl:text&gt;
      &lt;/xsl:function&gt;
  
      &lt;xsl:template match="/"&gt;
          &lt;xsl:element name="html"&gt;
              &lt;xsl:element name="body"&gt;
                  &lt;xsl:value-of select="custom:test('AB')"/&gt;
              &lt;/xsl:element&gt;
          &lt;/xsl:element&gt;
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>