RE: [xsl] Can XSLT remember the occurrence

Subject: RE: [xsl] Can XSLT remember the occurrence
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Sun, 4 Jan 2004 17:28:56 +0100
> -----Original Message-----
> From: suresh reddy
>
<snip />
>
> Can I write an XSL so that the output is the following
> ..
>
> <html>
> <body>
> e power x power base i
> </body>
> </html>
>

In this case, the following templates should do the trick:

<xsl:template match="/">
  <html>
  <xsl:apply-templates select="math/msup" />
  </html>
</xsl:template>

<xsl:template match="msup">
  <body>
  <xsl:apply-templates select="mrow/msub/mi[1]" />
  </body>
</xsl:template>

<xsl:template match="mrow/msub/mi">
  <xsl:value-of select="ancestor::msup/mi" />
  <xsl:text> power </xsl:text>
  <xsl:value-of select="." />
  <xsl:text> power base </xsl:text>
  <xsl:value-of select="following-sibling::mi[1]" />
</xsl:template>

> Can anyone please help me... the solution should be
> more generalized .... the above is just a simple
> instance I have chosen.. the expression can be very
> complex and every variable should be expressed with
> respect to the ground variable.
>

I think you will find the 'ancestor::msup/mi' XPath expression particularly
helpful. The above example only works for this specific case, so I
definitely hope there is at least some other way to distinguish between the
types of operation (i.e. power).

Hope this helps! (If not, don't hesitate to re-post)

Cheers,

Andreas


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread