]> Lady’s Gitweb - Caudex/blob - parser.xslt
Enable manual ordering
[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:ladys="https://vocab.ladys.computer/terms/"
26 xmlns:ore="http://www.openarchives.org/ore/terms/"
27 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
28 xmlns:skos="http://www.w3.org/2004/02/skos/core#"
29 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
30 extension-element-prefixes="exslstr"
31 version="1.0"
32 >
33 <书社:id>urn:fdc:ladys.computer:20240204:Caudex:parser.xslt</书社:id>
34 <template match="html:div[html:article/@data-lesml-profile='urn:fdc:ladys.computer:20240204:Caudex:pf:codex']">
35 <for-each select="html:article">
36 <variable name="title" select="html:footer[@class='head']//html:dt[normalize-space()='TITLE']/following-sibling::html:dd"/>
37 <element name="ore:Aggregation">
38 <apply-templates select="@lang|@xml:lang"/>
39 <attribute name="rdf:nodeID">
40 <text>codex</text>
41 </attribute>
42 <if test="$title">
43 <attribute name="dcterms:title">
44 <value-of select="$title"/>
45 </attribute>
46 </if>
47 </element>
48 </for-each>
49 </template>
50 <template match="html:div[html:article/@data-lesml-profile='urn:fdc:ladys.computer:20240204:Caudex:pf:category']">
51 <variable name="identifier" select="exslstr:tokenize($IDENTIFIER, '/')[last()-1]"/>
52 <for-each select="html:article">
53 <variable name="title" select="html:footer[@class='head']//html:dt[normalize-space()='TITLE']/following-sibling::html:dd"/>
54 <variable name="order" select="number(html:footer[@class='head']//html:dt[normalize-space()='ORDER']/following-sibling::html:dd)"/>
55 <element name="awol:Category">
56 <apply-templates select="@lang|@xml:lang"/>
57 <attribute name="rdf:nodeID">
58 <value-of select="$identifier"/>
59 </attribute>
60 <attribute name="awol:term">
61 <choose>
62 <when test="$title">
63 <value-of select="$title"/>
64 </when>
65 <otherwise>
66 <value-of select="$identifier"/>
67 </otherwise>
68 </choose>
69 </attribute>
70 <if test="$title">
71 <attribute name="dcterms:title">
72 <value-of select="$title"/>
73 </attribute>
74 </if>
75 <if test="$order!=number('NaN')">
76 <element name="ladys:order">
77 <attribute name="rdf:datatype">
78 <text>&xsd;integer</text>
79 </attribute>
80 <value-of select="$order"/>
81 </element>
82 </if>
83 </element>
84 </for-each>
85 </template>
86 <template match="html:div[html:article/@data-lesml-profile='urn:fdc:ladys.computer:20240204:Caudex:pf:entry']">
87 <for-each select="html:article">
88 <variable name="title" select="html:footer[@class='head']//html:dt[normalize-space()='TITLE']/following-sibling::html:dd"/>
89 <variable name="order" select="number(html:footer[@class='head']//html:dt[normalize-space()='ORDER']/following-sibling::html:dd)"/>
90 <variable name="idstring" select="string(exslstr:tokenize($IDENTIFIER, '/')[last()])"/>
91 <element name="ore:Proxy">
92 <if test="$title">
93 <attribute name="dcterms:title">
94 <value-of select="$title"/>
95 </attribute>
96 </if>
97 <element name="awol:category">
98 <attribute name="rdf:nodeID">
99 <value-of select="exslstr:tokenize($IDENTIFIER, '/')[last()-1]"/>
100 </attribute>
101 </element>
102 <if test="$order!=number('NaN')">
103 <element name="ladys:order">
104 <attribute name="rdf:datatype">
105 <text>&xsd;integer</text>
106 </attribute>
107 <value-of select="$order"/>
108 </element>
109 </if>
110 <element name="skos:notation">
111 <attribute name="rdf:datatype">
112 <text>&xsd;string</text>
113 </attribute>
114 <choose>
115 <when test="contains($idstring, ',')">
116 <value-of select="substring-before($idstring, ',')"/>
117 </when>
118 <otherwise>
119 <value-of select="$idstring"/>
120 </otherwise>
121 </choose>
122 </element>
123 <element name="ore:proxyIn">
124 <attribute name="rdf:nodeID">
125 <text>codex</text>
126 </attribute>
127 </element>
128 <element name="ore:proxyFor">
129 <element name="foaf:Document">
130 <apply-templates select="@lang|@xml:lang"/>
131 <element name="awol:content">
132 <attribute name="rdf:parseType">
133 <text>Resource</text>
134 </attribute>
135 <element name="awol:body">
136 <attribute name="rdf:parseType">
137 <text>Literal</text>
138 </attribute>
139 <apply-templates select="node()[not(self::html:footer[@class='head'])]"/>
140 </element>
141 <element name="awol:mediaType">
142 <attribute name="rdf:datatype">
143 <text>&xsd;string</text>
144 </attribute>
145 <text>application/xml+xhtml</text>
146 </element>
147 </element>
148 </element>
149 </element>
150 </element>
151 </for-each>
152 </template>
153 </transform>
This page took 0.058836 seconds and 5 git commands to generate.