Rob, does the following template demonstrate your assertion?  It runs fine
on my latest build (from last Wednesday or Thursday, I think).  Can you try
it with whatever version you are running?

If it works, it would help a lot if you would build a *small* stylesheet
and XML source that demonstrates the issue.  Maybe you can play around with
the one below to reproce it.

I suspect that the problem may be something else than you said, but it may
be a bug in the latest developer version or the latest released version, or
I may be misunderstanding something about what you said.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version=
"1.0">
  <xsl:output indent="yes"/>

<xsl:template name="yada">
          <xsl:for-each select="//center">
            <xsl:apply-templates select="ancestor::*"/>
          </xsl:for-each>
</xsl:template>


<xsl:template match="/">
  <out>
      <xsl:variable name="foo">
          <xsl:for-each select="//center">
            <xsl:apply-templates select="ancestor::*"/>
          </xsl:for-each>
    </xsl:variable>
    <xsl:copy-of select="$foo"/>
      <xsl:variable name="foo2">
            <xsl:call-template name="yada"/>
    </xsl:variable>
    <xsl:copy-of select="$foo2"/>
  </out>
</xsl:template>

<xsl:template match="*">
  <xsl:value-of select="name(.)"/>: <xsl:copy/>
  <xsl:text>&#10;</xsl:text>
</xsl:template>

</xsl:stylesheet>

XML I am using to process it:

<?xml version="1.0"?>
<far-north>
      <north>
            <near-north>
                  <far-west/>
                  <west/>
                  <near-west/>
                  <center>
                        <near-south>
                              <south>
                                    <far-south/>
                              </south>
                        </near-south>
                  </center>
                        <near-east/>
                        <east/>
                        <far-east/>
            </near-north>
      </north>
</far-north>

Your results should look like:

<?xml version="1.0" encoding="UTF-8"?>
<out>far-north: <far-north/>
north: <north/>
near-north: <near-north/>
far-north: <far-north/>
north: <north/>
near-north: <near-north/>
</out>

-scott




                                                                                       
                                                
                      Rob Tice                                                         
                                                
                      <rob.tice@fdgroup        To:       "'[EMAIL PROTECTED]'" 
<[EMAIL PROTECTED]>                       
                      .com>                    cc:       (bcc: Scott 
Boag/Cambridge/IBM)                                               
                                               Subject:  xsl-for-each                  
                                                
                      07/09/2002 02:47                                                 
                                                
                      AM                                                               
                                                
                      Please respond to                                                
                                                
                      xalan-dev                                                        
                                                
                                                                                       
                                                
                                                                                       
                                                




Just a general posting as I am not sure if it is a bug or a feature of xsl.

Using the latest xalan (don't know about the behaviour in previous
versions) I cannot wrap an xsl:for-each as a variable e.g. <xsl:variable
name="test"><xsl:for-each ......etc... ></xsl:for-each></xsl:variable> I
get a 'cannot convert tree fragment to node-list exception'.
However, if I put the 'for each' in a template I can wrap the return from
this template in a variable. This seems inconsistent. Any comments

Rob Tice







Reply via email to