xsl-list
[Top] [All Lists]

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

2006-11-25 18:25:42
Hi,

in RDF and OWL most of the information is stored in the content of the
attributes, so in this case I personally have found using the "key
construct" really helpful.

specially in your OWL file the information is so easy to track by
defining constructs like

<xsl:key name="FindPerson" match="owl:Class/rdfs:subClassOf"
use="@rdf:resource"/>

then by using something like the code below you can extract all the
information for all the kids

<xsl:for-each select="key('FindPerson', '#Dad')">
    <!-- you can manipulate the node here  something like the part below-->
    <xsl:variable name="sonOrDaughter">
        <xsl:value-of select="../@rdf:ID"/>
    </xsl:variable>
</xsl:for-each>

if there is any chance for having both of the formats below:

<owl:Class rdf:about="#Dad">
  <rdfs:subClassOf>
    <owl:Class rdf:about="#Grandad"/>
  </rdfs:subClassOf>
</owl:Class>

<owl:Class rdf:about="#Dad">
  <rdfs:subClassOf rdf:resource="#Grandad"/>
</owl:Class>

then you can have the following keys with the sane "name"

<xsl:key name="FindGrandad" match="owl:Class/rdfs:subClassOf"
use="@rdf:resource"/>
<xsl:key name="FindGrandad"
match="owl:Class/rdfs:subClassOf/owl:Class" use="@rdf:about"/>

It is a bit tricky and sometimes makes your code look ugly though.
Does anybody else have a better suggestion?

cheers,
-Nima

On 11/25/06, John Smith <debrief(_at_)gmail(_dot_)com> wrote:
Hello,


I am trying to display the below file using xslt as a tree structure;

------------------------------------------------------------------
<?xml version="1.0"?>
<rdf:RDF
    xmlns:rdf=" http://www.w3.org/1999/02/22-rdf-syntax-ns#";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#";
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#";
    xmlns:owl="http://www.w3.org/2002/07/owl#";>

  <owl:Class rdf:about="#Grandad">
    <rdfs:comment
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>old</rdfs:comment>
  </owl:Class>

  <owl:Class rdf:about="#Dad">
    <rdfs:subClassOf>
      <owl:Class rdf:about="#Grandad"/>
    </rdfs:subClassOf>
  </owl:Class>

  <owl:Class rdf:ID="Son">
    <rdfs:subClassOf rdf:resource="#Dad"/>
  </owl:Class>

  <owl:Class rdf:ID="Daughter">
    <rdfs:subClassOf rdf:resource="#Dad"/>
  </owl:Class>

</rdf:RDF>

------------------------------------------------------------


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
as:
<Grandad>
  <Dad>
    <Son>
    </Son>
    <Daughter>
    </Daughter>
  </Dad>
</Grandad>

How can I display this using xsl to show the hierarchy of classes ?

Grandad( Dad( Son(), Daughter() ) )

I am not too concerned with the form of presentation, only how to
backtrack the Classes based on the relationship.
For example to be able to create something like the below:
<div>
    Grandad
    <div>
        Dad
        <div>
            Son
        </div>
        <div>
            Daughter
        </div>
    </div>
</div>



Thanks in advance
John

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--