You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Ovidiu Predescu <ov...@cup.hp.com> on 2000/12/02 01:24:17 UTC

applying templates on variables

The following template does not work with Xalan 1.2.1, while it works fine with
Saxon 5.5.1:

 <xsl:template match="page[split]">
  <xsl:variable name="page">
   <page>
    <xsl:copy-of select="@*"/>
    <xsl:copy-of select="child::*[preceding::split]"/>
   </page>
  </xsl:variable>
  <xsl:apply-templates select="$page"/>
 </xsl:template>

The first error I got was an exception as XRTreeFrag object could not be
converted to a NodeList. This was easily fixed by defining the nodeset()
method; here is a patch that does it:

--- xalan-j_1_2_1/src/org/apache/xalan/xpath/XRTreeFrag.java    Wed Nov 15 
07:09:47 2000
+++ xalan-j_1_2_1.modif/src/org/apache/xalan/xpath/XRTreeFrag.java      Fri 
Dec  1 14:13:33 2000
@@ -168,7 +168,12 @@
   public NodeList convertToNodeset()
   {
     return ((DocumentFragment)m_obj).getChildNodes();
-  }  
+  }
+
+    public NodeList nodeset()
+    {
+        return convertToNodeset();
+    }
   
   /**
    * Tell if two objects are functionally equal.


However it looks like Xalan still doesn't want to properly apply the templates
to the DOM tree kept in the $page variable. Any ideas what could be wrong?

Thanks,
-- 
Ovidiu Predescu <ov...@cup.hp.com>
http://orion.nsr.hp.com/ (inside HP's firewall only)
http://www.geocities.com/SiliconValley/Monitor/7464/



Re: applying templates on variables

Posted by Gary L Peskin <ga...@firstech.com>.
Ovidiu Predescu wrote:
> 
> The following template does not work with Xalan 1.2.1, while it works fine with
> Saxon 5.5.1:
> 
>  <xsl:template match="page[split]">
>   <xsl:variable name="page">
>    <page>
>     <xsl:copy-of select="@*"/>
>     <xsl:copy-of select="child::*[preceding::split]"/>
>    </page>
>   </xsl:variable>
>   <xsl:apply-templates select="$page"/>
>  </xsl:template>
> 
> The first error I got was an exception as XRTreeFrag object could not be
> converted to a NodeList. This was easily fixed by defining the nodeset()
> method; here is a patch that does it:

Ovidiu --

Your patch does not properly implement the nodeset() extension.  You
should use the one supplied with Xalan itself.  A result tree fragrment
is equivalent to a node-set consisting of a single node that is the root
node of the result tree.  Your patch creates a node-set consisting of
all of the child nodes in the RTF.

Try this with the built-in nodeset extension and let us know if that
works.

Gary