3 SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 © 2024 Lady [@ Ladys Computer].
9 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
10 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/>.
14 xmlns="http://www.w3.org/1999/XSL/Transform"
15 xmlns:Vocab="urn:fdc:vocab.ladys.computer:20240731:ns"
16 xmlns:Vocabvocab="urn:fdc:vocab.ladys.computer:20240731:vocab:"
17 xmlns:exsl="http://exslt.org/common"
18 xmlns:exslfunc="http://exslt.org/functions"
19 xmlns:owl="http://www.w3.org/2002/07/owl#"
20 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
21 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
22 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
23 exclude-result-prefixes="Vocab Vocabvocab"
24 extension-element-prefixes="exsl exslfunc"
27 <书社:id>urn:fdc:vocab.ladys.computer:20240731:transforms:site:infer.xslt</书社:id>
28 <key name="Vocab:equivalent-class" match="owl:Class|owl:Restriction|rdfs:Datatype" use="owl:equivalentClass/@rdf:resource"/>
29 <key name="Vocab:equivalent-property" match="owl:AnnotationProperty|owl:DatatypeProperty|owl:ObjectProperty" use="owl:equivalentProperty/@rdf:resource"/>
30 <key name="Vocab:equivalent-individual" match="owl:NamedIndividual" use="owl:sameAs/@rdf:resource"/>
31 <key name="Vocab:inverse-class" match="owl:Class|rdfs:Datatype" use="owl:complementOf/@rdf:resource"/>
32 <key name="Vocab:inverse-property" match="owl:DatatypeProperty|owl:ObjectProperty" use="owl:inverseOf/@rdf:resource"/>
33 <key name="Vocab:disjoint-class" match="owl:Class|rdfs:Datatype" use="owl:disjointWith/@rdf:resource"/>
34 <key name="Vocab:disjoint-property" match="owl:DatatypeProperty|owl:ObjectProperty" use="owl:propertyDisjointWith/@rdf:resource"/>
35 <exslfunc:function name="Vocab:get-equivalents">
36 <param name="resource-nodes"/>
37 <param name="kind" select="'individual'"/>
38 <param name="include-self" select="false()"/>
39 <param name="exclude" select="/.."/>
40 <variable name="result-fragment">
41 <call-template name="Vocab:get-fragment-of-equivalents">
42 <with-param name="kind" select="$kind"/>
43 <with-param name="resource-nodes" select="$resource-nodes"/>
44 <with-param name="include-self" select="$include-self"/>
45 <with-param name="exclude" select="$exclude"/>
48 <exslfunc:result select="exsl:node-set($result-fragment)/*"/>
50 <exslfunc:function name="Vocab:get-transitives">
51 <param name="resource-nodes"/>
52 <param name="kind" select="'individual'"/>
53 <param name="relationship"/>
54 <param name="include-self" select="false()"/>
55 <param name="exclude" select="/.."/>
56 <variable name="result-fragment">
57 <call-template name="Vocab:get-fragment-of-transitives">
58 <with-param name="kind" select="$kind"/>
59 <with-param name="relationship" select="$relationship"/>
60 <with-param name="resource-nodes" select="$resource-nodes"/>
61 <with-param name="include-self" select="$include-self"/>
62 <with-param name="exclude" select="$exclude"/>
65 <exslfunc:result select="exsl:node-set($result-fragment)/*"/>
67 <exslfunc:function name="Vocab:get-symmetrics">
68 <param name="resource-nodes"/>
70 <param name="relationship"/>
71 <param name="include-self" select="false()"/>
72 <param name="exclude" select="/.."/>
73 <variable name="root" select="/"/>
74 <variable name="relationship-names" select="Vocab:relationship-names($kind, $relationship)"/>
75 <variable name="result-fragment">
76 <if test="string($relationship-names/Vocab:local-name)!=''">
77 <variable name="relationship-key">
79 <value-of select="$relationship"/>
81 <value-of select="$kind"/>
83 <variable name="equivalents" select="Vocab:get-equivalents($resource-nodes, $kind, true(), $exclude)"/>
84 <variable name="unfiltered-result-fragment">
85 <if test="$include-self">
86 <copy-of select="$equivalents"/>
88 <for-each select="$equivalents/@rdf:about">
89 <variable name="source" select="string()"/>
90 <for-each select="$root">
91 <for-each select="key(concat('Vocab:named-', $kind), $source)">
92 <apply-templates select="*[local-name()=$relationship-names/Vocab:local-name and namespace-uri()=$relationship-names/Vocab:namespace]" mode="Vocab:format-get">
93 <with-param name="source" select="$source"/>
96 <for-each select="key($relationship-key, $source)">
97 <apply-templates select="." mode="Vocab:format-get">
98 <with-param name="source" select="string(@rdf:about)"/>
104 <for-each select="exsl:node-set($unfiltered-result-fragment)/*">
105 <copy-of select="self::*[not(@rdf:about and ($exclude|preceding-sibling::*)/@rdf:about[string()=string(current()/@rdf:about)])]"/>
109 <exslfunc:result select="exsl:node-set($result-fragment)/*"/>
111 <exslfunc:function name="Vocab:relationship-names">
113 <param name="relationship"/>
114 <variable name="result-fragment">
115 <element name="Vocab:local-name">
117 <when test="$relationship='equivalent' and $kind='class'">
118 <text>equivalentClass</text>
120 <when test="$relationship='equivalent' and $kind='property'">
121 <text>equivalentProperty</text>
123 <when test="$relationship='equivalent' and $kind='individual'">
126 <when test="$relationship='super' and $kind='class'">
127 <text>subClassOf</text>
129 <when test="$relationship='super' and $kind='property'">
130 <text>subPropertyOf</text>
132 <when test="$relationship='inverse' and $kind='class'">
133 <text>complementOf</text>
135 <when test="$relationship='inverse' and $kind='property'">
136 <text>inverseOf</text>
138 <when test="$relationship='disjoint' and $kind='class'">
139 <text>disjointWith</text>
141 <when test="$relationship='disjoint' and $kind='property'">
142 <text>propertyDisjointWith</text>
146 <element name="Vocab:namespace">
148 <when test="$relationship='super'">
149 <text>http://www.w3.org/2000/01/rdf-schema#</text>
152 <text>http://www.w3.org/2002/07/owl#</text>
157 <exslfunc:result select="exsl:node-set($result-fragment)"/>
159 <template name="Vocab:get-fragment-of-equivalents">
160 <param name="kind" select="'individual'"/>
161 <param name="resource-nodes" select="/.."/> <!-- not yet processed, but selected -->
162 <param name="include-self" select="true()"/> <!-- make false on first run to not include provided nodes -->
163 <param name="exclude" select="/.."/> <!-- leave named nodes out of result -->
164 <param name="gotten" select="/.."/> <!-- already processed -->
165 <variable name="root" select="/"/>
166 <variable name="relationship-names" select="Vocab:relationship-names($kind, 'equivalent')"/>
167 <variable name="gotten-nodes" select="exsl:node-set($gotten)/*"/>
168 <variable name="next"> <!-- new selection -->
169 <for-each select="$resource-nodes/@rdf:about">
170 <!-- Iterate over each named resource to get, find it, and get the equivalent resources. -->
171 <if test="not(($gotten-nodes|../preceding-sibling::*)/@rdf:about[string()=string(current())])">
172 <variable name="source" select="string()"/>
173 <for-each select="$root">
174 <for-each select="key(concat('Vocab:named-', $kind), $source)">
175 <apply-templates select="*[local-name()=$relationship-names/Vocab:local-name and namespace-uri()=$relationship-names/Vocab:namespace]" mode="Vocab:format-get">
176 <with-param name="source" select="$source"/>
179 <for-each select="key(concat('Vocab:equivalent-', $kind), $source)">
180 <apply-templates select="." mode="Vocab:format-get">
181 <with-param name="source" select="string(@rdf:about)"/>
188 <variable name="next-nodes" select="exsl:node-set($next)/*"/>
189 <if test="$include-self">
190 <for-each select="$resource-nodes">
191 <if test="not(@rdf:about and ($exclude|$gotten-nodes|preceding-sibling::*)/@rdf:about[string()=string(current()/@rdf:about)])">
192 <apply-templates select="." mode="Vocab:format-get"/>
196 <if test="$next-nodes">
197 <call-template name="Vocab:get-fragment-of-equivalents">
198 <with-param name="kind" select="$kind"/>
199 <with-param name="resource-nodes" select="$next-nodes"/>
200 <with-param name="exclude" select="$exclude"/>
201 <with-param name="gotten">
202 <copy-of select="$gotten-nodes"/>
203 <for-each select="$resource-nodes">
204 <if test="not(@rdf:about and ($gotten-nodes|preceding-sibling::*)/@rdf:about[string()=string(current()/@rdf:about)])">
205 <copy-of select="."/>
212 <template name="Vocab:get-fragment-of-transitives">
213 <param name="kind" select="'individual'"/>
214 <param name="relationship"/>
215 <param name="resource-nodes" select="/.."/> <!-- not yet processed, but selected -->
216 <param name="include-self" select="true()"/> <!-- make false on first run to not include provided nodes -->
217 <param name="exclude" select="/.."/> <!-- leave named nodes out of result -->
218 <param name="gotten" select="/.."/> <!-- already processed -->
219 <variable name="root" select="/"/>
220 <variable name="relationship-names" select="Vocab:relationship-names($kind, $relationship)"/>
221 <if test="string($relationship-names/Vocab:local-name)!=''">
222 <variable name="gotten-nodes" select="exsl:node-set($gotten)/*"/>
223 <variable name="equivalent-nodes" select="Vocab:get-equivalents($resource-nodes, $kind, true(), $gotten-nodes)"/> <!-- already deduped -->
224 <variable name="next"> <!-- new selection -->
225 <for-each select="$equivalent-nodes/@rdf:about">
226 <!-- Iterate over each named resource to get, find it, and get the related resources. -->
227 <variable name="source" select="string()"/>
228 <for-each select="$root">
229 <for-each select="key(concat('Vocab:named-', $kind), $source)">
230 <apply-templates select="*[local-name()=$relationship-names/Vocab:local-name and namespace-uri()=$relationship-names/Vocab:namespace]" mode="Vocab:format-get">
231 <with-param name="source" select="$source"/>
237 <variable name="next-nodes" select="exsl:node-set($next)/*"/>
238 <if test="$include-self">
239 <for-each select="$equivalent-nodes">
240 <if test="not(@rdf:about and $exclude/@rdf:about[string()=string(current()/@rdf:about)])">
241 <copy-of select="."/>
245 <if test="$next-nodes">
246 <call-template name="Vocab:get-fragment-of-transitives">
247 <with-param name="kind" select="$kind"/>
248 <with-param name="relationship" select="$relationship"/>
249 <with-param name="resource-nodes" select="$next-nodes"/>
250 <with-param name="exclude" select="$exclude"/>
251 <with-param name="gotten">
252 <copy-of select="$gotten-nodes"/>
253 <copy-of select="$equivalent-nodes"/>
259 <template match="*" mode="Vocab:format-get">
260 <param name="source"/>
262 <when test="Vocabvocab:inferred-from">
263 <copy-of select="."/>
265 <when test="@rdf:about|@rdf:resource">
266 <element name="rdf:Description">
267 <attribute name="rdf:about">
268 <value-of select="@rdf:about|@rdf:resource"/>
270 <if test="string($source)!=''">
271 <element name="Vocabvocab:inferred-from">
272 <attribute name="rdf:resource">
273 <value-of select="$source"/>
280 <for-each select="*">
282 <copy-of select="@*|node()"/>
283 <if test="string($source)!=''">
284 <element name="Vocabvocab:inferred-from">
285 <attribute name="rdf:resource">
286 <value-of select="$source"/>