<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:output method="html"/>

  <xsl:template match="/">
    <html>
      <head>
        <link rel="stylesheet" href="stylesheet.css" type="text/css"/>
<link href="http://www.obofoundry.org/css/main.css"
      media="all"
      rel="Stylesheet"
      type="text/css" />
<link href="http://www.obofoundry.org/css/table.css"
      media="all"
      rel="Stylesheet"
      type="text/css" />
<link href="http://www.obofoundry.org/css/menu.css"
      media="all"
      rel="Stylesheet"
      type="text/css" />
<link href="http://www.obofoundry.org/css/detail.css"
      media="all"
      rel="Stylesheet"
      type="text/css" />
<link href="http://www.obofoundry.org/css/list.css"
      media="all"
      rel="Stylesheet"
      type="text/css" />
<link rel="shortcut icon"
      href="http://www.obofoundry.org/images/favicon.ico"
      type="image/x-icon" />
        <title>
          OBO Relation Ontology
        </title>
      </head>
      <body>
        <xsl:comment>
          This HTML page is autogenerated from the relations ontology obo format file using the relationship.xsl stylesheet. See cvs for details
        </xsl:comment>

        <div id="header">
          <a class="image" href="http://www.obofoundry.org"
            title="The Open Biomedical Ontology Foundry">
            <img src="http://www.obofoundry.org/images/obofoundry_logo.gif"
              alt="The Open Biomedical Ontology Foundry"
              class="image" />
          </a>
        </div>

        <div id="main_container_aux">
          <a class="image" href="http://www.obofoundry.org/ro"
            title="The Relation Ontology">
            <img src="ro_logo.png"
              alt="RO"
              class="image" />
          </a>

        <h1>OBO Relation Ontology</h1>
        <p>
          An ontology of core relations for use by <a
          href="http://obo.sourceforge.net">OBO</a> Foundry ontologies
        </p>
        <ul>
          <li>
            <a href="#reference">Reference</a>
          </li>
          <li>
            <a href="#download">Download</a>
          </li>
          <li>
            <a href="#mappings">Mappings</a>
          </li>
          <li>
            <a href="#summary">Summary</a>
          </li>
          <li>
            <a href="#details">Details</a>
          </li>
          <li>
            <a href="#wiki">Wiki</a>
          </li>
          <li>
            <a href="#pending">Pending Relations</a>
          </li>
          <li>
            <a href="#request-tracker">Request Tracker</a>
          </li>
          <li>
            <a href="#maling-list">Mailing List</a>
          </li>
        </ul>
        <h2 id="reference">Reference</h2>
        <p>
          Smith B, Ceusters W, Klagges B, Kohler J, Kumar A, Lomax J, Mungall CJ, Neuhaus F, Rector A, Rosse C <b><a href="http://genomebiology.com/2005/6/5/R46">Relations in Biomedical Ontologies</a>.</b><i>Genome Biology, 2005, 6:R46</i>
        </p>
        <h2 id="download">Download</h2>
        <p>
          Select format: [
          <a href="ro.obo">OBO-Text Format</a>
          |
          <a href="ro.obo-xml">OBO-XML Format</a>
          |
          <a href="ro.owl">OWL Format</a>
          ]
        </p>
        <p>The native format is OBO; the OWL file is automatically
        derived from the OBO-XML</p>
        <h2 id="mappings">Mappings and inter-ontology bridges</h2>
        <p>
          Domain and range constraints using <a
          href="http://www.ifomis.org/bfo">BFO</a> are available (test
          release). To use these, you will have to import 3 documents:
          ro, bfo and ro_bfo_bridge.
        </p>
        <p>
          Select format: [
          <a href="ro_bfo_bridge.obo">OBO-Text Format</a>
          |
          <a href="ro_bfo_bridge.obo-xml">OBO-XML Format</a>
          |
          <a href="ro_bfo_bridge.owl">OWL Format</a>
          ]
        </p>
        <p></p>
        <h2 id="summary">Summary Table</h2>
        <table border="1">
          <tr>
            <th>
              name
            </th>
            <th>
              transitive
            </th>
            <th>
              symmetric
            </th>
            <th>
              reflexive
            </th>
            <th>
              anti-symmetric
            </th>
            <th>
              documentation
            </th>
          </tr>
          <xsl:apply-templates mode="summary" select="*/typedef[def and name != 'relationship' and not(is_obsolete='1')]"/>
        </table>
        <h2 id="details">Details</h2>
        <xsl:apply-templates mode="detail" select="*/typedef[def and name != 'relationship' and not(is_obsolete='1')]"/>
        <h2 id="about">About</h2>
        <div class="remark">
          <p>
            <xsl:value-of 
              disable-output-escaping="yes" select="obo/header/remark"/>
          </p>
        </div>
        <h2 id="wiki">Wiki</h2>
        <p>
          A preliminary <a href="http://www.bioontology.org/wiki/index.php/RO:Main_Page">Relation Ontology Wiki</a> has been set up on the <a href="http://www.bioontology.org/wiki/index.php/Main_Page">Wiki site for OBO ontology content</a>
        </p>
        <h2 id="pending">Pending Relations</h2>
        <h3>Relations required in OBO</h3>
        <p>
          The relations below are required for OBO, but not all have
          yet been defined or approved. They are still available for
          use, with caveats, below. See also the <a href="#release-tracker">tracker</a>
        </p> 
        <p>
          Select format: [
          <a href="http://www.berkeleybop.org/ontologies/obo-all/ro_proposed/ro_proposed.obo">OBO Format</a>
          |
          <a href="http://www.berkeleybop.org/ontologies/obo-all/ro_proposed/ro_proposed.obo-xml">OBO-XML Format</a>
          |
          <a href="http://www.berkeleybop.org/ontologies/obo-all/ro_proposed/ro_proposed.owl">OWL</a>
          ]
        </p>
        <p>
          Many of these relations are used in the OBO Foundry <a href="http://www.berkeleybop.org/ontologies#logical_definitions">cross-products</a>, and in <a href="http://www.berkeleybop.org/obol">Obol</a> predictions
        </p>
        <h3>Relations proposed by UCDHSC</h3>
        <p>
          Select format: [
          <a href="http://www.berkeleybop.org/ontologies/obo-all/ro_ucdhsc/ro_ucdhsc.obo">OBO Format</a>
          |
          <a href="http://www.berkeleybop.org/ontologies/obo-all/ro_ucdhsc/ro_ucdhsc.obo-xml">OBO-XML Format</a>
          |
          <a href="http://www.berkeleybop.org/ontologies/obo-all/ro_ucdhsc/ro_ucdhsc.owl">OWL</a>
          ]
        </p>
        <p>
          Many of these relations are required for <a href="http://www.obofoundry.org/cgi-bin/detail.cgi?id=go_xp_chebi">GO-to-CheBI cross-products</a>
        </p>
        <h3>Relations proposed by OBI</h3>
        <p>
          (Open Biomedical Investigations)
          <a href="https://wiki.cbil.upenn.edu/obiwiki/index.php/ListOfRelationships">ListOfRelationships</a> on OBI wiki
        </p>
        <h2 id="request-tracker">Request Tracker</h2>
        <p>
          Requests for new relations, or suggestions for changes to existing relations can be made using a standard OBO sourceforge tracker:
          <a href="http://sourceforge.net/tracker/?group_id=76834&amp;atid=947684">obo-relation-requests</a>
        </p>
        <h2 id="mailing-list">Mailing List</h2>
        <p>
          You can browse or subscribe to the obo-relations mail list
          here:
          <a href="http://lists.sourceforge.net/lists/listinfo/obo-relations">http://lists.sourceforge.net/lists/listinfo/obo-relations</a>
        </p>
        <hr/>
        <font size="-2">
          <xsl:value-of select="obo/header/date"/>
          <br/>
          <xsl:comment select="obo/header/saved-by"/>
          <xsl:text>Page maintained by: Chris Mungall</xsl:text>
        </font>
      </div>
      </body>
    </html>
  </xsl:template>

  <xsl:template mode="summary" match="typedef">
    <tr>
      <td >
        <xsl:value-of select="name"/>
      </td>
      <td >
        <xsl:apply-templates select="is_transitive" mode="show-bool"/>
      </td>
      <td >
        <xsl:apply-templates select="is_symmetric" mode="show-bool"/>
      </td>
      <td >
        <xsl:apply-templates select="is_reflexive" mode="show-bool"/>
      </td>
      <td >
        <xsl:apply-templates select="is_anti_symmetric" mode="show-bool"/>
      </td>
      <td >
        <a>
          <xsl:attribute name="href">
            <xsl:text>#</xsl:text>
            <xsl:value-of select="id"/>
          </xsl:attribute>
          <xsl:text>View detailed summary</xsl:text>
        </a>
      </td>
    </tr>
  </xsl:template>

  <xsl:template mode="detail" match="typedef">
    <a>
      <xsl:attribute name="name">
        <xsl:value-of select="id"/>
      </xsl:attribute>
    </a>
    <h4><xsl:value-of select="name"/></h4>
    <table border="1">
      <tr>
        <th>ID</th>
        <td>
          <xsl:value-of select="id"/>
        </td>
      </tr>
      <tr>
        <th>Name</th>
        <td>
          <xsl:value-of select="name"/>
        </td>
      </tr>
      <tr>
        <th>Relation properties</th>
        <td>
          <xsl:if test="is_transitive">
            <xsl:text> [transitive] </xsl:text>
          </xsl:if>
          <xsl:if test="is_reflexive">
            <xsl:text> [reflexive] </xsl:text>
          </xsl:if>
          <xsl:if test="is_symmetric">
            <xsl:text> [symmetric] </xsl:text>
          </xsl:if>
          <xsl:if test="is_anti_symmetric">
            <xsl:text> [anti-symmetric] </xsl:text>
          </xsl:if>
        </td>
      </tr>
      <xsl:if test="inverse_of">
        <tr>
          <th>inverse_of</th>
          <td>
            <xsl:value-of select="inverse_of"/> 
            <font size="-2"><xsl:text>  (instance level)</xsl:text></font>
          </td>
        </tr>
      </xsl:if>
      <tr>
        <th>Definition</th>
        <td >
          <xsl:apply-templates mode="text2html" select="def/defstr"/>
        </td>
      </tr>
      <tr>
        <th>Comments</th>
        <td >
          <xsl:apply-templates mode="text2html" select="comment"/>
        </td>
      </tr>
    </table>
  </xsl:template>

  <!-- modified from: http://www.xml.com/pub/a/2002/06/05/transforming.html -->
  <xsl:template name="globalReplace">
    <xsl:param name="outputString"/>
    <xsl:param name="target"/>

    <xsl:choose>
      <xsl:when test="contains($outputString,$target)">
        
        <xsl:value-of select="substring-before($outputString,$target)"/>
        <br/>
        <xsl:call-template name="globalReplace">
          <xsl:with-param name="outputString" 
            select="substring-after($outputString,$target)"/>
          <xsl:with-param name="target" select="$target"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$outputString"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>         
  
  <xsl:template match="*" mode="show-bool">
    <xsl:choose>
      <xsl:when test=".=1">
        <xsl:text>+</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>-</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template mode="text2html" match="*|text()">
    <xsl:call-template name="globalReplace">
      <xsl:with-param name="outputString" select="."/>
      <xsl:with-param name="target" select="'\n'"/>
    </xsl:call-template>

  </xsl:template>

</xsl:stylesheet>
