Changeset 5243
- Timestamp:
- 05/20/14 19:24:02 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CMDI-Interoperability/CMD2RDF/trunk/xsl/Component2RDF.xsl
r4830 r5243 6 6 <!ENTITY cmdm 'http://www.clarin.eu/cmd/general.rdf#'> 7 7 ]> 8 <xsl:stylesheet 9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" 10 xmlns:dcr="http://www.isocat.org/ns/dcr.rdf#" 11 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 12 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 13 xmlns:cmd="http://www.clarin.eu/cmd/" 14 xmlns:cmdm="http://www.clarin.eu/cmd/general.rdf" 15 xmlns:dcterms="http://purl.org/dc/terms/" 16 > 17 8 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:dcr="http://www.isocat.org/ns/dcr.rdf#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:cmd="http://www.clarin.eu/cmd/" xmlns:cmdm="http://www.clarin.eu/cmd/general.rdf" xmlns:dcterms="http://purl.org/dc/terms/"> 9 18 10 <xsl:output method="xml" encoding="UTF-8"/> 19 20 <xsl:param name=" base" select="base-uri()"/>21 11 12 <xsl:param name="out" select="'.'"/> 13 22 14 <xsl:include href="CMD2RDF.xsl"/> 23 15 24 16 <!-- let's create some RDF --> 25 <xsl:template match="/ ">17 <xsl:template match="/CMD_ComponentSpec"> 26 18 <!-- for the output base replace the xml extension by rdf --> 27 <rdf:RDF xml:base="{replace($base,'xml$','')}rdf#"> 28 <xsl:apply-templates> 29 <xsl:with-param name="context" tunnel="yes" select="''"/> 30 </xsl:apply-templates> 31 </rdf:RDF> 32 </xsl:template> 33 19 <xsl:result-document href="{concat($out,'/',Header/ID,'.rdf')}"> 20 <rdf:RDF xml:base="{if (@isProfile='true') then (cmd:ppath(Header/ID,'rdf')) else (cmd:cpath(Header/ID,'rdf'))}#"> 21 <xsl:apply-templates> 22 <xsl:with-param name="context" tunnel="yes" select="''"/> 23 </xsl:apply-templates> 24 </rdf:RDF> 25 </xsl:result-document> 26 </xsl:template> 27 34 28 <!-- override default text template --> 35 29 <xsl:template match="text()"/> 36 30 37 31 <!-- some attributes appear everywhere --> 38 32 <xsl:template name="generic"> … … 48 42 </xsl:if> 49 43 </xsl:template> 50 44 51 45 <!-- a profile (and component?) contains all the nested components as well, 52 46 but as these are shared we want to also share their RDF representations. 53 So cut off the traversal when there is reuse. --> 54 <xsl:template match="CMD_Component[exists(@ComponentId)]"/> 55 56 <!-- component belonging only to the root profile/component --> 57 <xsl:template match="CMD_Component[empty(@ComponentId)]"> 47 So restart the traversal when there is reuse. --> 48 <xsl:template match="CMD_Component[exists(@ComponentId)]"> 49 <xsl:if test="empty(preceding::CMD_Component[@ComponentId=current()/@ComponentId])"> 50 <xsl:result-document href="{concat($out,'/',@ComponentId,'.rdf')}"> 51 <!-- for the output base replace the xml extension by rdf --> 52 <rdf:RDF xml:base="{cmd:cpath(@ComponentId,'rdf')}#"> 53 <xsl:call-template name="CMD_Component"> 54 <xsl:with-param name="context" tunnel="yes" select="''"/> 55 </xsl:call-template> 56 </rdf:RDF> 57 </xsl:result-document> 58 </xsl:if> 59 </xsl:template> 60 61 <xsl:template name="CMD_Component"> 58 62 <xsl:param name="context" tunnel="yes"/> 59 63 <!-- extend the context path with this component --> … … 62 66 <rdfs:Class rdf:about="{$id}"> 63 67 <xsl:choose> 64 <xsl:when test=" ../CMD_ComponentSpec/@isProfile='true'">68 <xsl:when test="parent::CMD_ComponentSpec/@isProfile='true'"> 65 69 <rdfs:subClassOf rdf:resource="&cmdm;Profile"/> 66 70 </xsl:when> … … 74 78 </dcterms:identifier> 75 79 </xsl:if> 80 <xsl:if test="exists(@ComponentId)"> 81 <dcterms:identifier> 82 <xsl:value-of select="@ComponentId"/> 83 </dcterms:identifier> 84 </xsl:if> 76 85 <xsl:call-template name="generic"/> 77 86 </rdfs:Class> … … 81 90 </xsl:apply-templates> 82 91 </xsl:template> 83 92 93 <!-- component belonging only to the root profile/component --> 94 <xsl:template match="CMD_Component[empty(@ComponentId)]"> 95 <xsl:param name="context" tunnel="yes"/> 96 <xsl:call-template name="CMD_Component"> 97 <xsl:with-param name="context" tunnel="yes" select="$context"/> 98 </xsl:call-template> 99 </xsl:template> 100 84 101 <!-- a CMD element --> 85 102 <xsl:template match="CMD_Element"> … … 131 148 </xsl:apply-templates> 132 149 </xsl:template> 133 150 134 151 <!-- a CDM value --> 135 152 <xsl:template match="item"> … … 148 165 </rdf:Class> 149 166 </xsl:template> 150 167 151 168 <!-- a CMD attribute --> 152 169 <xsl:template match="Attribute"> … … 163 180 <rdf:Property rdf:about="{$has}Value"> 164 181 <rdfs:subPropertyOf rdf:resource="&cmdm;hasAttributeValue"/> 165 <!-- the domain is the CMD element RDF class --> 182 <!-- the domain is the CMD element RDF class --> 166 183 <rdfs:domain rdf:resource="{$id}"/> 167 184 <xsl:choose> … … 187 204 <rdf:Property rdf:about="{$has}Entity"> 188 205 <rdfs:subPropertyOf rdf:resource="&cmdm;hasAttributeEntity"/> 189 <!-- the domain is the CMD element RDF class --> 206 <!-- the domain is the CMD element RDF class --> 190 207 <rdfs:domain rdf:resource="{id}"/> 191 208 <!-- the range consists of a superclass for the specific value classes -->
Note: See TracChangeset
for help on using the changeset viewer.