Re: Is it so hard to generate compliant software ?

thanks to david's "Universal Svg/MathML stylesheet" (USMSS) we now have a
real cross-browser multi-namespace xml document. I made some minor
modifications to his stylesheet (i might have modified the prefixes
alternatively), so that the following works with ie6 *and* amaya.

note to use *.xml instead of *.html for ie6 to work properly.
also note, that the 'svg' is *not* rotated in amaya because of the obviously
not implemented 'transform' attribute.

thanks a lot .. david carlisle .. this is also very useful for inline svg
only.

MathmlSvg.xml
//------------------------------------------------------------------------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="MathmlSvg.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:g="http://www.w3.org/2000/svg"
      xmlns:m="http://www.w3.org/1998/Math/MathML">
<head>
  <title>SVG/MathML</title>
</head>
<body>
  <h2>SVG and MathML</h2>
  <p>In SVG a homogenous transformation matrix looks like this.</p>
   <p>
    <m:math>
     <m:mrow>
      <m:mi>T</m:mi><m:mo>=</m:mo>
       <m:mo>(</m:mo>
        <m:mtable>
         <m:mtr>
          <m:mtd> <m:mi>a</m:mi> </m:mtd>
          <m:mtd> <m:mi>c</m:mi> </m:mtd>
          <m:mtd> <m:mi>e</m:mi> </m:mtd>
         </m:mtr>
         <m:mtr>
          <m:mtd> <m:mi>b</m:mi> </m:mtd>
          <m:mtd> <m:mi>d</m:mi> </m:mtd>
          <m:mtd> <m:mi>f</m:mi> </m:mtd>
         </m:mtr>
         <m:mtr>
          <m:mtd> <m:mn>0</m:mn> </m:mtd>
          <m:mtd> <m:mn>0</m:mn> </m:mtd>
          <m:mtd> <m:mn>1</m:mn> </m:mtd>
         </m:mtr>
        </m:mtable>
       </m:mrow>
      <m:mo>)</m:mo>
    </m:math>
   </p>
  <p>
  Here is how we use it.
  </p>
  <p>
    <g:svg width="200" height="150">
      <g:text transform="matrix(0.5,0.866,-0.866,0.5,10,40)"
              stroke="darkslateblue" fill="lightblue" font-size="60"
              font-family="Comic Sans MS">SVG</g:text>
    </g:svg>
  </p>
</body>
</html>

MathmlSvg.xsl
// -------------------------------------------------------------
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:m="http://www.w3.org/1998/Math/MathML"
  xmlns:g="http://www.w3.org/2000/svg"
  xmlns:h="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="h"
>


<h:p>The main bulk of this stylesheet is an identity transformation
so...</h:p>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>



