]> Lady’s Gitweb - Shushe/commitdiff
Replace source catalog with metadata file
authorLady <redacted>
Wed, 22 May 2024 04:44:49 +0000 (00:44 -0400)
committerLady <redacted>
Thu, 11 Jul 2024 01:46:30 +0000 (21:46 -0400)
There are two things which this approach should eventally bring :—

1. Availability of various aspects of file metadata for every file
   during the parsing and transformation phases. Right now, only
   metadata for the file currently being processed is available, and
   while loading the catalog is possible in transforms, it’s probably
   not really advisable and hasn’t been extensively tested.

2. Cacheing of file metadata for files which have not changed since the
   last time Make was run. This comes with the usual Make drawback that
   if a file is changed to be older, rather than newer, it won’t be
   recognized as having been changed.

Neither of these things are really implemented at this point, but the
metadata file is created and being used and the old catalog has been
removed. Future commits should refine the behaviour.

GNUmakefile
README.markdown
lib/catalog2parser.xslt
lib/catalog2transform.xslt
lib/metadata2dependencies.xslt [moved from lib/catalog2dependencies.xslt with 75% similarity]
lib/metadata2destinations.xslt [moved from lib/catalog2destinations.xslt with 52% similarity]

index f5b738aa94f2faf62005e33b1ffa4f390f8f6acf..1cf21d27fa361240ba3dda1aa65771832a4a9bc0 100644 (file)
@@ -317,6 +317,12 @@ ifeq ($(MODE),urn:fdc:ladys.computer:20231231:Shu1She4:mode:default)
 # ☡ This variable creates at least one subshell every time it is computed.
 override diffprereqs = $(if $(subst $(shell $(CAT) $(call quote,$(BUILDDIR)/lastprereqs/$1) 2>>/dev/null || :),,$2),$2 FORCE$(and $(shell $(call ensuredirectory,$(BUILDDIR)/lastprereqs) && $(PRINTF) '%s\n' $(call quote,$2) >|$(BUILDDIR)/lastprereqs/$1),),$2)
 
