/usr/share/perl5/GO/xsl/owl_to_oboxml.xsl is in libgo-perl 0.15-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
version="1.0"
>
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<obo>
<xsl:apply-templates select="rdf:RDF"/>
</obo>
</xsl:template>
<xsl:template match="rdf:RDF">
<xsl:apply-templates select="owl:Ontology"/>
<xsl:apply-templates select="owl:Class" mode="default"/>
<xsl:apply-templates select="owl:ObjectProperty|owl:TransitiveProperty"/>
<xsl:apply-templates select="owl:DatatypeProperty"/>
<xsl:apply-templates select="owl:FunctionalProperty"/>
</xsl:template>
<xsl:template match="owl:Ontology">
<header>
<remark>
<xsl:value-of select="rdfs:comment"/>
</remark>
<default_namespace>
<xsl:value-of select="rdfs:label"/>
</default_namespace>
</header>
</xsl:template>
<xsl:template match="owl:ObjectProperty|owl:DatatypeProperty|owl:FunctionalProperty|owl:TransitiveProperty">
<typedef>
<id>
<xsl:value-of select="substring-after(@rdf:about,'#')"/>
<xsl:value-of select="@rdf:ID"/>
</id>
<name>
<xsl:choose>
<xsl:when test="rdfs:label">
<xsl:value-of select="rdfs:label"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@rdf:ID"/>
</xsl:otherwise>
</xsl:choose>
</name>
<xsl:if test="name(..) = 'owl:TransitiveProperty'">
<is_transitive>true</is_transitive>
</xsl:if>
<xsl:apply-templates select="rdfs:subPropertyOf"/>
<xsl:apply-templates select="rdfs:domain"/>
<xsl:apply-templates select="rdfs:range"/>
<xsl:apply-templates mode="namespace" select="../owl:Ontology"/>
</typedef>
</xsl:template>
<xsl:template match="rdfs:comment">
<comment>
<xsl:value-of select="."/>
</comment>
</xsl:template>
<xsl:template match="rdfs:subPropertyOf">
<is_a>
<xsl:value-of select="substring-after(owl:Class/@rdf:about,'#')"/>
<xsl:value-of select="substring-after(@rdf:resource,'#')"/>
<xsl:value-of select="owl:Class/@rdf:ID"/>
</is_a>
</xsl:template>
<xsl:template match="rdfs:domain">
<domain>
<xsl:value-of select="substring-after(owl:Class/@rdf:about,'#')"/>
<xsl:value-of select="substring-after(@rdf:resource,'#')"/>
<xsl:value-of select="owl:Class/@rdf:ID"/>
</domain>
</xsl:template>
<xsl:template match="rdfs:range">
<range>
<xsl:value-of select="substring-after(owl:Class/@rdf:about,'#')"/>
<xsl:value-of select="substring-after(@rdf:resource,'#')"/>
<xsl:value-of select="owl:Class/@rdf:ID"/>
</range>
</xsl:template>
<!-- map owl:Class to term -->
<xsl:template match="owl:Class" mode="default">
<term>
<id>
<xsl:value-of select="substring-after(@rdf:about,'#')"/>
<xsl:value-of select="@rdf:ID"/>
</id>
<name>
<xsl:choose>
<xsl:when test="rdfs:label">
<xsl:value-of select="rdfs:label"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@rdf:ID"/>
</xsl:otherwise>
</xsl:choose>
</name>
<!-- both normal subclasses and restrictions are under subclass -->
<xsl:apply-templates select="owl:equivalentClass"/>
<xsl:apply-templates select="owl:intersectionOf"/>
<xsl:apply-templates select="rdfs:subClassOf"/>
<xsl:apply-templates select="owl:disjointWith"/>
<xsl:apply-templates mode="namespace" select="../owl:Ontology"/>
</term>
</xsl:template>
<xsl:template match="*" mode="namespace">
<xsl:if test="rdfs:label">
<namespace>
<xsl:value-of select="rdfs:label"/>
</namespace>
</xsl:if>
</xsl:template>
<!-- embedded in equivalentClass -->
<xsl:template match="owl:Class" mode="in-equiv">
<xsl:apply-templates select="owl:intersectionOf"/>
</xsl:template>
<!-- equivalentClass -->
<xsl:template match="owl:equivalentClass">
<xsl:apply-templates select="owl:Class" mode="in-equiv"/>
<!-- restrictions may be inside equivalentClass -->
<xsl:apply-templates select="owl:Restriction"/>
</xsl:template>
<!-- is_as and relationships -->
<xsl:template match="rdfs:subClassOf">
<xsl:choose>
<xsl:when test="not(owl:Restriction)">
<is_a>
<xsl:value-of select="substring-after(owl:Class/@rdf:about,'#')"/>
<xsl:value-of select="substring-after(@rdf:resource,'#')"/>
<xsl:value-of select="owl:Class/@rdf:ID"/>
</is_a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="owl:Restriction"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- map owl:Restriction to relationships -->
<xsl:template match="owl:Restriction">
<!-- restrictions may be object, datatype or functional properties -->
<!-- ObjectProperty - normal obo relationship -->
<xsl:if test="owl:onProperty/owl:ObjectProperty">
<relationship>
<type>
<!-- rdf:about or rdf:ID can be used -->
<xsl:value-of select="owl:onProperty/owl:ObjectProperty/@rdf:ID"/>
<xsl:value-of select="substring-after(owl:onProperty/owl:ObjectProperty/@rdf:about,'#')"/>
<xsl:value-of select="substring-after(owl:onProperty/owl:ObjectProperty/@rdf:resource,'#')"/>
</type>
<xsl:apply-templates select="owl:allValuesFrom|owl:someValuesFrom|owl:hasValue"/>
<xsl:apply-templates select="owl:maxCardinality"/>
</relationship>
</xsl:if>
<!-- Functional Property -->
<xsl:if test="owl:onProperty/owl:FunctionalProperty">
<functional_property>
<type>
<!-- rdf:about or rdf:ID can be used -->
<xsl:value-of select="owl:onProperty/owl:FunctionalProperty/@rdf:ID"/>
<xsl:value-of select="substring-after(owl:onProperty/owl:FunctionalProperty/@rdf:about,'#')"/>
<xsl:value-of select="substring-after(owl:onProperty/owl:FunctionalProperty/@rdf:resource,'#')"/>
</type>
<xsl:apply-templates select="owl:allValuesFrom|owl:someValuesFrom|owl:hasValue"/>
<xsl:apply-templates select="owl:maxCardinality"/>
</functional_property>
</xsl:if>
<xsl:if test="owl:onProperty/owl:DatatypeProperty">
<xsl:comment>
ignoring datatype property
<xsl:value-of select="substring-after(owl:onProperty/owl:DatatypeProperty/@rdf:about,'#')"/>
<xsl:text> </xsl:text>
</xsl:comment>
</xsl:if>
</xsl:template>
<xsl:template match="owl:allValuesFrom|owl:someValuesFrom">
<to>
<xsl:apply-templates mode="resolve-id" select="."/>
</to>
</xsl:template>
<xsl:template match="owl:hasValue">
<to>
<xsl:value-of select="*/@rdf:ID"/>
<xsl:value-of select="substring-after(*/@rdf:about,'#')"/>
<xsl:value-of select="substring-after(@rdf:resource,'#')"/>
<xsl:value-of select="@rdf:datatype"/>
</to>
</xsl:template>
<xsl:template match="owl:maxCardinality">
<max_cardinality>
<xsl:value-of select="."/>
</max_cardinality>
</xsl:template>
<xsl:template match="owl:intersectionOf">
<xsl:for-each select="owl:Class">
<intersection_of>
<type>is_a</type>
<to>
<xsl:apply-templates mode="resolve-id" select="."/>
</to>
</intersection_of>
</xsl:for-each>
<xsl:for-each select="owl:Restriction">
<intersection_of>
<type>
<xsl:choose>
<!-- todo: not exhaustive enough -->
<xsl:when test="owl:onProperty/owl:ObjectProperty">
<xsl:apply-templates mode="resolve-id" select="owl:onProperty/owl:ObjectProperty"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates mode="resolve-id" select="owl:onProperty"/>
</xsl:otherwise>
</xsl:choose>
</type>
<to>
<!-- warning!! currently obo does not distinguish existential/universal -->
<xsl:choose>
<xsl:when test="owl:allValuesFrom|owl:someValuesFrom|owl:hasValue">
<xsl:apply-templates mode="resolve-id"
select="owl:allValuesFrom|owl:someValuesFrom|owl:hasValue"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:text>relationship to unresolvable</xsl:text>
<xsl:copy-of select="."/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</to>
</intersection_of>
</xsl:for-each>
</xsl:template>
<xsl:template match="owl:disjointWith">
<disjoint_with>
<xsl:apply-templates mode="resolve-id" select="owl:Class"/>
</disjoint_with>
</xsl:template>
<xsl:template mode="resolve-id" match="*|@*">
<xsl:choose>
<!-- multiple ways of refering to something -->
<xsl:when test="owl:Class">
<!-- class object - recursively resolve -->
<xsl:apply-templates mode="resolve-id" select="owl:Class"/>
</xsl:when>
<xsl:when test="@rdf:ID">
<xsl:value-of select="@rdf:ID"/>
</xsl:when>
<xsl:when test="substring-after(@rdf:about,'#')">
<xsl:value-of select="substring-after(@rdf:about,'#')"/>
</xsl:when>
<xsl:when test="substring-after(@rdf:resource,'#')">
<xsl:value-of select="substring-after(@rdf:resource,'#')"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>Cannot resolve ID: </xsl:text>
<xsl:copy-of select="."/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|