]> Lady’s Gitweb - Shushe/commitdiff
Provide metadata in transform; add attributes there
authorLady <redacted>
Wed, 22 May 2024 06:37:02 +0000 (02:37 -0400)
committerLady <redacted>
Thu, 11 Jul 2024 01:46:30 +0000 (21:46 -0400)
The metadata actually depends on the parser, so it’s a recursive
dependency to make the parser use it. Instead, just make it available
in transforms and add the various ⛩️📰 书社 attributes during the
expansion phase.

Literally including the metadata R·D·F in the transform greatly
increases its file size, but it “should” be fine.

This commit also brings with it a few other improvements and changes to
transforms :⁠—

- All of the `$书社:*` variables which used to return result tree
    fragments now return node sets.

- The `书社:application` mode has been renamed to `书社:apply`, to
    match `书社:expand`.

GNUmakefile
README.markdown
lib/catalog2parser.xslt
lib/catalog2transform.xslt
lib/literally.xslt [new file with mode: 0644]
transforms/asset.xslt
transforms/serialization.xslt

index 50be48d2ef074c93ff6f7b1788c1c5544d91d256..e9514eb3c0e8f5cfc6150d195c009f0d5d18c9e2 100644 (file)
@@ -426,10 +426,10 @@ 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, 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)))))
+# Pair each parser, transform, source file, parsed file, or metadata compilation with its file u·r·i.
+override fileuripairs := $(join $(patsubst %,%|,$(PARSERS) $(TRANSFORMS) $(sourcefiles) $(sourceincludes) $(call parsed,$(sourcefiles) $(sourceincludes)) $(BUILDDIR)/metadata),$(call pathenc,$(foreach uriable,$(PARSERS) $(TRANSFORMS) $(sourcefiles) $(sourceincludes) $(call parsed,$(sourcefiles) $(sourceincludes)) $(BUILDDIR)/metadata,file://$(abspath $(uriable)))))
 
-# (callable) Get the file u·r·is for the given parsers, transforms, or parsed files.
+# (callable) Get the file u·r·is for the given parsers, transforms, parsed files, or metadata compilations.
 override fileuri = $(foreach file,$1,$(or $(patsubst $(file)|%,%,$(filter $(file)|%,$(fileuripairs))),$(error Unable to get file u·r·i for `$(file)´)))
 
 ifneq ($(wildcard $(BUILDDIR)/dependencies),)
@@ -626,7 +626,7 @@ $(BUILDDIR)/parser.xslt : $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2pars
 $(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,$@)
+       $(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 $<,$(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.
 #
@@ -662,9 +662,9 @@ $(BUILDDIR)/transform.catalog : $(call diffprereqs,transforms,$(sort $(TRANSFORM
        $(call inform,$(PRINTF) '%s\n' 'Generating catalog of transforms…' >&2)
        $(silent)$(XMLCATALOG) --create --noout $(call quote,$@)
        $(foreach transform,$(TRANSFORMS),$(silent){ $(call id,$(transform)); $(PRINTF) '%s\n' $(call quote,$(call fileuri,$(transform))) '--noout' $(call quote,$@); } | $(xargsmultiquote) | $(XARGS) -E '' $(XMLCATALOG) --add uri$(newline))
-$(BUILDDIR)/transform.xslt : $(BUILDDIR)/transform.catalog $(THISDIR)/lib/catalog2transform.xslt
+$(BUILDDIR)/transform.xslt : $(BUILDDIR)/transform.catalog $(BUILDDIR)/metadata $(THISDIR)/lib/catalog2transform.xslt
        $(call inform,$(PRINTF) '%s\n' 'Generating main transform…' >&2)
-       $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2transform.xslt) $(call quote,$<)
+       $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) --stringparam METADATA $(call quote,$(call fileuri,$(BUILDDIR)/metadata)) $(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,$$@)) $$(call parsed,$$(call dependencies,$$(call uncompiled,$$@))) $(BUILDDIR)/transform.xslt $(BUILDDIR)/metadata
index e70361e3160b68b98656993439f61f38f36d5f52..e5a24eddc675297b11551834d15673f74dea3568 100644 (file)
@@ -464,32 +464,27 @@ It is **strongly recommended** that auxillary templates in parsers be
 
 ### Attributes added during parsing
 
-⛩️📰 书社 will add a few attributes to the output of the parsing step,
-  namely :⁠—
+⛩️📰 书社 will add a few attributes to elements which result from
+  parsing plaintext `<html:script>` elements.
+These include :⁠—
 
-- For toplevel result elements :⁠—
+- A `@书社:parsed-by` attribute, giving a space‐separated list of
+    parsers which parsed the node.
+  (Generally, this will be a list of one, but it is possible for the
+    result of a parse to be another plaintext node, which may be parsed
+    by a different parser.)
 
-  - A `@书社:cksum` attribute giving the `cksum` checksum of the
-      corresponding source file.
+- A `@书社:media-type` attribute, giving the identified media type of
+    the plaintext node.
 
-  - A `@书社:mtime` attribute giving the last modified time of the
-      corresponding source file.
-
-  - A `@书社:identifier` attribute giving the ⛩️📰 书社 identifier
-      (i·e, starting with `about:shushe?`) of the corresponding source
-      file.
-
-- For the elements which result from parsing plaintext `<html:script>`
-    elements :⁠—
-
-  - A `@书社:parsed-by` attribute, giving a space‐separated list of
-      parsers which parsed the node.
-    (Generally, this will be a list of one, but it is possible for the
-      result of a parse to be another plaintext node, which may be
-      parsed by a different parser.)
+## Output Redirection
 
-  - A `@书社:media-type` attribute, giving the identified media type of
-      the plaintext node.
+By default, ⛩️📰 书社 installs files to the same location in `DESTDIR`
+  as they were placed in their `SRCDIR`.
+This behaviour can be customized by setting the `@书社:destination`
+  attribute on the root element, whose value can give a different path.
+This attribute is read after parsing, but before transformation (where
+  it is silently dropped).
 
 ## Embedding
 
@@ -516,14 +511,30 @@ Embedding takes place after parsing but before transformation, so
   and update them accordingly; it will signal an error if the
   dependencies are recursive.
 
-## Output Redirection
+### Attributes added during expansion
 
-By default, ⛩️📰 书社 installs files to the same location in `DESTDIR`
-  as they were placed in their `SRCDIR`.
-This behaviour can be customized by setting the `@书社:destination`
-  attribute on the root element, whose value can give a different path.
-This attribute is read after parsing, but before transformation (where
-  it is silently dropped).
+⛩️📰 书社 will add a few attributes to toplevel result elements, both
+  in the main document and any embedded documents, during the expansion
+  phase prior to the main transformation.
+These include :⁠—
+
+- A `@书社:cksum` attribute giving the `cksum` checksum of the
+    corresponding source file.
+
+- A `@书社:mtime` attribute giving the last modified time of the
+    corresponding source file.
+
+- A `@书社:identifier` attribute giving the ⛩️📰 书社 identifier
+    (i·e, starting with `about:shushe?`) of the corresponding source
+    file.
+
+- For elements in the `html` namespace, an `itemscope` attribute and an
+    `itemtype` attribute with a value of
+    `urn:fdc:ladys.computer:20231231:Shu1She4:document` (for the main
+    document) or `urn:fdc:ladys.computer:20231231:Shu1She4:embed` (for
+    embedded documents).
+  These attributes are used to scope any nested `<html:meta>` elements
+    with `@itemprop` attributes to their containing documents.
 
 ## Transforms
 
@@ -609,9 +620,6 @@ The following params are made available globally in parsers and
 
 The following params are only available in transforms :⁠—
 
-- **`METADATA`:**
-  The path of the metadata file (within `BUILDDIR`).
-
 - **`PATH`:**
   The path of the output file (within `DESTDIR`).
 
index f3afd7fa945d8a763e30cbe22f792269910e290c..381fee3f8b993968aec2ff79a79be6258f266c2a 100644 (file)
@@ -122,30 +122,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </xslt:for-each>
                        </xslt:template>
                        <xslt:template match="/">
-                               <xslt:variable name="parsedroot">
-                                       <xslt:apply-templates select="node()" mode="书社:parse"/>
-                               </xslt:variable>
-                               <xslt:for-each select="exsl:node-set($parsedroot)/node()">
-                                       <xslt:choose>
-                                               <xslt:when test="self::*">
-                                                       <xslt:copy>
-                                                               <xslt:attribute name="书社:cksum">
-                                                                       <xslt:value-of select="document('metadata')//*[@rdf:about=$IDENTIFIER]/nfo:hasHash[@nfo:hashAlgorithm='CRC32']/@nfo:hashValue"/>
-                                                               </xslt:attribute>
-                                                               <xslt:attribute name="书社:identifier">
-                                                                       <xslt:value-of select="$IDENTIFIER"/>
-                                                               </xslt:attribute>
-                                                               <xslt:attribute name="书社:mtime">
-                                                                       <xslt:value-of select="document('metadata')//*[@rdf:about=$IDENTIFIER]/nfo:fileLastModified"/>
-                                                               </xslt:attribute>
-                                                               <xslt:copy-of select="@*[namespace-uri()!='urn:fdc:ladys.computer:20231231:Shu1She4' or not(contains(' cksum identifier mtime ', concat(' ', local-name(), ' ')))]|node()"/>
-                                                       </xslt:copy>
-                                               </xslt:when>
-                                               <xslt:otherwise>
-                                                       <xslt:copy-of select="."/>
-                                               </xslt:otherwise>
-                                       </xslt:choose>
-                               </xslt:for-each>
+                               <xslt:apply-templates select="node()" mode="书社:parse"/>
                        </xslt:template>
                        <xslt:template match="@*|node()" priority="-1">
                                <xslt:copy>
index dc09330ed10c461f1d5059d41ce1fe472a92bcdf..fe160872ee39699e76db49ccd0da4df5803a8fe4 100644 (file)
@@ -32,22 +32,29 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        exclude-result-prefixes="catalog"
        version="1.0"
 >
+       <include href="literally.xslt"/>
        <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
+       <param name="METADATA" select="'about:blank'"/>
        <template match="/">
                <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="IDENTIFIER" select="false()"/>
-                       <xslt:param name="METADATA" select="'metadata'"/>
                        <xslt:param name="PATH" select="'/unknown'"/>
                        <xslt:param name="SRCREV" select="false()"/>
                        <xslt:param name="THISREV" select="false()"/>
                        <xslt:variable name="书社:source" select="/"/>
-                       <xslt:variable name="书社:expansion">
+                       <xslt:variable name="书社:about-fragment">
+                               <apply-templates select="document($METADATA)" mode="书社:literally"/>
+                       </xslt:variable>
+                       <xslt:variable name="书社:about" select="exsl:node-set($书社:about-fragment)"/>
+                       <xslt:variable name="书社:expansion-fragment">
                                <xslt:apply-templates select="$书社:source/node()" mode="书社:expand"/>
                        </xslt:variable>
-                       <xslt:variable name="书社:result">
-                               <xslt:apply-templates select="exsl:node-set($书社:expansion)/node()"/>
+                       <xslt:variable name="书社:expansion" select="exsl:node-set($书社:expansion-fragment)"/>
+                       <xslt:variable name="书社:result-fragment">
+                               <xslt:apply-templates select="$书社:expansion/node()"/>
                        </xslt:variable>
+                       <xslt:variable name="书社:result" select="exsl:node-set($书社:result-fragment)"/>
                        <xslt:variable name="书社:destination">
                                <xslt:choose>
                                        <xslt:when test="string($书社:source/@书社:destination)!=''">
@@ -253,13 +260,13 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </html:html>
                        </xslt:template>
                        <xslt:template match="/" priority="1">
-                               <xslt:variable name="result-nodes" select="exsl:node-set($书社:result)/node()[not(self::书社:apply-attributes-to-root)]|exsl:node-set($书社:result)/书社:apply-attributes-to-root/descendant::node()[not(self::书社:apply-attributes-to-root) and not(ancestor::*[not(self::书社:apply-attributes-to-root)])]"/>
+                               <xslt:variable name="result-nodes" select="$书社:result/node()[not(self::书社:apply-attributes-to-root)]|$书社:result/书社:apply-attributes-to-root/descendant::node()[not(self::书社:apply-attributes-to-root) and not(ancestor::*[not(self::书社:apply-attributes-to-root)])]"/>
                                <xslt:variable name="root-with-attributes">
                                        <xslt:choose>
-                                               <xslt:when test="$result-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive']|$result-nodes/@书社:disable-output-wrapping|exsl:node-set($书社:result)//书社:apply-attributes-to-root/@书社:disable-output-wrapping">
+                                               <xslt:when test="$result-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive']|$result-nodes/@书社:disable-output-wrapping|$书社:result//书社:apply-attributes-to-root/@书社:disable-output-wrapping">
                                                        <xslt:call-template name="书社:apply-attributes">
                                                                <xslt:with-param name="and-version" select="true()"/>
-                                                               <xslt:with-param name="context-nodes" select="exsl:node-set($书社:result)//书社:apply-attributes-to-root"/>
+                                                               <xslt:with-param name="context-nodes" select="$书社:result//书社:apply-attributes-to-root"/>
                                                                <xslt:with-param name="destination-nodes" select="$result-nodes"/>
                                                        </xslt:call-template>
                                                </xslt:when>
@@ -271,32 +278,32 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                        </xslt:variable>
                                                        <xslt:call-template name="书社:apply-attributes">
                                                                <xslt:with-param name="and-version" select="true()"/>
-                                                               <xslt:with-param name="context-nodes" select="exsl:node-set($书社:result)//书社:apply-attributes-to-root"/>
+                                                               <xslt:with-param name="context-nodes" select="$书社:result//书社:apply-attributes-to-root"/>
                                                                <xslt:with-param name="destination-nodes" select="exsl:node-set($wrapped-result)/node()"/>
                                                        </xslt:call-template>
                                                </xslt:otherwise>
                                        </xslt:choose>
                                </xslt:variable>
-                               <xslt:apply-templates select="exsl:node-set($root-with-attributes)/node()" mode="书社:application"/>
+                               <xslt:apply-templates select="exsl:node-set($root-with-attributes)/node()" mode="书社:apply"/>
                        </xslt:template>
                        <xslt:template match="@*|node()" priority="-1">
                                <xslt:copy>
                                        <xslt:apply-templates select="@*|node()"/>
                                </xslt:copy>
                        </xslt:template>
-                       <xslt:template match="@*|node()" mode="书社:application">
+                       <xslt:template match="@*|node()" mode="书社:apply">
                                <xslt:copy>
-                                       <xslt:apply-templates select="@*|node()" mode="书社:application"/>
+                                       <xslt:apply-templates select="@*|node()" mode="书社:apply"/>
                                </xslt:copy>
                        </xslt:template>
-                       <xslt:template match="@书社:destination|@书社:disable-output-wrapping|@书社:archived-as[../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]]" mode="书社:application" priority="1"/>
-                       <xslt:template match="书社:archive" mode="书社:application" priority="1">
+                       <xslt:template match="@书社:destination|@书社:disable-output-wrapping|@书社:archived-as[../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]]" mode="书社:apply" priority="1"/>
+                       <xslt:template match="书社:archive" mode="书社:apply" priority="1">
                                <xslt:copy>
                                        <xslt:for-each select="@*">
                                                <xslt:choose>
                                                        <xslt:when test="local-name()='archived-as' and namespace-uri()='&书社;' and ../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]"/>
                                                        <xslt:otherwise>
-                                                               <xslt:apply-templates select="." mode="书社:application"/>
+                                                               <xslt:apply-templates select="." mode="书社:apply"/>
                                                        </xslt:otherwise>
                                                </xslt:choose>
                                        </xslt:for-each>
@@ -315,50 +322,26 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                </xslt:otherwise>
                                                                        </xslt:choose>
                                                                </xslt:variable>
-                                                               <xslt:apply-templates select="exsl:node-set($component)/node()" mode="书社:application"/>
+                                                               <xslt:apply-templates select="exsl:node-set($component)/node()" mode="书社:apply"/>
                                                        </xslt:when>
                                                        <xslt:otherwise>
-                                                               <xslt:apply-templates select="." mode="书社:application"/>
+                                                               <xslt:apply-templates select="." mode="书社:apply"/>
                                                        </xslt:otherwise>
                                                </xslt:choose>
                                        </xslt:for-each>
                                </xslt:copy>
                        </xslt:template>
-                       <xslt:template match="书社:apply-attributes" mode="书社:application" priority="1">
+                       <xslt:template match="书社:apply-attributes" mode="书社:apply" priority="1">
                                <xslt:variable name="children">
-                                       <xslt:apply-templates mode="书社:application"/>
+                                       <xslt:apply-templates mode="书社:apply"/>
                                </xslt:variable>
                                <xslt:call-template name="书社:apply-attributes">
                                        <xslt:with-param name="context-nodes" select="."/>
                                        <xslt:with-param name="destination-nodes" select="exsl:node-set($children)/node()"/>
                                </xslt:call-template>
                        </xslt:template>
-                       <xslt:template match="书社:apply-attributes-to-root" mode="书社:application" priority="1">
-                               <xslt:apply-templates mode="书社:application"/>
-                       </xslt:template>
-                       <xslt:template match="/node()" mode="书社:expand" priority="0">
-                               <xslt:copy>
-                                       <xslt:choose>
-                                               <xslt:when test="self::html:*">
-                                                       <xslt:attribute name="itemscope">itemscope</xslt:attribute>
-                                                       <xslt:attribute name="itemtype">
-                                                               <xslt:text>
-                                                                       <text>&书社;:document</text>
-                                                               </xslt:text>
-                                                               <xslt:for-each select="exslstr:tokenize(@itemtype)/token">
-                                                                       <xslt:text>
-                                                                               <text> </text>
-                                                                       </xslt:text>
-                                                                       <xslt:value-of select="."/>
-                                                               </xslt:for-each>
-                                                       </xslt:attribute>
-                                                       <xslt:apply-templates select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()" mode="书社:expand"/>
-                                               </xslt:when>
-                                               <xslt:otherwise>
-                                                       <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
-                                               </xslt:otherwise>
-                                       </xslt:choose>
-                               </xslt:copy>
+                       <xslt:template match="书社:apply-attributes-to-root" mode="书社:apply" priority="1">
+                               <xslt:apply-templates mode="书社:apply"/>
                        </xslt:template>
                        <xslt:template match="书社:link[@xlink:show='embed']" mode="书社:expand" priority="1">
                                <xslt:variable name="identifier" select="string(@xlink:href)"/>
@@ -366,7 +349,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <xslt:choose>
                                        <xslt:when test="$uri">
                                                <xslt:variable name="expanded">
-                                                       <xslt:apply-templates select="document($uri)" mode="书社:expand"/>
+                                                       <xslt:apply-templates select="document($uri)" mode="书社:expand">
+                                                               <xslt:with-param name="identifier" select="$identifier"/>
+                                                       </xslt:apply-templates>
                                                </xslt:variable>
                                                <xslt:for-each select="exsl:node-set($expanded)/node()">
                                                        <xslt:copy>
@@ -400,6 +385,42 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        </xslt:otherwise>
                                </xslt:choose>
                        </xslt:template>
+                       <xslt:template match="/node()" mode="书社:expand" priority="0">
+                               <xslt:param name="identifier" select="$IDENTIFIER"/>
+                               <xslt:copy>
+                                       <xslt:if test="self::*">
+                                               <xslt:attribute name="书社:cksum">
+                                                       <xslt:value-of select="$书社:about//*[@rdf:about=$identifier]/nfo:hasHash[@nfo:hashAlgorithm='CRC32']/@nfo:hashValue"/>
+                                               </xslt:attribute>
+                                               <xslt:attribute name="书社:identifier">
+                                                       <xslt:value-of select="$identifier"/>
+                                               </xslt:attribute>
+                                               <xslt:attribute name="书社:mtime">
+                                                       <xslt:value-of select="$书社:about//*[@rdf:about=$identifier]/nfo:fileLastModified"/>
+                                               </xslt:attribute>
+                                       </xslt:if>
+                                       <xslt:choose>
+                                               <xslt:when test="self::html:*">
+                                                       <xslt:attribute name="itemscope">itemscope</xslt:attribute>
+                                                       <xslt:attribute name="itemtype">
+                                                               <xslt:text>
+                                                                       <text>&书社;:document</text>
+                                                               </xslt:text>
+                                                               <xslt:for-each select="exslstr:tokenize(@itemtype)/token">
+                                                                       <xslt:text>
+                                                                               <text> </text>
+                                                                       </xslt:text>
+                                                                       <xslt:value-of select="."/>
+                                                               </xslt:for-each>
+                                                       </xslt:attribute>
+                                                       <xslt:apply-templates select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype') or namespace-uri()='&书社;' and (local-name()='cksum' or local-name()='identifier' or local-name()='mtime'))]|node()" mode="书社:expand"/>
+                                               </xslt:when>
+                                               <xslt:otherwise>
+                                                       <xslt:apply-templates select="@*[not(namespace-uri()='&书社;' and (local-name()='cksum' or local-name()='identifier' or local-name()='mtime'))]|node()" mode="书社:expand"/>
+                                               </xslt:otherwise>
+                                       </xslt:choose>
+                               </xslt:copy>
+                       </xslt:template>
                        <xslt:template match="@*|node()[not(self::书社:link) or not(@xlink:show='embed')]" mode="书社:expand" priority="-1">
                                <xslt:copy>
                                        <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
diff --git a/lib/literally.xslt b/lib/literally.xslt
new file mode 100644 (file)
index 0000000..dc104e1
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
+SPDX-License-Identifier: MPL-2.0
+-->
+<!--
+⁌ ⛩️📰 书社 ∷ lib/literally.xslt
+
+© 2024 Lady [@ Lady’s 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:xslt="http://www.w3.org/1999/XSL/TransformAlias"
+       xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
+       version="1.0"
+>
+       <template match="node()" mode="书社:literally">
+               <choose>
+                       <when test="self::*">
+                               <xslt:element name="{name()}" namespace="{namespace-uri()}">
+                                       <for-each select="@*">
+                                               <xslt:attribute name="{name()}" namespace="{namespace-uri()}">
+                                                       <xslt:text>
+                                                               <value-of select="."/>
+                                                       </xslt:text>
+                                               </xslt:attribute>
+                                       </for-each>
+                                       <apply-templates mode="书社:literally"/>
+                               </xslt:element>
+                       </when>
+                       <when test="self::text()">
+                               <xslt:text>
+                                       <value-of select="."/>
+                               </xslt:text>
+                       </when>
+                       <when test="self::processing-instruction()">
+                               <xslt:processing-instruction name="{local-name()}">
+                                       <xslt:text>
+                                               <value-of select="."/>
+                                       </xslt:text>
+                               </xslt:processing-instruction>
+                       </when>
+                       <when test="self::comment()">
+                               <xslt:comment>
+                                       <xslt:text>
+                                               <value-of select="."/>
+                                       </xslt:text>
+                               </xslt:comment>
+                       </when>
+                       <otherwise>
+                               <apply-templates mode="书社:literally"/>
+                       </otherwise>
+               </choose>
+       </template>
+</transform>
index f7636c2f2b255298d162c2c39c354d85314507eb..575e53647267312be524b3ba9567064473b38689 100644 (file)
@@ -43,12 +43,12 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </html:video>
        </template>
        <template match="xslt:include[@书社:id='urn:fdc:ladys.computer:20231231:Shu1She4:asset.xslt']" mode="书社:metadata">
-               <for-each select="exsl:node-set($书社:expansion)//html:object[@type='text/css']">
+               <for-each select="$书社:expansion//html:object[@type='text/css']">
                        <html:link rel="stylesheet" type="text/css" href="{@data}">
                                <copy-of select="@书社:identifier"/>
                        </html:link>
                </for-each>
-               <for-each select="exsl:node-set($书社:expansion)//html:style">
+               <for-each select="$书社:expansion//html:style">
                        <copy-of select="."/>
                </for-each>
        </template>
index 6d6dacddf03c4bce6e0bd98a9e46b0dc8f16e461..2565fa6ea0bd38a0e2a9a057c7cf273545fdf2ce 100644 (file)
@@ -22,10 +22,10 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 >
        <import href="../lib/serialize.xslt"/>
        <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:serialization.xslt</书社:id>
-       <template match="书社:serialize-xml" mode="书社:application" priority="1">
+       <template match="书社:serialize-xml" mode="书社:apply" priority="1">
                <variable name="namespaces" select="namespace::*"/>
                <variable name="contents">
-                       <apply-templates mode="书社:application"/>
+                       <apply-templates mode="书社:apply"/>
                </variable>
                <variable name="passthru-namespaces" select="exslstr:tokenize(string(@with-namespaces))"/>
                <apply-templates select="exsl:node-set($contents)" mode="书社:serialize">
This page took 0.217773 seconds and 4 git commands to generate.