RE: [xsl] ancestor

Subject: RE: [xsl] ancestor
From: "Jiang, Peiyun" <Peiyun.Jiang@xxxxxxxxxxxxxx>
Date: Mon, 18 Oct 2004 12:54:56 -0400
Thanks, everyone!

I picked up "inlineequation[not(ancestor::table)]" because it looks neat and
it works!!!
Testing for ancestor does not seem to slow down my application. The // part
probaly is the critical "PATH" as Jeni said. My "inlineequation" is all over
the document nesting with different depths and I'll use "//" for now. 

The pain part is this (though my XSLT is not too slow as measured on my
computer): 
I'm trying to output the position of each selected inlineequation (using
inlineequation[not(ancestor::table)]). The numbering is sequential in the
selected inlineequations. What I'm doing is when each inlineequation is
matched, I call a template that will get the position in the selected list.
"inlineequation[not(ancestor::table)]" is evaluated over and over again.

template:
  <xsl:template name="inlineequation_position">
     <xsl:param name="inlineequation"></xsl:param>
     <xsl:for-each select="//inlineequation[not(ancestor::table) and
not(ancestor::figure)]">
        <xsl:if test="$inlineequation/@id=./@id"><xsl:value-of
select="position()" /></xsl:if>
     </xsl:for-each>
  </xsl:template>

simplified calling template:
  <xsl:template match="inlineequation">
    <img alt="">
       <xsl:attribute name="src">ImgServer?<xsl:call-template
name="inlineequation_position"><xsl:with-param
name="inlineequation" select="."/></xsl:call-template>h.gif</xsl:attribute>
    </img>     
  </xsl:template>  

Is there a way to cache the result of
"//inlineequation[not(ancestor::table)]" in a variable and pass it to the
template? There seems to be two problems with this approach: a global
variable may not have access to the document and can we pass two parameters
to a template?

Thanks.

Peiyun Jiang

Current Thread