ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: nico <nicolas.marsgui@libertysurf.fr>
Subject: Re: open math
Date: Sat, 20 May 2006 00:30:15 +0200	[thread overview]
Message-ID: <ops9tkspj69niby6@localhost> (raw)
In-Reply-To: <446E2ADC.3030601@wxs.nl>

On Fri, 19 May 2006 22:30:20 +0200, Hans Hagen <pragma@wxs.nl> wrote:

> nico wrote:
>> On Thu, 18 May 2006 22:02:03 +0200, Hans Hagen <pragma@wxs.nl> wrote:
>>
>> Just a question about the ctx file as described in the doc: does it mean
>> that every XML file is processed first by 'openmath' and then  
>> 'mathadore'?
>>
>> If so, why not using the xsltproc piping, avoiding the intermediate .om
>> files?
>>
> i'm not aware of piping ... how does the command look then?

Thinking a bit about this, you could avoid using two passes, by merging  
both stylesheets. The only limitation is the need of the node-set EXSL  
function (but available in xsltproc by default).

Simple example:

The main stylesheet (say, x-openmath.xsl):

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:exsl="http://exslt.org/common"
                 exclude-result-prefixes="exsl"
                 version='1.0'>

<xsl:import href="x-sm2om.xsl"/>
<xsl:import href="x-om2cml.xsl"/>

<xsl:template match="i|n">
   <xsl:variable name="om">
     <xsl:apply-imports select="."/>
   </xsl:variable>
   <xsl:apply-templates select="exsl:node-set($om)"/>
</xsl:template>

</xsl:stylesheet>

The imported ones:

x-sm2om.xsl
-----------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>

<xsl:template match="i|n">
    <xsl:element name="OMOBJ">
       <xsl:attribute  
name="xmlns">http://www.openmath.org/OpenMath</xsl:attribute>
       <xsl:attribute name="version">2.0</xsl:attribute>
       <xsl:value-of select="text()"/>
    </xsl:element>
</xsl:template>

</xsl:stylesheet>

x-om2cml.xsl
------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>

<xsl:template match="OMOBJ">
   <xsl:element name="cn">
     <xsl:attribute  
name="xmlns">http://www.openmath.org/OpenMath</xsl:attribute>
     <xsl:attribute name="version">2.0</xsl:attribute>
     <xsl:value-of select="text()"/>
   </xsl:element>
</xsl:template>

</xsl:stylesheet>

XML file
---------
<example>
<i>a</i>
<i>b</i>
<i>c</i>
<n>d</n>
<i>e</i>
</example>

xsltproc x-openmath.xsl example.xml


It should be checked on the real stylesheets, but it should work. It's  
nicer than piping commands, and should take less time to process.

Regards,
BG

      parent reply	other threads:[~2006-05-19 22:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-18 20:02 Hans Hagen
2006-05-19 20:25 ` nico
2006-05-19 20:30   ` Hans Hagen
2006-05-19 21:27     ` nico
2006-05-21 17:35       ` Hans Hagen
2006-05-19 22:30     ` nico [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ops9tkspj69niby6@localhost \
    --to=nicolas.marsgui@libertysurf.fr \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).