override destinations := $(shell $(CAT) $(BUILDDIR)/destinations)
# Pair source files and their destinations.
-override sourcedestinationpair := $(foreach destination,$(destinations),$(call sourcefile,$(firstword $(subst |, ,$(destination))))|$(call perdec,$(subst $(space),|,$(wordlist 2,$(words $(subst |, ,$(destination))),$(subst |, ,$(destination))))))
+override sourcedestinationpair := $(foreach destination,$(destinations),$(call sourcefile,$(firstword $(subst |, ,$(destination))))|$(subst $(space),|,$(wordlist 2,$(words $(subst |, ,$(destination))),$(subst |, ,$(destination)))))
+endif
# (callable) Get the destination for the given source files, or return `.NOTDEF/$1´.
#
# (callable) Get the installed locations for the given source files.
override installed = $(foreach file,$1,$(DESTDIR)/$(call destination,$(file)))
-endif
# ─ ¶ Recipe Variable Definitions ─────────────────────────────────────
$(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types)
# Generate R·D·F metadata for files.
-$(call metadata,$(sourcefiles) $(sourceincludes)) : % : $$(call datadata,$$@) $(typeupdates)
+#
+# This “depends” on `$(THISDIR)/lib/expandmetadata.xslt´ not because it is an actual dependency, but because a change to that file strongly suggests a change to these rules has occurred as well.
+$(call metadata,$(sourcefiles) $(sourceincludes)) : % : $$(call datadata,$$@) $(THISDIR)/lib/expandmetadata.xslt $(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); $(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: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:fileName="%s" nfo:fileUrl="%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"/></nfo:LocalFileDataObject>' $(call quote,$(call attresc,$(call localuri,$<))) $(call quote,$(call attresc,$(if $(filter $<,$(sourceincludes)),$(call includepath,$<),$(call sourcepath,$<)))) $(call quote,$(call attresc,$(call fileuri,$<))) $(call quote,$(call attresc,$(call typeoffile,$<))) >|$(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); $(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,$@)
# Parse the files.
#
# Collect the metadata into a single file.
$(BUILDDIR)/metadata : $(call diffprereqs,metadatas,$(call metadata,$(sort $(sourcefiles) $(sourceincludes)))) $(call parsed,$(filter-out $(assetfiles),$(sourcefiles) $(sourceincludes))) $(THISDIR)/lib/expandmetadata.xslt
$(call inform,$(PRINTF) '%s\n' 'Compiling metadata…' >&2)
- $(silent){ $(PRINTF) '<?xml version="1.0"?><rdf:RDF 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#" xmlns:书社vocab="urn:fdc:ladys.computer:20231231:Shu1She4:vocab:"><nfo:LocalFileDataObject rdf:about="about:shushe?builddir" nfo:fileUrl="%s"><nie:interpretedAs><nfo:Folder/></nie:interpretedAs></nfo:LocalFileDataObject>' $(call quote,$(call attresc,$(call fileuri,$(BUILDDIR)))); { $(foreach meta,$(call metadata,$(sort $(sourcefiles) $(sourceincludes))),$(CAT) $(call quote,$(meta));) } | $(SED) 's/<?xml version="1.0"?>//g'; $(PRINTF) '%s\n' '</rdf:RDF>'; } | $(XSLTPROC) --nonet --novalid --nomkdir --nowrite $(call quote,$(THISDIR)/lib/expandmetadata.xslt) - | $(XMLLINT) --nonet --nsclean - >|$(call quote,$@)
+ $(silent){ $(PRINTF) '<?xml version="1.0"?><rdf:RDF 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:"><书社vocab:BuildDirectory nfo:fileUrl="%s"/>' $(call quote,$(call attresc,$(call fileuri,$(BUILDDIR)))); { $(foreach meta,$(call metadata,$(sort $(sourcefiles) $(sourceincludes))),$(CAT) $(call quote,$(meta));) } | $(SED) 's/<?xml version="1.0"?>//g'; $(PRINTF) '%s\n' '</rdf:RDF>'; } | $(XSLTPROC) --nonet --novalid --nomkdir --nowrite $(call quote,$(THISDIR)/lib/expandmetadata.xslt) - | $(XMLLINT) --nonet --nsclean - >|$(call quote,$@)
# Build a list of dependencies for each parsed file.
$(BUILDDIR)/dependencies : $(BUILDDIR)/metadata $(THISDIR)/lib/metadata2dependencies.xslt
$(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 --nomkdir --nowrite --stringparam METADATA 'metadata' --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*)$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<) >|$(call quote,$@)
+ $(silent)$(XSLTPROC) --nonet --novalid --nomkdir --nowrite --stringparam METADATA 'metadata' --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@)))$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<) >|$(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/%
- **`THISREV`:**
The value of the `THISREV` variable (if present).
-The following params are only available in transforms :—
-
-- **`PATH`:**
- The path of the output file (within `DESTDIR`).
-
## Output Wrapping
Provided at least one toplevel result element belongs to the H·T·M·L
]>
<transform
xmlns="http://www.w3.org/1999/XSL/Transform"
- 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:xlink="http://www.w3.org/1999/xlink"
xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
+ xmlns:书社vocab="urn:fdc:ladys.computer:20231231:Shu1She4:vocab:"
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'"/>
+ <variable name="builddir" select="document($METADATA)//书社vocab:BuildDirectory/@nfo:fileUrl"/>
<template match="/">
<variable name="ids">
<for-each select="//catalog:uri[@name]">
<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="PATH" select="'/unknown'"/>
<xslt:param name="SRCREV" select="false()"/>
<xslt:param name="THISREV" select="false()"/>
<xslt:variable name="书社:source" select="/"/>
<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)!=''">
- <xslt:value-of select="$书社:source/@书社:destination"/>
- </xslt:when>
- <xslt:when test="starts-with($PATH, '/')">
- <xslt:value-of select="substring-after($PATH, '/')"/>
- </xslt:when>
- <xslt:otherwise>
- <xslt:value-of select="$PATH"/>
- </xslt:otherwise>
- </xslt:choose>
- </xslt:variable>
+ <xslt:variable name="书社:destination" select="string($书社:about//*[@rdf:about=$IDENTIFIER]/@书社vocab:destination)"/>
<for-each select="//catalog:uri">
<xslt:include href="{@uri}">
<attribute name="书社:id">
</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="document($METADATA)//*[@rdf:about=$identifier]/dct:hasFormat/*[nie:interpretedAs/*[@nie:mimeType='application/xml']]/@nfo:fileUrl[1]"/>
+ <xslt:variable name="included" select="$书社:about//*[@rdf:about=$identifier]"/>
<xslt:choose>
- <xslt:when test="$uri">
+ <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="expanded">
<xslt:apply-templates select="document($uri)" mode="书社:expand">
<xslt:with-param name="identifier" select="$identifier"/>
-->
<transform
xmlns="http://www.w3.org/1999/XSL/Transform"
- 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#"
extension-element-prefixes="exsl"
version="1.0"
>
- <variable name="builddir" select="//*[@rdf:about='about:shushe?builddir']/@nfo:fileUrl"/>
- <variable name="files" select="/rdf:RDF/nfo:LocalFileDataObject[not(nie:interpretedAs/nfo:Folder)]"/>
+ <variable name="builddir" select="//书社vocab:BuildDirectory/@nfo:fileUrl"/>
+ <variable name="files" select="//书社vocab:SourceFile|//书社vocab:IncludeFile"/>
<template name="书社:process-dependencies">
<param name="processed"/>
<param name="unprocessed"/>
</when>
</choose>
</variable>
- <for-each select="document(concat($builddir, $subdir, @nfo:fileName), .)//书社:link[@xlink:show='embed']">
+ <for-each select="document(concat($builddir, $subdir, @书社vocab:path), .)//书社:link[@xlink:show='embed']">
<if test="exsl:node-set($old)/书社:dependency-root[string()=string(current()/@xlink:href)]">
<书社:recursive-dependency>
<value-of select="$parent"/>
</otherwise>
</choose>
</template>
- <template match="rdf:RDF/nfo:LocalFileDataObject[not(nie:interpretedAs/nfo:Folder or nie:interpretedAs/nfo:PlainTextDocument)]" priority="1">
+ <template match="//书社vocab:SourceFile[not(nie:interpretedAs/nfo:PlainTextDocument)]" priority="1">
<copy>
- <apply-templates select="@*|node()"/>
- <if test="starts-with(@rdf:about, 'about:shushe?source=')">
- <dct:hasFormat>
- <nfo:LocalFileDataObject dct:creator="urn:fdc:ladys.computer:20231231:Shu1She4" nfo:fileName="{substring-after(@rdf:about, 'about:shushe?source=')}"/>
- </dct:hasFormat>
- </if>
+ <apply-templates select="@*"/>
+ <attribute name="书社vocab:destination">
+ <value-of select="@书社vocab:path"/>
+ </attribute>
+ <apply-templates select="node()"/>
</copy>
</template>
- <template match="rdf:RDF/nfo:LocalFileDataObject[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
- <variable name="parsed" select="document(concat($builddir, '/sources/', @nfo:fileName), .)"/>
+ <template match="//书社vocab:SourceFile[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
+ <variable name="parsed" select="document(concat($builddir, '/sources/', @书社vocab:path), .)"/>
<variable name="destination-delim" select="concat('/', $parsed/*/@书社:destination, '/')"/>
<variable name="destination">
<choose>
- <when test="not(starts-with(@rdf:about, 'about:shushe?source='))"/>
<when test="not(contains($destination-delim, '//') or contains($destination-delim, '/./') or contains($destination-delim, '/../'))">
<value-of select="$parsed/*/@书社:destination"/>
</when>
<otherwise>
- <value-of select="substring-after(@rdf:about, 'about:shushe?source=')"/>
+ <value-of select="@书社vocab:path"/>
</otherwise>
</choose>
</variable>
<variable name="dependencies-fragment">
<apply-templates select="." mode="书社:dependencies"/>
</variable>
- <variable name="dependencies" select="exsl:node-set($dependencies)"/>
+ <variable name="dependencies" select="exsl:node-set($dependencies-fragment)"/>
+ <copy>
+ <apply-templates select="@*"/>
+ <attribute name="书社vocab:destination">
+ <value-of select="$destination"/>
+ </attribute>
+ <apply-templates select="node()"/>
+ <for-each select="$dependencies/书社:dependency">
+ <书社vocab:hasDependencyOn rdf:resource="{.}"/>
+ </for-each>
+ <for-each select="$dependencies/书社:recursive-dependency">
+ <书社vocab:hasRecursiveDependencyOn rdf:resource="{.}"/>
+ </for-each>
+ </copy>
+ </template>
+ <template match="//书社vocab:IncludeFile[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
+ <variable name="dependencies-fragment">
+ <apply-templates select="." mode="书社:dependencies"/>
+ </variable>
+ <variable name="dependencies" select="exsl:node-set($dependencies-fragment)"/>
<copy>
<apply-templates select="@*|node()"/>
<for-each select="$dependencies/书社:dependency">
<for-each select="$dependencies/书社:recursive-dependency">
<书社vocab:hasRecursiveDependencyOn rdf:resource="{.}"/>
</for-each>
- <if test="$destination!=''">
- <dct:hasFormat>
- <nfo:LocalFileDataObject dct:creator="urn:fdc:ladys.computer:20231231:Shu1She4" nfo:fileName="{$destination}">
- </nfo:LocalFileDataObject>
- </dct:hasFormat>
- </if>
</copy>
</template>
<template match="@*|node()">
<apply-templates select="@*|node()"/>
</copy>
</template>
- <template match="nfo:LocalFileDataObject" mode="书社:dependencies">
+ <template match="书社vocab:SourceFile|书社vocab:IncludeFile" mode="书社:dependencies">
<if test="nie:interpretedAs/nfo:PlainTextDocument">
<call-template name="书社:process-dependencies">
<with-param name="unprocessed">
version="1.0"
>
<template match="/">
- <for-each select="rdf:RDF/nfo:LocalFileDataObject[nie:interpretedAs/nfo:PlainTextDocument]">
+ <for-each select="rdf:RDF/*[nie:interpretedAs/nfo:PlainTextDocument]">
<value-of select="@rdf:about"/>
<text>
</text>
<for-each select="书社vocab:hasRecursiveDependencyOn/@rdf:resource">
-->
<transform
xmlns="http://www.w3.org/1999/XSL/Transform"
- xmlns:dct="http://purl.org/dc/terms/"
- 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:"
version="1.0"
>
<template match="/">
- <for-each select="/rdf:RDF/nfo:LocalFileDataObject[starts-with(@rdf:about, 'about:shushe?source=')]">
+ <for-each select="//书社vocab:SourceFile">
<value-of select="@rdf:about"/>
<text>|</text>
- <value-of select="dct:hasFormat/nfo:LocalFileDataObject[@dct:creator='urn:fdc:ladys.computer:20231231:Shu1She4']/@nfo:fileName"/>
+ <value-of select="@书社vocab:destination"/>
<text>
</text>
</for-each>
</template>