Re: MathML tags in an attribute of an HTML EMBED tag ?

Subject: Re: MathML tags in an attribute of an HTML EMBED tag ?
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 26 Oct 2000 10:45:02 +0100
Frédéric,

>and I want to output this :
>
><EMBED TYPE="text/mathml" MMLDATA="
><math>...some mathml ...</math>" HEIGHT="75" WIDTH="200" />
>to render MathML with the IBM techexplorer plug-in.

This is not well-formed XML as it stands.  Do you know whether the the IBM
techexplorer plug-in will work if you have:

<EMBED TYPE="text/mathml" MMLDATA="
&lt;math&gt;...some mathml ...&lt;/math&gt;" HEIGHT="75" WIDTH="200" />

instead, as this *is* well-formed XML and therefore easier to produce?

If so (and I hope so), then you can use a serialising template to take the
contents of the FORMULE element and turn it into a serialised XML version:

----
<xsl:template match="FORMULE">
  <EMBED TYPE="text/mathml" HEIGHT="75" WIDTH="200">
    <xsl:attribute name="MMLDATA">
      <xsl:apply-templates mode="serialise" />
    </xsl:attribute>
  </EMBED>
</xsl:template>

<xsl:template match="*" mode="serialise">
  <xsl:text />&lt;<xsl:value-of select="name()" />
  <xsl:for-each select="@*">
    <xsl:text> </xsl:text>
    <xsl:value-of select="name()" />
    <xsl:text />="<xsl:value-of select="." />"<xsl:text />
  </xsl:for-each>
  <xsl:text>&gt;</xsl:text>
  <xsl:apply-templates mode="serialise" />
  <xsl:text />&lt;/<xsl:value-of select="name()" />&gt;<xsl:text />
</xsl:template>

<xsl:template match="text()[not(normalize-space())]" mode="serialise" />
----

If not, then you have two options.  One is to produce the whole thing as
text;  obviously that's undesirable because you can't take advantage of the
way you can build elements and attributes in XSLT.  The other is to create
an output filter or emitter or whatever that can be plugged into Xalan and
used to serialise the DOM in whatever way you want.  Again, that involves a
lot of work.

Sorry not to be more help,

Jeni


Jeni Tennison
http://www.jenitennison.com/


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


Current Thread