source: RELcat/trunk/mod-RELcat-interface-rest/representations/SRX-spo-RDF.xsl @ 2029

Last change on this file since 2029 was 2029, checked in by mwindhouwer, 12 years ago

Initial import of all the *cats, i.e., ISOcat, RELcat and SCHEMAcat.

File size: 1.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet
3    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4    version="2.0"
5    xmlns:sparql="http://www.w3.org/2005/sparql-results#"
6    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7>
8   
9    <xsl:template match="text()"/>
10   
11    <xsl:template match="/sparql:sparql">
12        <rdf:RDF>
13            <xsl:apply-templates/>
14        </rdf:RDF>
15    </xsl:template>
16   
17    <xsl:template match="sparql:result[exists(sparql:binding[@name='s']) and exists(sparql:binding[@name='p']) and exists(sparql:binding[@name='o'])]">
18        <xsl:variable name="s" select="sparql:binding[@name='s']/sparql:uri"/>
19        <xsl:variable name="p" select="sparql:binding[@name='p']/sparql:uri"/>
20        <xsl:variable name="o" select="sparql:binding[@name='o']/sparql:uri"/>
21        <rdf:Description rdf:about="{$s}">
22            <xsl:choose>
23                <xsl:when test="contains($p,'#')">
24                    <xsl:element namespace="{substring-before($p,'#')}#" name="{substring-after($p,'#')}">
25                        <xsl:attribute name="rdf:resource" select="$o"/>
26                    </xsl:element>
27                </xsl:when>
28                <xsl:when test="replace($p,'.*/','')!=''">
29                    <xsl:element namespace="{replace($p,'/[^/]*?$','')}/" name="{replace($p,'.*/','')}">
30                        <xsl:attribute name="rdf:resource" select="$o"/>
31                    </xsl:element>
32                </xsl:when>
33                <xsl:otherwise>
34                    <xsl:message terminate="yes">
35                        <xsl:text>ERR: don't know how to transform the URI[</xsl:text>
36                        <xsl:value-of select="$p"/>
37                        <xsl:text>] into a valid QName!</xsl:text>
38                    </xsl:message>
39                </xsl:otherwise>
40            </xsl:choose>
41        </rdf:Description> 
42    </xsl:template>
43   
44</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.