Last active
September 22, 2021 06:47
-
-
Save dmj/065fc4559d51eb8d46c15187a6e57bf3 to your computer and use it in GitHub Desktop.
Simple XProc 3.0 pipeline for publishing letters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p:declare-step version="3.0" name="main" | |
xmlns:c="http://www.w3.org/ns/xproc-step" | |
xmlns:p="http://www.w3.org/ns/xproc" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |
<p:output port="result" sequence="true"/> | |
<p:variable name="targetDirectory" as="xs:string" select="resolve-uri('../../export/publish/', static-base-uri())"/> | |
<p:file-delete href="{$targetDirectory}" recursive="true" fail-on-error="false"/> | |
<p:directory-list path="../../daten/brief" max-depth="3"/> | |
<p:xslt> | |
<p:with-input port="stylesheet"> | |
<xsl:transform version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:mode on-no-match="shallow-copy"/> | |
<xsl:template match="c:file"> | |
<xsl:copy> | |
<xsl:sequence select="@*"/> | |
<xsl:attribute name="path" select="string-join(ancestor-or-self::*/@name, '/')"/> | |
<xsl:sequence select="node()"/> | |
</xsl:copy> | |
</xsl:template> | |
</xsl:transform> | |
</p:with-input> | |
</p:xslt> | |
<p:delete match="c:file[@name = 'transcript.xml']"/> | |
<p:viewport match="c:file[@name = 'content.xml']" name="prepare-content"> | |
<p:group name="load-content"> | |
<p:output port="result"/> | |
<p:load href="{resolve-uri(c:file/@name, base-uri(c:file))}"/> | |
<p:xslt> | |
<p:with-input port="stylesheet" href="publish-tei.xsl"/> | |
</p:xslt> | |
</p:group> | |
<p:insert match="c:file" position="first-child"> | |
<p:with-input port="insertion" pipe="result@load-content"/> | |
<p:with-input port="source" pipe="current@prepare-content"/> | |
</p:insert> | |
</p:viewport> | |
<p:viewport match="c:file"> | |
<p:variable name="target" as="xs:string" select="resolve-uri(c:file/@path, $targetDirectory)"/> | |
<p:choose> | |
<p:when test="empty(c:file/*)"> | |
<p:file-copy href="{resolve-uri(c:file/@name, base-uri(c:file))}" target="{$target}"/> | |
</p:when> | |
<p:otherwise> | |
<p:unwrap/> | |
<p:store href="{$target}"/> | |
</p:otherwise> | |
</p:choose> | |
</p:viewport> | |
<p:sink/> | |
</p:declare-step> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment