You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Nicolas Dubien <xa...@dubien.org> on 2013/06/28 13:23:43 UTC
Xalan-Java extension with special chars
Hi,
I would like to know how I can use Xalan-Java extensions to compute data
and return special chars like <, >.. without being escaped.
Actually, I'm using the following xsl instruction in my xsl file:
<xsl:value-of select="xalanexample:addcolor(@first)"/>
I would like a return like:
<fo:inline color="red">David</fo:inline>
But instead of that, the return is:
<fo:inline color="red">David</fo:inline>
My Java extension is:
public String addcolor(String name) {
String result = ((name.compareTo("David") == 0) ? "<fo:inline
color=\"red\">" : "<fo:inline color=\"blue\">") + name + "</fo:inline>";
return result;
}
How could I do?
I am looking forward to hearing from you,
Nicolas DUBIEN
Re: Xalan-Java extension with special chars
Posted by "USHAKOV, Sergey" <s-...@yandex.ru>.
Hi Nicolas,
unfortunately I cannot address your problem in full, but still hope to
point to the right direction...
The source of your problem is that in fact you do not need a string with
special characters in your output, but rather you need an XML element
named "inline" if the "fo" namespace... And you make a string, and so
get a properly formatted XML string...
What you need is to return an instance of org.w3c.dom.DocumentFragment,
see http://xml.apache.org/xalan-j/extensions.html#ext-func-retval .
And unfortunately I can provide no more guidance for you from that point...
Kind regards and good luck,
Sergey
On 28.06.13 15:23, Nicolas Dubien wrote:
> Hi,
>
> I would like to know how I can use Xalan-Java extensions to compute
> data and return special chars like <, >.. without being escaped.
>
> Actually, I'm using the following xsl instruction in my xsl file:
> <xsl:value-of select="xalanexample:addcolor(@first)"/>
>
> I would like a return like:
> <fo:inline color="red">David</fo:inline>
> But instead of that, the return is:
> <fo:inline color="red">David</fo:inline>
>
> My Java extension is:
> public String addcolor(String name) {
> String result = ((name.compareTo("David") == 0) ? "<fo:inline
> color=\"red\">" : "<fo:inline color=\"blue\">") + name + "</fo:inline>";
> return result;
> }
>
> How could I do?
>
> I am looking forward to hearing from you,
> Nicolas DUBIEN