]> Lady’s Gitweb - Caudex/blob - parser.xslt
d20da125c5f23fde826be1ba0874dcc98b8f6d43
[Caudex] / parser.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2025 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
5 -->
6 <!--
7 ⁌ 🪾📰 Caudex ∷ parser.xslt
8
9 © 2025 Lady [@ Ladys Computer].
10
11 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
12 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/>.
13 -->
14 <!DOCTYPE transform [
15 <!ENTITY xhtml 'http://www.w3.org/1999/xhtml'>
16 <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>
17 ]>
18 <transform
19 xmlns="http://www.w3.org/1999/XSL/Transform"
20 xmlns:awol="http://bblfish.net/work/atom-owl/2006-06-06/#"
21 xmlns:dcterms="http://purl.org/dc/terms/"
22 xmlns:exslstr="http://exslt.org/strings"
23 xmlns:foaf="http://xmlns.com/foaf/0.1/"
24 xmlns:html="&xhtml;"
25 xmlns:ore="http://www.openarchives.org/ore/terms/"
26 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
27 xmlns:skos="http://www.w3.org/2004/02/skos/core#"
28 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
29 extension-element-prefixes="exslstr"
30 version="1.0"
31 >
32 <书社:id>urn:fdc:ladys.computer:20240204:Caudex:parser.xslt</书社:id>
33 <template match="html:div[html:article/@data-lesml-profile='urn:fdc:ladys.computer:20240204:Caudex:pf:codex']">
34 <for-each select="html:article">
35 <variable name="title" select="html:footer[@class='head']//html:dt[normalize-space()='TITLE']/following-sibling::html:dd"/>
36 <element name="ore:Aggregation">
37 <apply-templates select="@lang|@xml:lang"/>
38 <attribute name="rdf:nodeID">
39 <text>codex</text>
40 </attribute>
41 <if test="$title">
42 <attribute name="dcterms:title">
43 <value-of select="$title"/>
44 </attribute>
45 </if>
46 </element>
47 </for-each>
48 </template>
49 <template match="html:div[html:article/@data-lesml-profile='urn:fdc:ladys.computer:20240204:Caudex:pf:category']">
50 <variable name="identifier" select="exslstr:tokenize($IDENTIFIER, '/')[last()-1]"/>
51 <for-each select="html:article">
52 <variable name="title" select="html:footer[@class='head']//html:dt[normalize-space()='TITLE']/following-sibling::html:dd"/>
53 <element name="awol:Category">
54 <apply-templates select="@lang|@xml:lang"/>
55 <attribute name="rdf:nodeID">
56 <value-of select="$identifier"/>
57 </attribute>
58 <attribute name="awol:term">
59 <choose>
60 <when test="$title">
61 <value-of select="$title"/>
62 </when>
63 <otherwise>
64 <value-of select="$identifier"/>
65 </otherwise>
66 </choose>
67 </attribute>
68 <if test="$title">
69 <attribute name="dcterms:title">
70 <value-of select="$title"/>
71 </attribute>
72 </if>
73 </element>
74 </for-each>
75 </template>
76 <template match="html:div[html:article/@data-lesml-profile='urn:fdc:ladys.computer:20240204:Caudex:pf:entry']">
77 <for-each select="html:article">
78 <variable name="title" select="html:footer[@class='head']//html:dt[normalize-space()='TITLE']/following-sibling::html:dd"/>
79 <variable name="idstring" select="string(exslstr:tokenize($IDENTIFIER, '/')[last()])"/>
80 <element name="ore:Proxy">
81 <if test="$title">
82 <attribute name="dcterms:title">
83 <value-of select="$title"/>
84 </attribute>
85 </if>
86 <element name="awol:category">
87 <attribute name="rdf:nodeID">
88 <value-of select="exslstr:tokenize($IDENTIFIER, '/')[last()-1]"/>
89 </attribute>
90 </element>
91 <element name="skos:notation">
92 <attribute name="rdf:datatype">
93 <text>&xsd;string</text>
94 </attribute>
95 <choose>
96 <when test="contains($idstring, ',')">
97 <value-of select="substring-before($idstring, ',')"/>
98 </when>
99 <otherwise>
100 <value-of select="$idstring"/>
101 </otherwise>
102 </choose>
103 </element>
104 <element name="ore:proxyIn">
105 <attribute name="rdf:nodeID">
106 <text>codex</text>
107 </attribute>
108 </element>
109 <element name="ore:proxyFor">
110 <element name="foaf:Document">
111 <apply-templates select="@lang|@xml:lang"/>
112 <element name="awol:content">
113 <attribute name="rdf:parseType">
114 <text>Resource</text>
115 </attribute>
116 <element name="awol:body">
117 <attribute name="rdf:parseType">
118 <text>Literal</text>
119 </attribute>
120 <apply-templates select="node()[not(self::html:footer[@class='head'])]"/>
121 </element>
122 <element name="awol:mediaType">
123 <attribute name="rdf:datatype">
124 <text>&xsd;string</text>
125 </attribute>
126 <text>application/xml+xhtml</text>
127 </element>
128 </element>
129 </element>
130 </element>
131 </element>
132 </for-each>
133 </template>
134 </transform>
This page took 0.050844 seconds and 3 git commands to generate.