Re: How to xsl:apply-templates while xsl:copy-of?

Mukul Gandhi <[email protected]>
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <[email protected]>
Hi Alain,
   The reason, why xsl:for-each select="$value" is working with
XMLSpy, is because XMLSpy is using a XSLT 2.0 engine, which treats
$value as a node-set.

Whereas, $value if a RTF (result tree fragment) in XSLT 1.0. An
expression, select="$value" will give an error, as you just found,
with XSLT 1.0.

To make this work with Xalan-J, you need to use the xx:node-set
extension function. Please refer,
http://xml.apache.org/xalan-j/extensionslib.html#exslt for more
information in this regard.

So you would need to do something, like:
xx:node-set($value)

or perhaps,
xx:node-set($value)/*

xx:node-set($value) behaves similar to, a 2.0 $value

On Tue, Sep 8, 2009 at 9:29 PM, Alain Gilbert <[email protected]> wrote:
> When I rewrite the addInlineText template as:
>
> <xsl:template name="addInlineText">
>  <xsl:param name="value" />
>  <fo:block>
>    <xsl:for-each select="$value" >
>      <xsl:copy/>
>      <xsl:apply-templates/>
>    </xsl:for-each>
>  </fo:block>
> </xsl:template>
>
> I do get the desired behavior with the Altova XSLT engine, built in the XMLSpy product.
>
> However, when trying the same with Xalan, I get this error:
>  SystemID: print.xsl; Line#: 20; Column#: 33
>  org.apache.xpath.XPathException: Can not convert #RTREEFRAG to a NodeList!
>    at org.apache.xpath.objects.XObject.error(XObject.java:703)
>    at org.apache.xpath.objects.XObject.iter(XObject.java:406)
>    at org.apache.xpath.Expression.asIterator(Expression.java:250)
>    at org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:333)
>
> Any help greatly appreciated,
> Alain Gilbert



-- 
Regards,
Mukul Gandhi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.