+# (callable) Escape special characters for use in X·M·L.
+override xmlesc = $(subst >,&gt;,$(subst <,&lt;,$(subst &,&amp;,$1)))
+
+# (callable) Escape special characters for use in X·M·L attributes.
+override attresc = $(subst ",&quot;,$(call xmlesc,$1))
+
 # (callable) Escape special characters for use in sed regular expressions.
 override sedesc = $(subst /,[/],$(subst $$,\$$,$(subst *,\*,$(subst .,\.,$(subst [,\[,$(subst ^,\^,$(subst \,\\,$1)))))))
 
@@ -412,6 +418,15 @@ override sourcefile = $(foreach local,$1,$(patsubst %|$(local),%,$(filter %|$(lo
 # This ensures that file classifications are up·to·date immediately after the reload.
 override typeupdates := $(if $(wildcard $(BUILDDIR)/.update-types),FORCE,)
 
+# Pair each source file and include with its metadata location.
+override sourcemetadatapair := $(foreach file,$(sourcefiles) $(sourceincludes),$(file)|$(BUILDDIR)/$(if $(filter $(file),$(sourceincludes)),includes.metadata/$(call includepath,$(file)),sources.metadata/$(call sourcepath,$(file))))
+
+# (callable) Get the location of the transformed X·M·L files for the given source files.
+override metadata = $(foreach file,$1,$(patsubst $(file)|%,%,$(filter $(file)|%,$(sourcemetadatapair))))
+
+# (callable) Get the source files for the given parsed file.
+override datadata = $(foreach file,$1,$(patsubst %|$(file),%,$(filter %|$(file),$(sourcemetadatapair))))
+
 # Pair each source file and include with its parsed location.
 override sourceparsedpair := $(foreach file,$(sourcefiles) $(sourceincludes),$(file)|$(BUILDDIR)/$(if $(filter $(file),$(sourceincludes)),includes/$(call includepath,$(file)),sources/$(call sourcepath,$(file))))
 
@@ -421,8 +436,8 @@ override parsed = $(foreach file,$1,$(patsubst $(file)|%,%,$(filter $(file)|%,$(
 # (callable) Get the source files for the given parsed file.
 override unparsed = $(foreach file,$1,$(patsubst %|$(file),%,$(filter %|$(file),$(sourceparsedpair))))
 
-# Pair each parser, transform, or parsed file with its file u·r·i.
-override fileuripairs := $(join $(patsubst %,%|,$(PARSERS) $(TRANSFORMS) $(call parsed,$(sourcefiles) $(sourceincludes))),$(call pathenc,$(foreach uriable,$(PARSERS) $(TRANSFORMS) $(call parsed,$(sourcefiles) $(sourceincludes)),file://$(abspath $(uriable)))))
+# Pair each parser, transform, source file, or parsed file with its file u·r·i.
+override fileuripairs := $(join $(patsubst %,%|,$(PARSERS) $(TRANSFORMS) $(sourcefiles) $(sourceincludes) $(call parsed,$(sourcefiles) $(sourceincludes))),$(call pathenc,$(foreach uriable,$(PARSERS) $(TRANSFORMS) $(sourcefiles) $(sourceincludes) $(call parsed,$(sourcefiles) $(sourceincludes)),file://$(abspath $(uriable)))))
 
 # (callable) Get the file u·r·is for the given parsers, transforms, or parsed files.
 override fileuri = $(foreach file,$1,$(or $(patsubst $(file)|%,%,$(filter $(file)|%,$(fileuripairs))),$(error Unable to get file u·r·i for `$(file)´)))
@@ -617,6 +632,12 @@ $(BUILDDIR)/parser.xslt : $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2pars
        $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2parser.xslt) $(call quote,$<)
        $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types)
 
+# Generate R·D·F metadata for files.
+$(call metadata,$(sourcefiles) $(sourceincludes)) : % : $$(call datadata,$$@) $(typeupdates)
+       $(call inform,$(PRINTF) '%s\n' $(call quote,Generating metadata for `$<´…) >&2)
+       $(silent)$(call ensuredirectory,$(dir $@))
+       $(silent){ if $(TEST) ! -f $(call quote,$(BUILDDIR)/.mtime); then $(PRINTF) '%b' '\n' >|$(call quote,$(BUILDDIR)/.mtime); fi; $(TOUCH) -r $(call quote,$<) $(call quote,$(BUILDDIR)/.mtime); TZ=UTC0 $(DIFF) -u $(call quote,$(BUILDDIR)/.mtime) /dev/null | $(SED) '1!d;s/.*   \([^ ]*\) \([^ ]*\).*$$/\1T\2Z/'; $(CKSUM) $(call quote,$<) | $(SED) 's/[ ].*//'; } | $(xargsmultiquote) | $(XARGS) -E '' $(PRINTF) '<?xml version="1.0"?><nfo:LocalFileDataObject xmlns:dct="http://purl.org/dc/terms/" xmlns:nie="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#" xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="%s" nfo:fileUrl="%s"><nie:interpretedAs>$(if $(filter $(source),$(assetfiles)),<nfo:InformationElement nie:mimeType="%s"/>,<nfo:PlainTextDocument nie:mimeType="%s"/>)</nie:interpretedAs><dct:hasFormat><nfo:LocalFileDataObject nfo:fileUrl="%s"><nie:interpretedAs><nfo:PlainTextDocument nie:mimeType="application/xml"/></nie:interpretedAs></nfo:LocalFileDataObject></dct:hasFormat><nfo:fileLastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">%s</nfo:fileLastModified><nfo:hasHash nfo:hashAlgorithm="CRC32" nfo:hashValue="%s"/></nfo:LocalFileDataObject>' $(call quote,$(call attresc,$(call localuri,$<))) $(call quote,$(call attresc,$(call fileuri,$<))) $(call quote,$(call attresc,$(call typeoffile,$<))) $(call quote,$(call attresc,$(call fileuri,$(call parsed,$<)))) >|$(call quote,$@)
+
 # Parse the files.
 #
 # Even plain X·M·L files are parsed, because they may contain X·H·T·M·L `<script>´ elements which contain other kinds of data.
@@ -626,28 +647,25 @@ $(call parsed,$(sourcefiles) $(sourceincludes)) : % : $$(call unparsed,$$@) $(BU
        $(silent)$(call ensuredirectory,$(dir $@))
        $(silent)$(if $(filter $<,$(assetfiles)),$(PRINTF) '%s\n' $(call quote,<?xml version="1.0"?><object xmlns="http://www.w3.org/1999/xhtml" type="$(call typeoffile,$<)" data="$(call datauri,$<)"/>) >|$(call quote,$@),$(if $(filter $<,$(plaintextfiles)),$(call wrapplaintext,$<),$(call serializexml,$<)) | $(XSLTPROC) --nonet --novalid -o $(call quote,$@) --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam IDENTIFIER $(call quote,$(call localuri,$<)) --stringparam SRCTIME '$(call modtime,$<)' --stringparam CKSUM $$($(CKSUM) $(call quote,$<) | $(SED) 's/[ ].*//')$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/parser.xslt) -)
 
-# Generate a catalog of all parsed files, for use when processing includes.
-#
-# This does not depend on actually transforming the files.
-$(BUILDDIR)/catalog : $(call diffprereqs,sources,$(sort $(sourcefiles) $(sourceincludes))) $(typeupdates)
-       $(call inform,$(PRINTF) '%s\n' 'Generating catalog of parsed files…' >&2)
-       $(silent)$(XMLCATALOG) --create --noout $(call quote,$@)
-       $(foreach source,$(sourcefiles) $(sourceincludes),$(silent)$(XMLCATALOG) --add uri $(call quote,$(call localuri,$(source))) $(call quote,$(call fileuri,$(call parsed,$(source)))#$(if $(filter $(source),$(assetfiles)),asset,xml)) --noout $(call quote,$@)$(newline))
+# Collect the metadata into a single file.
+$(BUILDDIR)/metadata : $(call diffprereqs,metadatas,$(call metadata,$(sort $(sourcefiles) $(sourceincludes))))
+       $(call inform,$(PRINTF) '%s\n' 'Compiling metadata…' >&2)
+       $(silent){ $(PRINTF) '%s' '<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">'; $(foreach meta,$(call metadata,$(sort $(sourcefiles) $(sourceincludes))),$(CAT) $(call quote,$(meta)) | $(SED) 's/<?xml version="1.0"?>//';) $(PRINTF) '%s\n' '</rdf:RDF>'; } >|$(call quote,$@)
 
 # Build a list of dependencies for each parsed file.
-$(BUILDDIR)/dependencies : $(BUILDDIR)/catalog $(call parsed,$(plaintextfiles) $(xmlfiles)) $(THISDIR)/lib/catalog2dependencies.xslt
+$(BUILDDIR)/dependencies : $(BUILDDIR)/metadata $(call parsed,$(filter-out $(assetfiles),$(sourcefiles) $(sourceincludes))) $(THISDIR)/lib/metadata2dependencies.xslt
        $(call inform,$(PRINTF) '%s\n' 'Identifying dependencies…' >&2)
        $(silent)$(TOUCH) $(call quote,$@)
-       $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2dependencies.xslt) $(call quote,$<)
+       $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) $(call quote,$(THISDIR)/lib/metadata2dependencies.xslt) $(call quote,$<)
 
 # Generate a catalog of destinations for files.
 #
 # This depends on parsing non·asset source files, but not assets or includes.
 # It does not require knowing the dependencies.
-$(BUILDDIR)/destinations : $(BUILDDIR)/catalog $(call parsed,$(filter-out $(assetfiles),$(sourcefiles))) $(THISDIR)/lib/catalog2destinations.xslt
+$(BUILDDIR)/destinations : $(BUILDDIR)/metadata $(call parsed,$(filter-out $(assetfiles),$(sourcefiles))) $(THISDIR)/lib/metadata2destinations.xslt
        $(call inform,$(PRINTF) '%s\n' 'Identifying output destinations…' >&2)
        $(silent)$(TOUCH) $(call quote,$@)
-       $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2destinations.xslt) $(call quote,$<)
+       $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) $(call quote,$(THISDIR)/lib/metadata2destinations.xslt) $(call quote,$<)
 
 # Generate the main transform.
 $(BUILDDIR)/transform.catalog : $(call diffprereqs,transforms,$(sort $(TRANSFORMS)))
@@ -659,10 +677,10 @@ $(BUILDDIR)/transform.xslt : $(BUILDDIR)/transform.catalog $(THISDIR)/lib/catalo
        $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2transform.xslt) $(call quote,$<)
 
 # Compile the result files using the dependencies as necessary.
-$(call compiled,$(compilablefiles)) : $(BUILDDIR)/results/% : $$(call parsed,$$(call uncompiled,$$@)) $(BUILDDIR)/transform.xslt $$(call parsed,$$(call dependencies,$$(call uncompiled,$$@)))
+$(call compiled,$(compilablefiles)) : $(BUILDDIR)/results/% : $$(call parsed,$$(call uncompiled,$$@)) $$(call parsed,$$(call dependencies,$$(call uncompiled,$$@))) $(BUILDDIR)/transform.xslt $(BUILDDIR)/metadata
        $(call inform,$(PRINTF) '%s\n' $(call quote,Compiling </$*>…) >&2)
        $(silent)$(call ensuredirectory,$(dir $@))
-       $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) --stringparam CATALOG 'catalog' --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME '$(call modtime,$(call uncompiled,$@))' --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*) --stringparam CKSUM $$($(CKSUM) $(call quote,$(call uncompiled,$@)) | $(SED) 's/[ ].*//')$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
+       $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) --stringparam METADATA 'metadata' --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME '$(call modtime,$(call uncompiled,$@))' --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*) --stringparam CKSUM $$($(CKSUM) $(call quote,$(call uncompiled,$@)) | $(SED) 's/[ ].*//')$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
 
 # Create the final files from the compiled results (or error in the case of recursive ones).
 $(call built,$(compilablefiles)) : $(BUILDDIR)/public/% : $(BUILDDIR)/results/%
index 040d56465513be1b09df1536dd481cbe15020f09..b3789ad52731f96b6f68c85470bfe414c4ed53cf 100644 (file)
@@ -606,8 +606,8 @@ The following params are made available globally in parsers and
 
 The following params are only available in transforms :⁠—
 
-- **`CATALOG`:**
-  The path of the catalog file (within `BUILDDIR`).
+- **`METADATA`:**
+  The path of the metadata file (within `BUILDDIR`).
 
 - **`PATH`:**
   The path of the output file (within `DESTDIR`).
index 3fdbdb2f4da42f1538316ed97c8f4b2bfe6220fe..799bfeb30e53a33f86db4869d77007c192c07e8f 100644 (file)
@@ -20,12 +20,13 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
-       exclude-result-prefixes="catalog exslstr"
+       exclude-result-prefixes="catalog"
+       extension-element-prefixes="exslstr"
        version="1.0"
 >
        <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
        <template match="/">
-               <xslt:transform version="1.0">
+               <xslt:transform extension-element-prefixes="exsl" version="1.0">
                        <xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
                        <xslt:param name="CKSUM" select="false()"/>
                        <xslt:param name="IDENTIFIER" select="false()"/>
index c0e989b60e4ecd48d1253d53a2c44c9c2e8aee15..c41e3b1c7bae35a516b07c0b7db88514bd36d827 100644 (file)
@@ -17,23 +17,28 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 ]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
-       xmlns:html="http://www.w3.org/1999/xhtml"
+       xmlns:dct="http://purl.org/dc/terms/"
        xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
        xmlns:exsl="http://exslt.org/common"
        xmlns:exslstr="http://exslt.org/strings"
+       xmlns:html="http://www.w3.org/1999/xhtml"
+       xmlns:nie="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#"
+       xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#"
+       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:svg="http://www.w3.org/2000/svg"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
+       exclude-result-prefixes="catalog"
        version="1.0"
 >
        <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
        <template match="/">
-               <xslt:transform exclude-result-prefixes="catalog" extension-element-prefixes="exsl exslstr" version="1.0">
+               <xslt:transform exclude-result-prefixes="nie nfo" extension-element-prefixes="exsl exslstr" version="1.0">
                        <xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
                        <xslt:param name="CKSUM" select="false()"/>
-                       <xslt:param name="CATALOG" select="'catalog'"/>
                        <xslt:param name="IDENTIFIER" select="false()"/>
+                       <xslt:param name="METADATA" select="'metadata'"/>
                        <xslt:param name="PATH" select="'/unknown'"/>
                        <xslt:param name="SRCREV" select="false()"/>
                        <xslt:param name="SRCTIME" select="'1972-12-31T00:00:00Z'"/>
@@ -362,7 +367,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        </xslt:template>
                        <xslt:template match="书社:link[@xlink:show='embed']" mode="书社:expand" priority="1">
                                <xslt:variable name="identifier" select="string(@xlink:href)"/>
-                               <xslt:variable name="uri" select="substring-before(document($CATALOG)//catalog:uri[@name=$identifier]/@uri[1], '#')"/>
+                               <xslt:variable name="uri" select="document($METADATA)//*[@rdf:about=$identifier]/dct:hasFormat/*[nie:interpretedAs/*[@nie:mimeType='application/xml']]/@nfo:fileUrl[1]"/>
                                <xslt:choose>
                                        <xslt:when test="$uri">
                                                <xslt:variable name="expanded">
similarity index 75%
rename from lib/catalog2dependencies.xslt
rename to lib/metadata2dependencies.xslt
index 4341dea3a594af7479626fbb85194e721648df7d..663674b7630c76b696e0d72965210b9acf5ae257 100644 (file)
@@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2023, 2024 Lady <https://www.ladys.computer/about/#lady>
 SPDX-License-Identifier: MPL-2.0
 -->
 <!--
-⁌ ⛩️📰 书社 ∷ lib/catalog2dependencies.xslt
+⁌ ⛩️📰 书社 ∷ lib/metadata2dependencies.xslt
 
 © 2023–2024 Lady [@ Lady’s Computer].
 
@@ -13,13 +13,16 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 -->
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
-       xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
+       xmlns:dct="http://purl.org/dc/terms/"
        xmlns:exsl="http://exslt.org/common"
+       xmlns:nie="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#"
+       xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#"
+       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        version="1.0"
 >
-       <variable name="uris" select="//catalog:uri"/>
+       <variable name="files" select="/rdf:RDF/nfo:LocalFileDataObject"/>
        <template name="书社:process-dependencies">
                <param name="processed"/>
                <param name="unprocessed"/>
@@ -48,15 +51,15 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </variable>
                <variable name="new">
                        <for-each select="exsl:node-set($queue)/书社:*">
-                               <for-each select="$uris[@name=string(current()) and substring-after(@uri, '#')!='asset']">
-                                       <variable name="parent" select="@name"/>
-                                       <for-each select="document(substring-before(@uri, '#'), .)//书社:link[@xlink:show='embed']">
+                               <for-each select="$files[@rdf:about=string(current()) and nie:interpretedAs/nfo:PlainTextDocument and dct:hasFormat/*/nie:interpretedAs/*[@nie:mimeType='application/xml']]">
+                                       <variable name="parent" select="@rdf:about"/>
+                                       <for-each select="document(dct:hasFormat/*[nie:interpretedAs/*[@nie:mimeType='application/xml']]/@nfo:fileUrl[1])//书社:link[@xlink:show='embed']">
                                                <if test="exsl:node-set($old)/书社:dependency-root[string()=string(current()/@xlink:href)]">
                                                        <书社:recursive-dependency>
                                                                <value-of select="$parent"/>
                                                        </书社:recursive-dependency>
                                                </if>
-                                               <if test="$uris/@name[string()=string(current()/@xlink:href)]">
+                                               <if test="$files/@rdf:about[string()=string(current()/@xlink:href)]">
                                                        <书社:dependency>
                                                                <value-of select="@xlink:href"/>
                                                        </书社:dependency>
@@ -81,24 +84,24 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        </otherwise>
                </choose>
        </template>
-       <template match="catalog:uri" mode="书社:dependencies">
-               <if test="substring-after(@uri, '#')!='asset'">
+       <template match="nfo:LocalFileDataObject" mode="书社:dependencies">
+               <if test="nie:interpretedAs/nfo:PlainTextDocument">
                        <call-template name="书社:process-dependencies">
                                <with-param name="unprocessed">
                                        <书社:dependency-root>
-                                               <value-of select="@name"/>
+                                               <value-of select="@rdf:about"/>
                                        </书社:dependency-root>
                                </with-param>
                        </call-template>
                </if>
        </template>
        <template match="/">
-               <for-each select="$uris[not(substring-after(@uri, '#')='asset')]">
-                       <variable name="parent" select="@name"/>
+               <for-each select="$files[nie:interpretedAs/nfo:PlainTextDocument]">
+                       <variable name="parent" select="@rdf:about"/>
                        <variable name="dependencies">
                                <apply-templates select="." mode="书社:dependencies"/>
                        </variable>
-                       <value-of select="@name"/>
+                       <value-of select="@rdf:about"/>
                        <text>&#xA;</text>
                        <for-each select="exsl:node-set($dependencies)/书社:recursive-dependency">
                                <text>&#x9;</text>
similarity index 52%
rename from lib/catalog2destinations.xslt
rename to lib/metadata2destinations.xslt
index 411c454f1f1215bbe92b2e4d3d3a86d2c7d15c1e..9410455399c9fd938f1254d99537acc27e91c336 100644 (file)
@@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2023, 2024 Lady <https://www.ladys.computer/about/#lady>
 SPDX-License-Identifier: MPL-2.0
 -->
 <!--
-⁌ ⛩️📰 书社 ∷ lib/catalog2destinations.xslt
+⁌ ⛩️📰 书社 ∷ lib/metadata2destinations.xslt
 
 © 2024 Lady [@ Lady’s Computer].
 
@@ -13,33 +13,36 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 -->
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
-       xmlns:catalog="urn:oasis:names:tc:entity:xmlns:xml:catalog"
+       xmlns:dct="http://purl.org/dc/terms/"
        xmlns:exslstr="http://exslt.org/strings"
+       xmlns:nie="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#"
+       xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#"
+       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        extension-element-prefixes="exslstr"
        version="1.0"
 >
        <template match="/">
-               <for-each select="//catalog:uri[starts-with(@name, 'about:shushe?source=')]">
+               <for-each select="/rdf:RDF/nfo:LocalFileDataObject[starts-with(@rdf:about, 'about:shushe?source=')]">
                        <choose>
-                               <when test="substring-after(@uri, '#')='xml'">
-                                       <variable name="destination" select="document(substring-before(@uri, '#'), .)/*/@书社:destination"/>
-                                       <value-of select="@name"/>
+                               <when test="nie:interpretedAs/nfo:PlainTextDocument and dct:hasFormat/*/nie:interpretedAs/*[@nie:mimeType='application/xml']">
+                                       <variable name="destination" select="document(dct:hasFormat/*[nie:interpretedAs/*[@nie:mimeType='application/xml']]/@nfo:fileUrl[1])/*/@书社:destination"/>
+                                       <value-of select="@rdf:about"/>
                                        <text>|</text>
                                        <choose>
                                                <when test="$destination">
                                                        <value-of select="$destination"/>
                                                </when>
                                                <otherwise>
-                                                       <value-of select="substring-after(@name, 'about:shushe?source=')"/>
+                                                       <value-of select="substring-after(@rdf:about, 'about:shushe?source=')"/>
                                                </otherwise>
                                        </choose>
                                        <text>&#xA;</text>
                                </when>
                                <otherwise>
-                                       <value-of select="@name"/>
+                                       <value-of select="@rdf:about"/>
                                        <text>|</text>
-                                       <value-of select="substring-after(@name, 'about:shushe?source=')"/>
+                                       <value-of select="substring-after(@rdf:about, 'about:shushe?source=')"/>
                                        <text>&#xA;</text>
                                </otherwise>
                        </choose>
This page took 0.044588 seconds and 4 git commands to generate.