<xsl:stylesheet
  xmlns:math="http://www.w3.org/1998/Math/MathML"
  xmlns:mdf="http://www.mathdox.org/MathDox/Functions"
  xmlns:om="http://www.openmath.org/OpenMath"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0"
>
  <!-- include new plangeo stylesheets as proposed by Xiaoyu chen -->
  <!--<xsl:include href="functions.xsl"/>-->
  <xsl:include href="plangeo-new.xsl"/>

  <!--
    This file contains the CDs: (in alphabetical order)
    - plangeo1 version 0 (Revision 5)
    - plangeo2 version 0 (Revision 1)
    - plangeo3 version 0 (Revision 2)
    - plangeo4 version 0 (Revision 4)
    - plangeo5 version 0 (Revision 2)
    - plangeo6 version 0 (Revision 3)
    
    In these CDs all symbols are present in alphabetical order.
  -->

  <!--
    plangeo1
    the following symbols are implemented:
    - are_on_line
    - assertion
    - configuration
    - incident
    - line
    - point
    - type
  -->
  
  <!--
    plangeo1.are_on_line
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo1" and @name="are_on_line"]]|
    om:OMA[om:OMS[@cd="plangeo1" and @name="are_on_line"]]'
  >
    <math:mrow>
      <xsl:copy-of select='mdf:makelist(*[position() &gt; 1])'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;are colinear</xsl:text>
      </math:mtext>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo1.assertion
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo1" and @name="assertion"]]|
    om:OMA[om:OMS[@cd="plangeo1" and @name="assertion"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>Suppose that we are given&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>. Then&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[3]'/>
      <math:mtext>
        <xsl:text>.</xsl:text>
      </math:mtext>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo1.configuration
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo1" and @name="configuration"]]|
    om:OMA[om:OMS[@cd="plangeo1" and @name="configuration"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the configuration consisting of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:copy-of select='mdf:makelist(*[position() &gt; 1])'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo1.incident
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo1" and @name="incident"]]|
    om:OMA[om:OMS[@cd="plangeo1" and @name="incident"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;is incident with&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo1.line
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo1" and @name="line"]]|
    om:OMA[om:OMS[@cd="plangeo1" and @name="line"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the line&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <xsl:if test='*[3]'>
        <!--
          handle conditions
        -->
        <math:mtext>
          <!-- U+00A0 non breakable space -->
          <xsl:text>, such that&#xA0;</xsl:text>
        </math:mtext>
        <xsl:copy-of select='mdf:makelist(*[position() &gt; 2])'/>
      </xsl:if>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo1.point
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo1" and @name="point"]]|
    om:OMA[om:OMS[@cd="plangeo1" and @name="point"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the point&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <xsl:if test='*[3]'>
        <!--
          handle conditions
        -->
        <math:mtext>
          <!-- U+00A0 non breakable space -->
          <xsl:text>, such that&#xA0;</xsl:text>
        </math:mtext>
        <xsl:copy-of select='mdf:makelist(*[position() &gt; 2])'/>
      </xsl:if>
    </math:mrow>
  </xsl:template>

  <!-- 
    plangeo1.point mode='short'
    if an OMV with no conditions then only show the OMV, otherwise as #default
  -->
  <xsl:template mode='short' 
    match='OMA[OMS[@cd="plangeo1" and @name="point"]]|
    om:OMA[om:OMS[@cd="plangeo1" and @name="point"]]'
  >
    <xsl:choose>
      <xsl:when test='not(*[3]) and *[2][self::OMV or self::om:OMV]'>
        <xsl:apply-templates select='*[2]'/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select='.' mode='#default'/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


  <!--
    plangeo1.type
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo1" and @name="type"]]|
    om:OMA[om:OMS[@cd="plangeo1" and @name="type"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the type of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo2
    the following symbols are implemented:
    - corner
    - endpoint
    - endpoints
    - halfline
    - segment
  -->

  <!--
    plangeo2.corner
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo2" and @name="corner"]]|
    om:OMA[om:OMS[@cd="plangeo2" and @name="corner"]]'
  >
    <math:mrow>
      <math:mo>
        <!-- U+2220 angle -->
        <xsl:text>&#x2220;</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[2]'/>
      <xsl:apply-templates select='*[3]'/>
      <xsl:if test='*[4]'>
        <xsl:apply-templates select='*[4]'/>
      </xsl:if>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo2.endpoint
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo2" and @name="endpoint"]]|
    om:OMA[om:OMS[@cd="plangeo2" and @name="endpoint"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the endpoint of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo2.endpoints
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo2" and @name="endpoints"]]|
    om:OMA[om:OMS[@cd="plangeo2" and @name="endpoints"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the endpoints of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo2.halfline
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo2" and @name="halfline"]]|
    om:OMA[om:OMS[@cd="plangeo2" and @name="halfline"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the halfline from&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;through &#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo2.segment
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo2" and @name="segment"]]|
    om:OMA[om:OMS[@cd="plangeo2" and @name="segment"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the segment &#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3
    the following symbols are implemented:
    - altitude
    - angle
    - arc
    - are_on_circle
    - center
    - center_of
    - center_of_gravity
    - circle
    - distance
    - is_midpoint
    - midpoint
    - parallel
    - perbisector
    - perpendicular
    - perpline
    - polarline
    - radius
    - radius_of
    - tangent
  -->

  <!--
    plangeo3.altitude
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="altitude"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="altitude"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the altitude from &#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;onto&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.angle
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="angle"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="angle"]]'
  >
    <math:mrow>
      <math:mo>
        <!-- U+2221 measured angle -->
        <xsl:text>&#x2221;</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[2]'/>
      <xsl:apply-templates select='*[3]'/>
      <xsl:apply-templates select='*[4]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.arc
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="arc"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="arc"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the arc of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;from&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[3]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;to&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[4]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.are_on_circle
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="are_on_circle"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="are_on_circle"]]'
  >
    <math:mrow>
      <xsl:copy-of select='mdf:makelist(*[position() &gt; 1])'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;lie on one circle</xsl:text>
      </math:mtext>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.center
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="center"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="center"]]'
  >
    <math:mrow>
      <math:mtext>
        <xsl:text>center</xsl:text>
      </math:mtext>
      <math:mo>
        <xsl:text>(</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[2]'/>
      <math:mo>
        <xsl:text>)=</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.center_of
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="center_of"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="center_of"]]'
  >
    <math:mrow>
      <math:mtext>
        <xsl:text>center</xsl:text>
      </math:mtext>
      <math:mo>
        <xsl:text>(</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[2]'/>
      <math:mo>
        <xsl:text>)</xsl:text>
      </math:mo>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.center_of_gravity
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="center_of_gravity"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="center_of_gravity"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the center of gravity of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:copy-of select='mdf:makelist(*[position() &gt; 1])'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.circle
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="circle"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="circle"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the circle&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <xsl:if test='*[3]'>
        <math:mtext>
          <!-- U+00A0 non breakable space -->
          <xsl:text>&#xA0;with&#xA0;</xsl:text>
        </math:mtext>
        <xsl:copy-of select='mdf:makelist(*[position() &gt; 2])'/>
      </xsl:if>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.distance
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="distance"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="distance"]]'
  >
    <math:mrow>
      <math:mtext>
        <xsl:text>d</xsl:text>
      </math:mtext>
      <math:mo>
        <xsl:text>(</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[2]'/>
      <math:mo>
        <!-- U+00A0 non breakable space -->
        <xsl:text>,&#xA0;</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[3]'/>
      <math:mo>
        <xsl:text>)</xsl:text>
      </math:mo>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.is_midpoint
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="is_midpoint"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="is_midpoint"]]'
  >
    <math:mrow>
      <!-- first the last argument of the 2/3 -->
      <xsl:choose>
        <xsl:when test='*[4]'>
          <xsl:apply-templates select='*[4]'/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates select='*[3]'/>
        </xsl:otherwise>
      </xsl:choose>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;is the midpoint of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <xsl:if test='*[4]'>
        <!-- in the three argument case put the inserted argument here -->
        <xsl:apply-templates select='*[3]'/>
      </xsl:if>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.midpoint
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="midpoint"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="midpoint"]]'
  >
    <math:mrow>
      <math:mtext>
        <xsl:text>midpoint</xsl:text>
      </math:mtext>
      <math:mo>
        <xsl:text>(</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[2]'/>
      <xsl:if test='*[3]'>
        <xsl:apply-templates select='*[3]'/>
      </xsl:if>
      <math:mo>
        <xsl:text>)</xsl:text>
      </math:mo>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.parallel
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="parallel"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="parallel"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[2]'/>
      <math:mo>
        <!-- U+2225 parallel to -->
        <xsl:text>&#x2225;</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.perpbisector
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="perpbisector"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="perpbisector"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the perpendicular bisector of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;and&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.perpendicular
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="perpendicular"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="perpendicular"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[2]'/>
      <math:mo>
        <!-- U+27C2 perpendicular -->
        <xsl:text>&#x27C2;</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.perpline
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="perpline"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="perpline"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the line through&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;perpendicular to&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.polarline
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="polarline"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="polarline"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the type of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.radius
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="radius"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="radius"]]'
  >
    <math:mrow>
      <math:mtext>
        <xsl:text>radius</xsl:text>
      </math:mtext>
      <math:mo>
        <xsl:text>(</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[2]'/>
      <math:mo>
        <xsl:text>) = </xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.radius_of
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="radius_of"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="radius_of"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>radius of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo3.tangent
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo3" and @name="tangent"]]|
    om:OMA[om:OMS[@cd="plangeo3" and @name="tangent"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;is tangent to&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo4
    the following symbols are implemented:
    - affine_coordinates
    - coordinates
    - is_affine
    - set_affine_coordinates
    - set_coordinates
  -->

  <!--
    plangeo4.affine_coordinates
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo4" and @name="affine_coordinates"]]|
    om:OMA[om:OMS[@cd="plangeo4" and @name="affine_coordinates"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the affine coordinates of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo4.coordinates
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo4" and @name="coordinates"]]|
    om:OMA[om:OMS[@cd="plangeo4" and @name="coordinates"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the coordinates of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo4.is_affine
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo4" and @name="is_affine"]]|
    om:OMA[om:OMS[@cd="plangeo4" and @name="is_affine"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0; is affine</xsl:text>
      </math:mtext>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo4.set_affine_coordinates
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo4" and @name="set_affine_coordinates"]]|
    om:OMA[om:OMS[@cd="plangeo4" and @name="set_affine_coordinates"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[2]'/>
      <math:mo>
        <!-- U+00A0 non breakable space -->
        <xsl:text>=</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo4.set_coordinates
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo4" and @name="set_coordinates"]]|
    om:OMA[om:OMS[@cd="plangeo4" and @name="set_coordinates"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[2]'/>
      <math:mo>
        <!-- U+00A0 non breakable space -->
        <xsl:text>=</xsl:text>
      </math:mo>
      <xsl:apply-templates select='*[3]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo5
    the following symbols are implemented:
    - coordinatize
    - ideal
    - is_coordinatized
    - polynomial_assertion
  -->

  <!--
    plangeo5.coordinatize
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo5" and @name="coordinatize"]]|
    om:OMA[om:OMS[@cd="plangeo5" and @name="coordinatize"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the coordinatization of&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo5.ideal
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo5" and @name="ideal"]]|
    om:OMA[om:OMS[@cd="plangeo5" and @name="ideal"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the ideal corresponding to&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo5.is_coordinatized
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo5" and @name="is_coordinatized"]]|
    om:OMA[om:OMS[@cd="plangeo5" and @name="is_coordinatized"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[2]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0; is coordinatized</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo5.polynomial_assertion
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo5" and @name="polynomial_assertion"]]|
    om:OMA[om:OMS[@cd="plangeo5" and @name="polynomial_assertion"]]'
  >
    <math:mrow>
      <xsl:apply-templates select='*[3]'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;holds in&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo6
    the following symbols are implemented:
    - are_on_conic
    - conic
  -->

  <!--
    plangeo6.are_on_conic
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo6" and @name="are_on_conic"]]|
    om:OMA[om:OMS[@cd="plangeo6" and @name="are_on_conic"]]'
  >
    <math:mrow>
      <xsl:copy-of select='mdf:makelist(*[position() &gt; 1])'/>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>&#xA0;lie on one conic</xsl:text>
      </math:mtext>
    </math:mrow>
  </xsl:template>

  <!--
    plangeo6.conic
  -->
  <xsl:template match='OMA[OMS[@cd="plangeo6" and @name="conic"]]|
    om:OMA[om:OMS[@cd="plangeo6" and @name="conic"]]'
  >
    <math:mrow>
      <math:mtext>
        <!-- U+00A0 non breakable space -->
        <xsl:text>the conic&#xA0;</xsl:text>
      </math:mtext>
      <xsl:apply-templates select='*[2]'/>
      <xsl:if test='*[3]'>
        <math:mtext>
          <!-- U+00A0 non breakable space -->
          <xsl:text>, such that&#xA0;</xsl:text>
        </math:mtext>
        <xsl:copy-of select='mdf:makelist(*[position() &gt; 2])'/>
      </xsl:if>
    </math:mrow>
  </xsl:template>

</xsl:stylesheet>
