]> Lady’s Gitweb - Shushe/commitdiff
Provide the location of parsed files in metadata
authorLady <redacted>
Sat, 22 Jun 2024 21:54:29 +0000 (17:54 -0400)
committerLady <redacted>
Thu, 11 Jul 2024 01:46:30 +0000 (21:46 -0400)
Rather than hardcoding parsed file lookup into `expandmetadata.xslt`
and `catalog2transform.xslt`, provide a file U·R·I for the parsed file
as a part of its metadata and use that instead. It _is_ reasonable for
transforms to want to access the original parsed documents of
dependencies. Note, however, that there is no guarantee that the parsed
document actually exists if it _isn’t_ a dependency for the file.

GNUmakefile
lib/catalog2transform.xslt
lib/expandmetadata.xslt

index be4ec71c07629345a14b35dac016406c4d9182cf..811520064d81d4435c5aba450d84916caff3c637 100644 (file)
@@ -442,10 +442,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 build directory, parser, transform, or source file with its file u·r·i.
-override fileuripairs := $(join $(patsubst %,%|,$(BUILDDIR) $(PARSERS) $(TRANSFORMS) $(sourcefiles) $(sourceincludes)),$(call pathenc,$(foreach uriable,$(BUILDDIR) $(PARSERS) $(TRANSFORMS) $(sourcefiles) $(sourceincludes),file://$(abspath $(uriable)))))
+# Pair each build directory, parser, transform, or parsed file with its file u·r·i.
+override fileuripairs := $(join $(patsubst %,%|,$(BUILDDIR) $(PARSERS) $(TRANSFORMS) $(call parsed,$(sourcefiles) $(sourceincludes))),$(call pathenc,$(foreach uriable,$(BUILDDIR) $(PARSERS) $(TRANSFORMS) $(call parsed,$(sourcefiles) $(sourceincludes)),file://$(abspath $(uriable)))))
 
-# (callable) Get the file u·r·is for the given parsers, transforms, parsed files, or metadata compilations.
+# (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)´)))
 
 ifneq ($(wildcard $(BUILDDIR)/dependencies),)
@@ -625,7 +625,7 @@ $(BUILDDIR)/parser.xslt : $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2pars
 # If the types have been updated but `typeupdates´ is not active, this recipe is skipped because a restart is forthcoming.
 $(call metadata,$(sourcefiles) $(sourceincludes)) : % : $$(call datadata,$$@) $(THISDIR)/lib/expandmetadata.xslt $(typeupdates)
        $(call inform,$(call unlesstypeswillupdate,$(PRINTF) '%s\n' $(call quote,Generating metadata for `$<´…) >&2))
-       $(silent)$(call unlesstypeswillupdate,$(call ensuredirectory,$(dir $@)); { if $(TEST) ! -f $(call quote,$(BUILDDIR)/.mtime); then $(PRINTF) '%b' '\n' >|$(call quote,$(BUILDDIR)/.mtime); fi; $(TOUCH) -r $(call quote,$<) $(call quote,$(BUILDDIR)/.mtime); $(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"?><书社vocab:$(if $(filter $<,$(sourceincludes)),IncludeFile,SourceFile) 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:书社vocab="urn:fdc:ladys.computer:20231231:Shu1She4:vocab:" rdf:about="%s" 书社vocab:path="%s"><nie:interpretedAs>$(if $(filter $<,$(assetfiles)),<nfo:InformationElement nie:mimeType="%s"/>,<nfo:PlainTextDocument nie:mimeType="%s"/>)</nie:interpretedAs><nfo:fileLastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">%s</nfo:fileLastModified><nfo:hasHash nfo:hashAlgorithm="CRC32" nfo:hashValue="%s"/></书社vocab:$(if $(filter $<,$(sourceincludes)),IncludeFile,SourceFile)>' $(call quote,$(call attresc,$(call localuri,$<))) $(call quote,$(call attresc,$(if $(filter $<,$(sourceincludes)),$(call includepath,$<),$(call sourcepath,$<)))) $(call quote,$(call attresc,$(call typeoffile,$<))) >|$(call quote,$@))
+       $(silent)$(call unlesstypeswillupdate,$(call ensuredirectory,$(dir $@)); { if $(TEST) ! -f $(call quote,$(BUILDDIR)/.mtime); then $(PRINTF) '%b' '\n' >|$(call quote,$(BUILDDIR)/.mtime); fi; $(TOUCH) -r $(call quote,$<) $(call quote,$(BUILDDIR)/.mtime); $(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"?><书社vocab:$(if $(filter $<,$(sourceincludes)),IncludeFile,SourceFile) 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:书社vocab="urn:fdc:ladys.computer:20231231:Shu1She4:vocab:" rdf:about="%s" 书社vocab:path="%s"><nie:interpretedAs>$(if $(filter $<,$(assetfiles)),<nfo:InformationElement nie:mimeType="%s"/>,<nfo:PlainTextDocument nie:mimeType="%s"/>)</nie:interpretedAs><书社vocab:hasParsedFile nfo:fileUrl="%s"/><nfo:fileLastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">%s</nfo:fileLastModified><nfo:hasHash nfo:hashAlgorithm="CRC32" nfo:hashValue="%s"/></书社vocab:$(if $(filter $<,$(sourceincludes)),IncludeFile,SourceFile)>' $(call quote,$(call attresc,$(call localuri,$<))) $(call quote,$(call attresc,$(if $(filter $<,$(sourceincludes)),$(call includepath,$<),$(call sourcepath,$<)))) $(call quote,$(call attresc,$(call typeoffile,$<))) $(call quote,$(call attresc,$(call fileuri,$(call parsed,$<)))) >|$(call quote,$@))
 
 # Parse the files.
 #
index e169fa7495a63c64340845b06a51594f1d99a71a..6d721a7b27c4cd8df61f710e8f5b5f783b8c76b4 100644 (file)
@@ -350,20 +350,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <xslt:variable name="included" select="$书社:about//*[@rdf:about=$identifier]"/>
                                <xslt:choose>
                                        <xslt:when test="$included">
-                                               <xslt:variable name="uri">
-                                                       <xslt:text>
-                                                               <value-of select="$builddir"/>
-                                                       </xslt:text>
-                                                       <xslt:choose>
-                                                               <xslt:when test="$included/self::书社vocab:SourceFile">
-                                                                       <xslt:text>/sources/</xslt:text>
-                                                               </xslt:when>
-                                                               <xslt:when test="$included/self::书社vocab:IncludeFile">
-                                                                       <xslt:text>/includes/</xslt:text>
-                                                               </xslt:when>
-                                                       </xslt:choose>
-                                                       <xslt:value-of select="$included/@书社vocab:path"/>
-                                               </xslt:variable>
+                                               <xslt:variable name="uri" select="$included/书社vocab:hasParsedFile/@nfo:fileUrl"/>
                                                <xslt:variable name="expanded">
                                                        <xslt:apply-templates select="document($uri)" mode="书社:expand">
                                                                <xslt:with-param name="identifier" select="$identifier"/>
index 3d46c82873b05e0aff27da0076c3dc5e6d673008..dd393550c5ea66416287886042cc3cda0fa6e6e6 100644 (file)
@@ -55,17 +55,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        <for-each select="exsl:node-set($queue)/书社:*">
                                <for-each select="$files[@rdf:about=string(current()) and nie:interpretedAs/nfo:PlainTextDocument]">
                                        <variable name="parent" select="@rdf:about"/>
-                                       <variable name="subdir">
-                                               <choose>
-                                                       <when test="starts-with($parent, 'about:shushe?include=')">
-                                                               <text>/includes/</text>
-                                                       </when>
-                                                       <when test="starts-with($parent, 'about:shushe?source=')">
-                                                               <text>/sources/</text>
-                                                       </when>
-                                               </choose>
-                                       </variable>
-                                       <for-each select="document(concat($builddir, $subdir, @书社vocab:path), .)//书社:link[@xlink:show='embed']">
+                                       <variable name="uri" select="书社vocab:hasParsedFile/@nfo:fileUrl"/>
+                                       <for-each select="document($uri)//书社:link[@xlink:show='embed']">
                                                <if test="exsl:node-set($old)/书社:dependency-root[string()=string(current()/@xlink:href)]">
                                                        <书社:recursive-dependency>
                                                                <value-of select="$parent"/>
@@ -106,7 +97,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </copy>
        </template>
        <template match="//书社vocab:SourceFile[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
-               <variable name="parsed" select="document(concat($builddir, '/sources/', @书社vocab:path), .)"/>
+               <variable name="parsed" select="document(书社vocab:hasParsedFile/@nfo:fileUrl)"/>
                <variable name="destination-delim" select="concat('/', $parsed/*/@书社:destination, '/')"/>
                <variable name="destination">
                        <choose>
This page took 0.031072 seconds and 4 git commands to generate.