Changeset 3798 for CMDI-Interoperability
- Timestamp:
- 10/18/13 11:27:01 (11 years ago)
- Location:
- CMDI-Interoperability/CMD2RDF/trunk/xsl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
CMDI-Interoperability/CMD2RDF/trunk/xsl/CMDRecord2RDF.xsl
r3792 r3798 4 4 <!ENTITY rdfs 'http://www.w3.org/TR/WD-rdf-schema#'> 5 5 <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'> 6 <!ENTITY cmdm 'http://www.clarin.eu/cmd/general.ttl#'> 6 7 ]> 7 8 <xsl:stylesheet … … 11 12 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 12 13 xmlns:cmd="http://www.clarin.eu/cmd/" 13 xmlns: rel="http://www.isocat.org/relcat/relations#"14 xmlns:cmdm="http://www.clarin.eu/cmd/general.ttl" 14 15 > 15 16 … … 106 107 <xsl:otherwise> 107 108 <!-- use the generic RELcat related relationship for the nesting of components --> 108 < rel:related>109 <cmdm:contains> 109 110 <xsl:copy-of select="$class"/> 110 </ rel:related>111 </cmdm:contains> 111 112 </xsl:otherwise> 112 113 </xsl:choose> … … 123 124 <!-- extend the context with this element --> 124 125 <xsl:variable name="id" select="cmd:path($context,$name)"/> 126 <xsl:variable name="has" select="cmd:path($context,concat('has',@name))"/> 125 127 <!-- find the matching instances --> 126 128 <xsl:for-each select="$instance/*[local-name()=$name]"> 127 129 <!-- use the generic RELcat related relationship for the nesting of the element in its component --> 128 < rel:related>130 <cmdm:contains> 129 131 <!-- a CMD element is a RDF class --> 130 132 <xsl:element name="{$id}" namespace="{$ns}"> 131 133 <xsl:attribute name="rdf:about" select="concat('#',generate-id(.))"/> 132 134 <!-- the value is assigned to a propery of the CMD element RDF class --> 133 <xsl:element name="{$id}Value" namespace="{$ns}"> 134 <xsl:choose> 135 <!-- the value comes from an enumeration and has its own URI --> 136 <xsl:when test="exists($profile/ValueScheme/enumeration)"> 137 <xsl:attribute name="rdf:resource" select="concat($ns,$id,'ValueScheme',$STEP,replace(.,'\s',''))"/> 138 </xsl:when> 139 <!-- the value is a literal --> 140 <xsl:otherwise> 141 <!-- map the CMD XSD datatype to a datatype supported by RDF --> 142 <xsl:attribute name="rdf:datatype" select="concat('&xsd;',cmd:datatype($profile/@ValueScheme))"/> 143 <!-- copy @xml:lang --> 144 <xsl:copy-of select="@xml:lang"/> 145 <!-- copy the literal --> 146 <xsl:value-of select="."/> 147 </xsl:otherwise> 148 </xsl:choose> 135 <xsl:element name="{$has}ElementValue" namespace="{$ns}"> 136 <!-- map the CMD XSD datatype to a datatype supported by RDF --> 137 <xsl:attribute name="rdf:datatype" select="concat('&xsd;',cmd:datatype($profile/@ValueScheme))"/> 138 <!-- copy @xml:lang --> 139 <xsl:copy-of select="@xml:lang"/> 140 <!-- copy the literal --> 141 <xsl:value-of select="."/> 149 142 </xsl:element> 143 <!-- if there is enum we also have an entity property --> 144 <xsl:if test="exists($profile/ValueScheme/enumeration)"> 145 <xsl:element name="{$id}ElementEntity" namespace="{$ns}"> 146 <xsl:attribute name="rdf:resource" select="concat($ns,$id,'ValueScheme',$STEP,replace(.,'\s',''))"/> 147 </xsl:element> 148 </xsl:if> 150 149 <!-- switch back from the instance to the profile to handle the attributes --> 151 150 <xsl:apply-templates select="$profile/AttributeList/Attribute"> … … 155 154 </xsl:apply-templates> 156 155 </xsl:element> 157 </ rel:related>156 </cmdm:contains> 158 157 </xsl:for-each> 159 158 </xsl:template> … … 168 167 <!-- extend the context with this attribute --> 169 168 <xsl:variable name="id" select="concat(cmd:path($context,$name),'Attribute')"/> 169 <xsl:variable name="has" select="concat(cmd:path($context,concat('has',$name)),'Attribute')"/> 170 170 <!-- find the matching instances --> 171 171 <xsl:for-each select="$instance/@*[local-name()=$name]"> 172 <xsl:element name="{$id}" namespace="{$ns}"> 173 <xsl:choose> 174 <!-- the value comes from an enumeration and has its own URI --> 175 <xsl:when test="exists($profile/ValueScheme/enumeration)"> 176 <xsl:attribute name="rdf:resource" select="concat($ns,$id,'ValueScheme',$STEP,replace(.,'\s',''))"/> 177 </xsl:when> 178 <!-- the value is a literal --> 179 <xsl:otherwise> 180 <!-- map the CMD XSD datatype to a datatype supported by RDF --> 181 <xsl:attribute name="rdf:datatype" select="concat('&xsd;',cmd:datatype($profile/Type))"/> 182 <!-- copy the literal --> 183 <xsl:value-of select="."/> 184 </xsl:otherwise> 185 </xsl:choose> 172 <xsl:element name="{$has}" namespace="{$ns}"> 173 <!-- map the CMD XSD datatype to a datatype supported by RDF --> 174 <xsl:attribute name="rdf:datatype" select="concat('&xsd;',cmd:datatype($profile/Type))"/> 175 <!-- copy the literal --> 176 <xsl:value-of select="."/> 186 177 </xsl:element> 178 <xsl:if test="exists($profile/ValueScheme/enumeration)"> 179 <xsl:element name="{$has}Entity" namespace="{$ns}"> 180 <xsl:attribute name="rdf:resource" select="concat($ns,$id,'ValueScheme',$STEP,replace(.,'\s',''))"/> 181 </xsl:element> 182 </xsl:if> 187 183 </xsl:for-each> 188 184 </xsl:template> -
CMDI-Interoperability/CMD2RDF/trunk/xsl/Component2RDF.xsl
r3792 r3798 4 4 <!ENTITY rdfs 'http://www.w3.org/TR/WD-rdf-schema#'> 5 5 <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'> 6 <!ENTITY cmdm 'http://www.clarin.eu/cmd/general.ttl#'> 6 7 ]> 7 8 <xsl:stylesheet … … 11 12 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 12 13 xmlns:cmd="http://www.clarin.eu/cmd/" 14 xmlns:cmdm="http://www.clarin.eu/cmd/general.ttl" 13 15 > 14 16 … … 58 60 <!-- a component maps to an RDF class --> 59 61 <rdfs:Class rdf:about="{$id}"> 62 <xsl:choose> 63 <xsl:when test="../CMD_ComponentSpec/@isProfile='true'"> 64 <rdfs:subClassOf rdf:resource="&cmdm;Profile"/> 65 </xsl:when> 66 <xsl:otherwise> 67 <rdfs:subClassOf rdf:resource="&cmdm;Component"/> 68 </xsl:otherwise> 69 </xsl:choose> 60 70 <xsl:call-template name="generic"/> 61 71 </rdfs:Class> … … 71 81 <!-- extend the context with this element --> 72 82 <xsl:variable name="id" select="cmd:path($context,@name)"/> 83 <xsl:variable name="has" select="cmd:path($context,concat('has',@name))"/> 73 84 <!-- element becomes a class to be able to group attributes and value together --> 74 85 <rdfs:Class rdf:about="{$id}"> 86 <rdfs:subClassOf rdf:resource="&cmdm;Element"/> 75 87 <xsl:call-template name="generic"/> 76 88 </rdfs:Class> 77 89 <!-- the value property --> 78 <rdf:Property rdf:about="{$ id}Value">79 < xsl:call-template name="generic"/>90 <rdf:Property rdf:about="{$has}ElementValue"> 91 <rdfs:subPropertyOf rdf:resource="&cmdm;hasElementValue"/> 80 92 <!-- the domain of the value property is the class corresponding to the CMD element --> 81 93 <rdfs:domain rdf:resource="{$id}"/> 82 94 <xsl:choose> 83 <!-- if the value scheme is an enumeration the range consists of a superclass for the specific value classes -->95 <!-- if the value scheme is an enumeration the range consists of the labels of the values --> 84 96 <xsl:when test="exists(ValueScheme/enumeration)"> 85 <rdfs:range rdf:resource=" {concat($id,'ValueScheme')}"/>97 <rdfs:range rdf:resource="&xsd;string"/> 86 98 </xsl:when> 87 99 <!-- if the value scheme is an XSD datatype the range becomes the equivalent RDF XSD datatype --> … … 95 107 </xsl:choose> 96 108 </rdf:Property> 109 <!-- if there is an value enumeration also have a hasElementEntity property --> 110 <if test="exists(ValueScheme/enumeration)"> 111 <rdf:Property rdf:about="{$has}ElementEntity"> 112 <rdfs:subPropertyOf rdf:resource="&cmdm;hasElementEntity"/> 113 <!-- the domain of the value property is the class corresponding to the CMD element --> 114 <rdfs:domain rdf:resource="{$id}"/> 115 <!-- the range consists of a superclass for the specific value classes --> 116 <rdfs:range rdf:resource="{$id}Value"/> 117 </rdf:Property> 118 </if> 97 119 <!-- continue with the attributes and values --> 98 120 <xsl:apply-templates> … … 109 131 <xsl:variable name="id" select="replace($label,'\s','')"/> 110 132 <!-- a value in a value scheme becomes a subclass of that scheme --> 111 <rdf:Class rdf:about="{ concat($context,'ValueScheme',$STEP,$id)}">112 <rdf:subClassOf rdf:resource="{ concat($context,'ValueScheme')}"/>133 <rdf:Class rdf:about="{$context}Value{$STEP}{$id}"> 134 <rdf:subClassOf rdf:resource="{$context}Value"/> 113 135 <xsl:call-template name="generic"/> 114 136 <rdfs:label> … … 123 145 <!-- extend the context with this attribute --> 124 146 <xsl:variable name="id" select="concat(cmd:path($context,Name),'Attribute')"/> 147 <xsl:variable name="has" select="concat(cmd:path($context,concat('has',Name)),'Attribute')"/> 125 148 <!-- an attribute becomes a property --> 126 <rdf:Property rdf:about="{$id}"> 149 <rdf:Property rdf:about="{$has}"> 150 <rdfs:subPropertyOf rdf:resource="&cmdm;hasAttributeValue"/> 127 151 <xsl:call-template name="generic"/> 128 <!-- the domain is CMD element RDF class -->152 <!-- the domain is the CMD element RDF class --> 129 153 <rdfs:domain rdf:resource="{$context}"/> 130 154 <xsl:choose> 131 <!-- if the value scheme is an enumeration the range consists of a superclass for the specific value classes -->155 <!-- if the value scheme is an enumeration the range is the labels --> 132 156 <xsl:when test="exists(ValueScheme/enumeration)"> 133 <rdfs:range rdf:resource=" {concat($id,'ValueScheme')}"/>157 <rdfs:range rdf:resource="&xsd;string"/> 134 158 </xsl:when> 135 159 <!-- if the value scheme is an XSD datatype the range becomes the equivalent RDF XSD datatype --> … … 143 167 </xsl:choose> 144 168 </rdf:Property> 169 <!-- if there is an value enumeration also have a hasAttributeEntity property --> 170 <xsl:if test="exists(ValueScheme/enumeration)"> 171 <rdf:Property rdf:about="{$has}Entity"> 172 <rdfs:subPropertyOf rdf:resource="&cmdm;hasAttributeEntity"/> 173 <!-- the domain is the CMD element RDF class --> 174 <rdfs:domain rdf:resource="{$context}"/> 175 <!-- the range consists of a superclass for the specific value classes --> 176 <rdfs:range rdf:resource="{$id}Value"/> 177 </rdf:Property> 178 </xsl:if> 145 179 <!-- continue with the values --> 146 180 <xsl:apply-templates>
Note: See TracChangeset
for help on using the changeset viewer.