<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" 
                              xmlns:html="http://www.w3.org/1999/xhtml" 
                              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:wwmode="urn:WebWorks-Engine-Mode"
                              xmlns:wwdoc="urn:WebWorks-Document-Schema"
                              xmlns:wwsplits="urn:WebWorks-Engine-Splits-Schema"
                              xmlns:wwimaging="urn:WebWorks-XSLT-Extension-Imaging"
                              xmlns:wwlog="urn:WebWorks-XSLT-Extension-Log"
                              xmlns:wwuri="urn:WebWorks-XSLT-Extension-URI"
                              exclude-result-prefixes="html xsl wwmode wwdoc wwsplits wwimaging wwlog wwuri"
>
  <xsl:import href="wwtransform:super" />
  
  <xsl:template match="wwdoc:Paragraph[@stylename = 'Equation']" mode="wwmode:content">
    <xsl:param name="ParamParagraph" select="." />
    <xsl:param name="ParamSplits"/>
    <xsl:param name="ParamSplit"/>
    
    <xsl:variable name="VarWifFrameId" select="$ParamParagraph/descendant::wwdoc:Frame[1]/@id" />
    <xsl:variable name="VarSplitsFrame" select="$ParamSplits/wwsplits:Splits/wwsplits:Split/wwsplits:Frame[@id = $VarWifFrameId]" />
    <xsl:variable name="VarImageInfo" select="wwimaging:GetInfo($VarSplitsFrame/@path)" />
    
    <xsl:variable name="VarSrc" select="wwuri:GetRelativeTo($VarImageInfo/@path, $ParamSplit/@path)" />
    <xsl:variable name="VarLog" select="wwlog:Warning($VarSrc)"/>
    
    <html:table style="width: 100%;">
      <html:tr>
        <!-- First cell with relative width -->
        <!--                             -->
        <html:td style="padding-left: 5%; text-align: left;">
          <html:img src="{$VarSrc}" class="EquationGraphic" style="border: 0px; vertical-align: baseline;" />
        </html:td>
        
        <!-- Second cell with fixed width -->
        <!--                                 -->
        <html:td style="padding-right: 20px; text-align: right;">
          <xsl:for-each select="$ParamParagraph/wwdoc:Number">
            <html:div style="font-weight: bold; font-size: large;">
              <xsl:for-each select="descendant::wwdoc:Text">
                <xsl:value-of select="@value" />
              </xsl:for-each>
            </html:div>
          </xsl:for-each>
        </html:td>
      </html:tr>
    </html:table>
  </xsl:template>
  
  
</xsl:stylesheet>
