xsl-list
[Top] [All Lists]

[xsl] XSLT 1.0: How to apply-templates while copying the content of a template parameter?

2009-09-09 14:51:46
Hi,

I have the simplified stylesheet that follows this message. I have a problem 
with the usage of the "addInlineText" template which simply tries to copy the 
nodes defined at the call site. It is also important to apply-template on the 
copied nodes to further apply transformations defined elsewhere.

Xalan fails to process the template and seems to fail to build a node-set for 
the for-each instruction. I get this error:
  SystemID: print.xsl; Line#: 9; 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)

Is it possible to rewrite the addInlineText template to be Xalan compliant?

The stylesheet is:
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
    xmlns:html="http://www.w3.org/1999/xhtml"; version="1.0" 
exclude-result-prefixes="html">

<xsl:output method="html" version="1.0" omit-xml-declaration="yes"  />
  
<xsl:template name="addInlineText">
  <xsl:param name="value" />
  <xsl:for-each select="$value" >
      <xsl:copy/>
      <xsl:apply-templates/>
  </xsl:for-each>
</xsl:template>
    
<xsl:template match="/">
  <html>
    <head>
      <title>Test</title>
    </head>
    <body>
      <xsl:call-template name="addInlineText">
        <xsl:with-param name="value">
          <html:p>Testing HTML in labels</html:p>
        </xsl:with-param>
      </xsl:call-template>
    </body>
  </html>
</xsl:template>

<xsl:template match="html:p">
  <p><xsl:value-of select="text()"/></p>
</xsl:template>

<!-- The identity transformation. -->
<xsl:template match="@*|node()">
  <xsl:copy>
  <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

Regards,
Alain Gilbert

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>