+++ /dev/null
-<?xml version="1.0"?>
-<!--
-SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
-SPDX-License-Identifier: MPL-2.0
--->
-<!--
-© 2024 Lady [@ Ladys Computer].
-
-This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
-If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
--->
-<transform
- xmlns="http://www.w3.org/1999/XSL/Transform"
- xmlns:Vocab="urn:fdc:vocab.ladys.computer:20240731:ns"
- xmlns:Vocabvocab="urn:fdc:vocab.ladys.computer:20240731:vocab:"
- xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:owl="http://www.w3.org/2002/07/owl#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:shacl="http://www.w3.org/ns/shacl#"
- xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
- exclude-result-prefixes="Vocab Vocabvocab"
- version="1.0"
->
- <书社:id>urn:fdc:vocab.ladys.computer:20240731:transforms:data:rdf.xslt</书社:id>
- <key name="Vocab:name" match="owl:AnnotationProperty|owl:Class|owl:DatatypeProperty|owl:NamedIndividual|owl:ObjectProperty|rdfs:Datatype" use="@rdf:about|owl:sameAs/@rdf:resource"/>
- <template name="Vocab:base">
- <value-of select="//rdf:RDF//owl:Ontology/shacl:declare/shacl:namespace[preceding-sibling::shacl:prefix='']"/>
- </template>
- <template name="Vocab:prefix">
- <param name="unprefixed" select="''"/>
- <variable name="namespace" select="//rdf:RDF//owl:Ontology/shacl:declare/shacl:namespace[starts-with($unprefixed, string()) and string(preceding-sibling::shacl:prefix)!=''][1]"/>
- <choose>
- <when test="not($namespace)">
- <value-of select="$unprefixed"/>
- </when>
- <otherwise>
- <value-of select="$namespace/preceding-sibling::shacl:prefix"/>
- <text>:</text>
- <value-of select="substring-after($unprefixed, $namespace)"/>
- </otherwise>
- </choose>
- </template>
- <template match="rdf:RDF/*[@rdf:about and Vocabvocab:superClassOf]" priority="2">
- <copy>
- <apply-templates select="@*|node()[not(self::Vocabvocab:superClassOf)]"/>
- </copy>
- <for-each select="Vocabvocab:superClassOf/*[1]">
- <copy>
- <apply-templates select="@*|node()"/>
- <element name="rdfs:subClassOf">
- <attribute name="rdf:resource">
- <value-of select="../../@rdf:about"/>
- </attribute>
- </element>
- </copy>
- </for-each>
- </template>
- <template match="@rdf:resource" priority="2">
- <variable name="base-iri">
- <call-template name="Vocab:base"/>
- </variable>
- <attribute name="rdf:resource">
- <choose>
- <when test="starts-with(., 'about:vocab?') and contains(., '=')">
- <variable name="query" select="substring-after(., 'about:vocab?')"/>
- <variable name="qterm" select="substring-before($query, '=')"/>
- <variable name="subdir">
- <choose>
- <when test="$qterm='class'">
- <text>classes/</text>
- </when>
- <when test="$qterm='property'">
- <text>properties/</text>
- </when>
- <otherwise>
- <text>individuals/</text>
- </otherwise>
- </choose>
- </variable>
- <variable name="match" select="//*[rdfs:isDefinedBy[starts-with(@rdf:resource, $base-iri) and substring-after(@rdf:resource, $base-iri)=concat($subdir, substring-after($query, '='), '.xhtml')]]"/>
- <choose>
- <when test="$match">
- <value-of select="$match/@rdf:about"/>
- </when>
- <otherwise>
- <value-of select="."/>
- </otherwise>
- </choose>
- </when>
- <otherwise>
- <value-of select="."/>
- </otherwise>
- </choose>
- </attribute>
- </template>
- <template match="html:a" priority="1">
- <variable name="base-prefix">
- <call-template name="Vocab:prefix">
- <with-param name="unprefixed">
- <call-template name="Vocab:base"/>
- </with-param>
- </call-template>
- </variable>
- <variable name="kind" select="@data-kind"/>
- <variable name="linked-resource" select="key('Vocab:name', @href)[not($kind) or $kind='class' and (self::owl:Class or self::owl:Datatype) or $kind='property' and (self::owl:AnnotationProperty or self::owl:ObjectProperty or self::owl:DatatypeProperty) or $kind='individual' and self::owl:NamedIndividual][1]"/>
- <copy>
- <apply-templates select="@*[not(contains(' data-curie data-kind ', local-name()) and namespace-uri()='')]"/>
- <choose>
- <when test="$linked-resource">
- <variable name="curie">
- <call-template name="Vocab:prefix">
- <with-param name="unprefixed" select="string(@href)"/>
- </call-template>
- </variable>
- <variable name="localid">
- <choose>
- <when test="starts-with($curie, $base-prefix)">
- <value-of select="substring-after($curie, $base-prefix)"/>
- </when>
- <otherwise>
- <value-of select="$curie"/>
- </otherwise>
- </choose>
- </variable>
- <attribute name="data-curie">
- <value-of select="$curie"/>
- </attribute>
- <attribute name="data-kind">
- <choose>
- <when test="@data-kind">
- <value-of select="@data-kind"/>
- </when>
- <when test="$linked-resource[self::owl:Class or self::owl:Datatype]">
- <text>class</text>
- </when>
- <when test="$linked-resource[self::owl:AnnotationProperty or self::owl:ObjectProperty or self::owl:DatatypeProperty]">
- <text>property</text>
- </when>
- <otherwise>
- <text>individual</text>
- </otherwise>
- </choose>
- </attribute>
- <choose>
- <when test="html:code[not(preceding-sibling::node() or following-sibling::node())]">
- <for-each select="$linked-resource">
- <variable name="wrappername">
- <choose>
- <when test="substring($localid, 1, 1)='(' and substring($localid, string-length($localid), 1)=')'">
- <text>cite</text>
- </when>
- <otherwise>
- <text>span</text>
- </otherwise>
- </choose>
- </variable>
- <attribute name="title">
- <value-of select="rdfs:label[1]"/>
- <text> (</text>
- <value-of select="$curie"/>
- <text>)</text>
- </attribute>
- <element name="html:{$wrappername}">
- <attribute name="lang">
- <value-of select="rdfs:label[1]/@xml:lang"/>
- </attribute>
- <attribute name="xml:lang">
- <value-of select="rdfs:label[1]/@xml:lang"/>
- </attribute>
- <value-of select="rdfs:label[1]"/>
- </element>
- </for-each>
- </when>
- <otherwise>
- <apply-templates/>
- </otherwise>
- </choose>
- </when>
- <otherwise>
- <apply-templates/>
- </otherwise>
- </choose>
- </copy>
- </template>
- <template match="html:a/@href[starts-with(., '#footnote-')]">
- <attribute name="href">
- <text>#footnote-</text>
- <value-of select="generate-id(ancestor::rdfs:comment//@id[string()=substring-after(current(), '#')])"/>
- </attribute>
- </template>
- <template match="html:*/@id[starts-with(., 'footnote-')]" priority="1">
- <attribute name="id">
- <text>footnote-</text>
- <value-of select="generate-id()"/>
- </attribute>
- </template>
-</transform>