Reputation: 21004
Apparently, it is impossible to directly call an external function from xsl:apply-templates. I have an XML node containing html tag for example :
<text>
<ul>
<li>
blablablaba
</li>
</ul>
<text>
In my output, if I want the html tags to be applied, I need to use xsl:apply-templates select="text"/>. I can't use xsl:value-of since it won't consider the HTML. Now the problem is that I need to call a function which will transform the html tags so my code would be :
<xsl:apply-templates select="util:myFunction(text)"/>
However, this will result in an error, is there another way I could do this ?
Thanks in advance.
Upvotes: 0
Views: 807
Reputation: 25034
I think what you are trying to say is: it appears to be impossible to use a function call to a Java function returning a string, in a context where XSLT requires an XPath expression which evaluates to a set of nodes.
Yes, that's impossible.
If you want to use the call util:myFunction(text)
to select the nodes to which templates should be applied, you will need that function to return a set of nodes using whatever tree representation your XSLT processor is using.
It is almost certainly possible to do this, for XSLT processors that support user-supplied Java functions at all. It is also almost certainly not the best solution for selecting input nodes to process; it's hard to imagine any node selection process that is easier in Java than in XSLT.
Upvotes: 1