Re: [xsl] RDF/OWL Transformation using XSL - Backtracking Parent Classes ?

Subject: Re: [xsl] RDF/OWL Transformation using XSL - Backtracking Parent Classes ?
From: "James A. Robinson" <jim.robinson@xxxxxxxxxxxx>
Date: Sat, 25 Nov 2006 18:29:56 -0800
> However as you can see the relationship is part of each element, as
> opposed to having the element nested within each other based on their
> relationship.
> If the relationships were going downwards it would be easy, i.e. The
> "Grandad" class would state what classes are inheriting from it,
> however as inheritance and classes don't work this way, i don't know
> how these relationships can be converted to a hierarchy structure such

I'd usually think of this is a problem in recursion. Given a starting
point, Grandad, how can you identify direct descendents of Grandad,
resolving to Dad?  Given Dad, how can you resolve direct descendents of
Dad, Son and Daughter?

There are probably details I'm totally unaware of w/re to the RDF/OWL
schemas, but just eyeballing it it looks to me like the following XPath
finds direct descendents of a given owl:Class:

            or owl:Class/@rdf:about=current()/@rdf:about]]"

Assuming my guess is at least feasible, you can then wrap
it in a template match:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""; version="2.0"
  <xsl:output indent="yes"/>

  <xsl:template match="/">
    <xsl:apply-templates select="/rdf:RDF/owl:Class[@rdf:about='#Grandad']" />

  <xsl:template match="owl:Class">
    <xsl:variable name="name" select="local:name-of(.)"/>
    <xsl:element name="{$name}">
            or owl:Class/@rdf:about=current()/@rdf:about]]"

  <xsl:function name="local:name-of" as="xs:string">
    <xsl:param name="class" as="element(owl:Class)"/>
      <xsl:when test="$class/@rdf:ID">
        <xsl:value-of select="$class/@rdf:ID"/>
      <xsl:when test="$class/@rdf:about">
        <xsl:value-of select="substring($class/@rdf:about, 2)"/>
        <xsl:message terminate="yes">
          <xsl:text>Unable to extrapolate an element name from </xsl:text>
          <xsl:sequence select="$class"/>


which will emit:

<?xml version="1.0" encoding="UTF-8"?>

or, if you change the match for / to apply templates to #Dad:



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       jim.robinson@xxxxxxxxxxxx
Stanford University HighWire Press
+1 650 7237294 (Work)                   +1 650 7259335 (Fax)

Current Thread