xsl-list
[Top] [All Lists]

Re: [xsl] How can I know if a node has already been processed ?

2008-11-06 17:23:02

sin x should be translated sin(x) but is translated sin(x)x

when processing MathML (which was an explict use case during the design
phase of XSLT, including joint teleconference between math and xsl
working groups to make sure that processing mathml was feasible) you
want to process the abstract function tree not the xml tree directly.
so in sin(x) you want to think of sin as a head with child x, process
sin first and then prcess the child.

However the markup is

<apply>
  <sin/>
  <mi>x</mi>
</apply>

so x is a sibling of sin not its child. However you should write your
templates with a mental model as if sin were the parent.

You don't want the template matching apply just to process all its
children, you want the processing of x to be controlled by the first
child of the apply (sin). One way s always to match on thins like
apply[*[1][self::sin]
to just match an apply with head sin.

look at http://www.w3.org/Math/XSL/ctop.xsl which is processing contnet
mathml to presentation mathml, but themethods of matching mathl
structures are usually very similar whatevr the output format.

It basically consists of a lot of templates like:
 
<xsl:template mode="c2p" match="mml:apply[*[1][self::mml:inverse]]">
 <mml:msup>
  <xsl:apply-templates mode="c2p" select="*[2]"/>
  <mml:mrow><mml:mo>(</mml:mo><mml:mn>-1</mml:mn><mml:mo>)</mml:mo></mml:mrow>
 </mml:msup>
</xsl:template>

so this is the template for inverse which typesets its "child" and
superscripts the result with -1.  the match pattern is the way it is
because the syntax is
<apply>
 <inverse/>
 <ci>x</ci>
</inverse>

but if the syntax had been 
<inverse>
<ci>x</ci>
</inverse>

The template could have been
<xsl:template mode="c2p" match="mml:mml:inverse">
 <mml:msup>
  <xsl:apply-templates mode="c2p" select="*[1]"/>
  <mml:mrow><mml:mo>(</mml:mo><mml:mn>-1</mml:mn><mml:mo>)</mml:mo></mml:mrow>
 </mml:msup>
</xsl:template>


which saves a few keystrokes but really isn't any simpler once you get
used to the mml:apply[*[1][self::mml:inverse]] idion used in the first
match. 


David

incidentally are you in touch with other people working on mathml from
braille, eg
http://www.ascience.eu/?q=en/wsParis/Archambault

D

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

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