<h:p>XHTML elements are copied sans prefix (XHTML is default namespace
here, so these elements will still be in XHTML namespace</h:p>
<xsl:template match="h:*">
<xsl:element name="{local-name(.)}">
 <xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

<h:p>This just ensures the mathml prefix declaration isn't copied from
the source at this stage, so that the system will use the mml prefix
coming from this stylesheet</h:p>
<xsl:template match="h:html|html">
<html>
<xsl:copy-of
select="@*[not(namespace-uri(.)='http://www.w3.org/2002/Math/preference')]"/
>
<xsl:apply-templates/>
</html>
</xsl:template>


<xsl:template match="h:head|head">
<head>
<object id="mmlFactory"
        classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">
<xsl:text> </xsl:text>
</object>
<xsl:processing-instruction name="import">
 namespace="m" implementation="#mmlFactory"
</xsl:processing-instruction>
<object id="AdobeSVG"
        classid="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2">
<xsl:text> </xsl:text>
</object>
<xsl:processing-instruction name="import">
 namespace="g" implementation="#AdobeSVG"
</xsl:processing-instruction>
<xsl:apply-templates/>
</head>
</xsl:template>



<h:p>Somewhat bizarrely in an otherwise namespace aware system,
Microsoft behaviours are defined to trigger off the
<h:em>prefix</h:em> not the <h:em>Namespace</h:em>. In the code above
we associated a MathML rendering behaviour (if one was found) with the
prefix <h:code>m:</h:code> so here we ensure that this is the prefix
that actually gets used in the output.</h:p>
<xsl:template match="m:*">
<xsl:element name="m:{local-name(.)}">
 <xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>


<xsl:template match="g:*">
<xsl:element name="g:{local-name(.)}">
 <xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>


</xsl:stylesheet>

// -----------------------------------------------------------

stefan goessner

----- Original Message -----
From: "David Carlisle" <davidc@nag.co.uk>
To: <goessner@mecxpert.de>
Cc: <www-math@w3.org>; <www-svg@w3.org>
Sent: Monday, June 24, 2002 6:14 PM
Subject: Re: Is it so hard to generate compliant software ?


>
>
> > Please note, that i don't use the universal MathML stylesheet (UMSS)
here,
> > since nothing comparable exists for Svg. So the resulting document
> > XHTML/Presentation MathML/SVG is unfortunately not cross-browser
enabled.
>
> If you cut out bits of the mathml stylesheet and change mathplayer to
> adobesvg you get the following stylesheet which appears to render your
> document, even when the mathplayer and adobe-specific object elements
> are removed.
>
> The same xml file also renders in amaya (the svg is clearly
> recognised as it comes out big and blue, but not rotated).
>
> This hasn't been tested at all except on the document you posted...
>
> This stylesheet doesn't do all the more exotic determination of
> available renderers that the mathml one does: it just does mathplayer and
> adobe svg, always, but it could form the basis of a stylesheet for
> cross platform svg.
>
> David
>
>
> ======================================
> <?xml version="1.0"?>
> <?xml-stylesheet type="text/xsl" href="svg.xsl"?>
> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:g="http://www.w3.org/2000/svg"
>       xmlns:m="http://www.w3.org/1998/Math/MathML">
> <head>
>   <title>SVG/MathML</title>
> </head>
> <body>
>   <h2>SVG and MathML</h2>
>   <p>In SVG a homogenous transformation matrix looks like this.</p>
>    <p>
>     <m:math>
>      <m:mrow>
>       <m:mi>T</m:mi><m:mo>=</m:mo>
>        <m:mo>(</m:mo>
>         <m:mtable>
>          <m:mtr>
>           <m:mtd> <m:mi>a</m:mi> </m:mtd>
>           <m:mtd> <m:mi>c</m:mi> </m:mtd>
>           <m:mtd> <m:mi>e</m:mi> </m:mtd>
>          </m:mtr>
>          <m:mtr>
>           <m:mtd> <m:mi>b</m:mi> </m:mtd>
>           <m:mtd> <m:mi>d</m:mi> </m:mtd>
>           <m:mtd> <m:mi>f</m:mi> </m:mtd>
>          </m:mtr>
>          <m:mtr>
>           <m:mtd> <m:mn>0</m:mn> </m:mtd>
>           <m:mtd> <m:mn>0</m:mn> </m:mtd>
>           <m:mtd> <m:mn>1</m:mn> </m:mtd>
>          </m:mtr>
>         </m:mtable>
>        </m:mrow>
>       <m:mo>)</m:mo>
>     </m:math>
>    </p>
>   <p>
>   Here is how we use it.
>   </p>
>   <p>
>     <g:svg width="200" height="150">
>       <g:text transform="matrix(0.5,0.866,-0.866,0.5,10,40)"
>               stroke="darkslateblue" fill="lightblue" font-size="60"
>               font-family="Comic Sans MS">SVG</g:text>
>     </g:svg>
>   </p>
> </body>
> </html>
> ======================================
> <xsl:stylesheet
>   version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns:mml="http://www.w3.org/1998/Math/MathML"
>   xmlns:svg="http://www.w3.org/2000/svg"
>   xmlns:h="http://www.w3.org/1999/xhtml"
>   xmlns="http://www.w3.org/1999/xhtml"
>   exclude-result-prefixes="h"
> >
>
>
> <h:p>The main bulk of this stylesheet is an identity transformation
so...</h:p>
> <xsl:template match="*">
> <xsl:copy>
> <xsl:copy-of select="@*"/>
> <xsl:apply-templates/>
> </xsl:copy>
> </xsl:template>
>
>
>
> <h:p>XHTML elements are copied sans prefix (XHTML is default namespace
> here, so these elements will still be in XHTML namespace</h:p>
> <xsl:template match="h:*">
> <xsl:element name="{local-name(.)}">
>  <xsl:copy-of select="@*"/>
> <xsl:apply-templates/>
> </xsl:element>
> </xsl:template>
>
> <h:p>This just ensures the mathml prefix declaration isn't copied from
> the source at this stage, so that the system will use the mml prefix
> coming from this stylesheet</h:p>
> <xsl:template match="h:html|html">
> <html>
> <xsl:copy-of
select="@*[not(namespace-uri(.)='http://www.w3.org/2002/Math/preference')]"/
>
> <xsl:apply-templates/>
> </html>
> </xsl:template>
>
>
> <xsl:template match="h:head|head">
> <head>
> <object id="mmlFactory"
>         classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">
> <xsl:text> </xsl:text>
> </object>
> <xsl:processing-instruction name="import">
>  namespace="mml" implementation="#mmlFactory"
> </xsl:processing-instruction>
> <object id="AdobeSVG"
>         classid="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2">
> <xsl:text> </xsl:text>
> </object>
> <xsl:processing-instruction name="import">
>  namespace="svg" implementation="#AdobeSVG"
> </xsl:processing-instruction>
> <xsl:apply-templates/>
> </head>
> </xsl:template>
>
>
>
> <h:p>Somewhat bizarrely in an otherwise namespace aware system,
> Microsoft behaviours are defined to trigger off the
> <h:em>prefix</h:em> not the <h:em>Namespace</h:em>. In the code above
> we associated a MathML rendering behaviour (if one was found) with the
> prefix <h:code>mml:</h:code> so here we ensure that this is the prefix
> that actually gets used in the output.</h:p>
> <xsl:template match="mml:*">
> <xsl:element name="mml:{local-name(.)}">
>  <xsl:copy-of select="@*"/>
> <xsl:apply-templates/>
> </xsl:element>
> </xsl:template>
>
>
> <xsl:template match="svg:*">
> <xsl:element name="svg:{local-name(.)}">
>  <xsl:copy-of select="@*"/>
> <xsl:apply-templates/>
> </xsl:element>
> </xsl:template>
>
>
> </xsl:stylesheet>
> ======================================
>
> _____________________________________________________________________
> This message has been checked for all known viruses by Star Internet
> delivered through the MessageLabs Virus Scanning Service. For further
> information visit http://www.star.net.uk/stats.asp or alternatively call
> Star Internet for details on the Virus Scanning Service.

Received on Monday, 24 June 2002 16:54:27 UTC