LaTeXML

 view release on metacpan or  search on metacpan

lib/LaTeXML/resources/XSLT/LaTeXML-jats.xsl  view on Meta::CPAN

  <xsl:template match="ltx:note[@role='footnote']">
    <fn id="{generate-id(.)}">
      <xsl:call-template name="require_p"/>
    </fn>
  </xsl:template>

  <xsl:template match="ltx:inline-block">
    <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="ltx:verbatim">
    <preformat>
      <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
      <xsl:apply-templates/>
    </preformat>
  </xsl:template>

  <xsl:template match="ltx:quote">
    <disp-quote>
      <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
      <xsl:apply-templates/>
    </disp-quote>
  </xsl:template>

  <xsl:template match="ltx:itemize">
    <p>
      <list list-type="bullet">
        <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
        <xsl:apply-templates/>
      </list>
    </p>
  </xsl:template>

  <xsl:template match="ltx:enumerate">
    <p>
      <list list-type="order">
        <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
        <xsl:apply-templates/>
      </list>
    </p>
  </xsl:template>

  <xsl:template match="ltx:description">
    <list>
      <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
      <xsl:apply-templates/>
    </list>
  </xsl:template>

  <xsl:template match="ltx:item">
    <list-item>
      <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
      <xsl:apply-templates/>
    </list-item>
  </xsl:template>

  <!-- ======================================================================
       Equations and Math -->
  <xsl:template match="ltx:equationgroup">
    <disp-formula-group>
      <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
      <xsl:apply-templates/>
    </disp-formula-group>
  </xsl:template>

  <xsl:template match="ltx:equation">
    <xsl:choose>
      <xsl:when test="count(ltx:Math | ltx:MathFork) > 1"> <!--Each needs disp-formula -->
        <disp-formula-group>
          <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
          <xsl:for-each select="ltx:Math | ltx:MathFork">
            <disp-formula>
              <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
              <xsl:apply-templates select="."/>
            </disp-formula>
          </xsl:for-each>
        </disp-formula-group>
      </xsl:when>
      <xsl:otherwise>
        <disp-formula>
          <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
          <xsl:apply-templates/>
        </disp-formula>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="ltx:Math[@mode='inline']">
    <inline-formula>
      <xsl:apply-templates select="m:math"/>
    </inline-formula>
  </xsl:template>

  <!-- caller (ltx:equation) will wrap disp-formula, as needed -->
  <xsl:template match="ltx:Math">
    <xsl:apply-templates select="m:math"/>
  </xsl:template>

  <xsl:template match="ltx:MathFork">
    <xsl:apply-templates select="ltx:Math[1]/m:math"/>
  </xsl:template>

  <!-- Copy MathML as is, but use mml as namespace prefix,
       since that's assumed by many non-XML aware JATS applications. -->
  <xsl:template match="m:*">
    <xsl:element name="mml:{local-name()}" namespace="http://www.w3.org/1998/Math/MathML">
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="m:math">
    <xsl:element name="mml:math" namespace="http://www.w3.org/1998/Math/MathML">
      <!-- Get the ltx:Math's @xml:id onto the mml:math -->
      <xsl:apply-templates select="../@xml:id" mode="copy-attribute"/>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

  <!-- ======================================================================
       Figures, Tables, Floats, Theorems, etc -->

  <xsl:template match="ltx:caption">
    <caption>
      <xsl:if test="./ltx:p">
        <xsl:apply-templates/>
      </xsl:if>
      <xsl:if test="not(./ltx:p)">
        <p>
          <xsl:apply-templates/>
        </p>
      </xsl:if>
    </caption>
  </xsl:template>

  <xsl:template match="ltx:toccaption"/>

  <xsl:template match="ltx:float">
    <boxed-text>
      <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
      <xsl:apply-templates/>
    </boxed-text>
  </xsl:template>

  <xsl:template match="ltx:figure">
    <fig>
      <xsl:apply-templates select="@xml:id" mode="copy-attribute"/>
      <xsl:apply-templates select="ltx:caption"/>
      <xsl:apply-templates select="*[not(self::ltx:caption)]"/>
    </fig>
  </xsl:template>

  <xsl:template match="ltx:table">



( run in 1.174 second using v1.01-cache-2.11-cpan-5a3173703d6 )