| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 
 | <?xml version = "1.0"?>
<xsl:stylesheet version="1.0" 
  xmlns="http://dl.kr.org/dig/lang">
  
</xsl:stylesheet>
  <xsl:output indent="yes" method="xml"/>
  <xsl:key name="terms" match="term" use="id"/>
  <xsl:template match="/">
    <tells   xmlns="http://dl.kr.org/dig/lang">
      <clearKB\>
      <xsl:apply-templates select="obo/term"/>
      <xsl:apply-templates select="obo/typedef"/>
    </rdf:RDF>
  </xsl:template>
  <xsl:template match="term">
    <defconcept>
      <xsl:attribute name="name">
        <xsl:value-of select="id"/>        
      </xsl:attribute>
    </defconcept>
    <xsl:apply-templates select="is_a"/>
    <xsl:apply-templates select="relationship"/>
    <xsl:if test="count(intersection_of)>0">
      <equalc>
        <catom>
          <xsl:attribute name="name">
            <xsl:value-of select="id"/>                    
          </xsl:attribute>
        </catom>
        <and>
          <xsl:apply-templates select="intersection_of"/>
        </and>
      </equalc>
    </xsl:if>
  </xsl:template>
  <xsl:template match="typedef">
    <defrole>
      <xsl:attribute name="name">
        <xsl:value-of select="id"/>        
      </xsl:attribute>
    </defrole>
  </xsl:template>
  <xsl:template match="is_a">
    <xsl:if test="not(@novel_inferred) and not(@problematic_inferred)">
      <xsl:comment>
        <xsl:text> </xsl:text>
        <xsl:value-of select="key('terms',.)/name"/>
        <xsl:text> </xsl:text>
      </xsl:comment>
      <rdfs:subClassOf>
        <xsl:apply-templates mode="rdf-resource" select="."/>
      </rdfs:subClassOf>
    </xsl:if>
  </xsl:template>
  <xsl:template match="relationship">
    <rdfs:subClassOf>
      <xsl:apply-templates mode="restriction" select="."/>      
    </rdfs:subClassOf>
  </xsl:template>
    
  <xsl:template match="intersection_of">
    <xsl:choose>
      <xsl:when test="type='is_a'">
        <catom>
          <xsl:attribute name="name">
            <xsl:value-of select="to"/>                    
          </xsl:attribute>
        </catom>
      </xsl:when>
      <xsl:otherwise>
        <some>
          <ratom>
            <xsl:attribute name="name">
              <xsl:value-of select="type"/>
            </xsl:attribute>
          </ratom>
          <iset>
            <atom>
              <xsl:attribute name="name">
                <xsl:value-of select="to"/>
              </xsl:attribute>
            </atom>
          </iset>
        </some>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template mode="restriction" match="*">
    <owl:Restriction>
      <owl:onProperty>
        <owl:ObjectProperty>
          <xsl:apply-templates mode="rdf-about" select="type"/>
        </owl:ObjectProperty>
      </owl:onProperty>
      <owl:someValuesFrom>
        <xsl:apply-templates mode="rdf-resource" select="to"/>
      </owl:someValuesFrom>
    </owl:Restriction>
    <xsl:comment>
      <xsl:text> </xsl:text>
      <xsl:value-of select="key('terms', to)/name"/>
      <xsl:text> </xsl:text>
    </xsl:comment>
  </xsl:template>
  
  <xsl:template match="text()|@*">
  </xsl:template>
  <!-- RDF stuff -->
  <xsl:template mode="rdf-id" match="*">
    <xsl:attribute name="rdf:ID">
      <xsl:value-of select="translate(.,':','_')"/>
    </xsl:attribute>
  </xsl:template>
  <xsl:template mode="rdf-about" match="*">
    <xsl:attribute name="rdf:about">
      <xsl:text>#</xsl:text>
      <xsl:value-of select="translate(.,':','_')"/>
    </xsl:attribute>
  </xsl:template>
  <xsl:template mode="rdf-resource" match="*">
    <xsl:attribute name="rdf:resource">
      <xsl:text>#</xsl:text>
      <xsl:value-of select="translate(.,':','_')"/>
    </xsl:attribute>
  </xsl:template>
</xsl:stylesheet>
 |