xsl-list
[Top] [All Lists]

Re: ancestor

2004-10-18 10:23:47
Has this test returned a value for you?

<xsl:if test="$inlineequation/@id=./@id"><xsl:value-of
select="position()" /></xsl:if>

My guess is that you are trying to do this:

<xsl:if test=". = @id">
<xsl:value-of select="position()" />
</xsl:if>

Which really doesnt make much logical sense iso then maybe the value you are passing in to the parameter 'inlinequation' contains an attribute id and you want to compare its value to the value of the current elements id attribute which would look like this:

<xsl:if test="$inlineequation/@id = current()/@id">
<xsl:value-of select="position()" />
</xsl:if>

But from your explanation it seems you are simply trying to generate sequential numbering which can be done by simply using the number element as such:

<xsl:for-each select="//inlineequation[not(ancestor::table) and
not(ancestor::figure)]">
<xsl:number/>
</xsl:for-each>

Or better yet just eliminate the named template all together and use apply-templates and the match attribute of the template as it was before and put the number element inside the template like so:

<xsl:template match="inlineequation">
<xsl:number/>
<xsl:value-of select="put desired output element here"/>
</xsl:template>

Not quite sure as to whether or not this helps or not as its unclear to me what it is you want to output and what type of ordering values need to be along side it. But hopefully this will get you going a little more in the right direction.

Best of luck!

<M:D/>



Jiang, Peiyun wrote:
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

--+------------------------------------------------------------------
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>