- <template match="rdf:RDF/nfo:LocalFileDataObject[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
- <variable name="parsed" select="document(concat($builddir, '/sources/', @nfo:fileName), .)"/>
- <variable name="destination-delim" select="concat('/', $parsed/*/@书社:destination, '/')"/>
- <variable name="destination">
+ <template match="//书社vocab:SourceFile[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
+ <variable name="parsed" select="document(书社vocab:hasParsedFile/@nfo:fileUrl)"/>
+ <variable name="provided-destinations" select="normalize-space($parsed/*/@书社:destination)"/>
+ <variable name="destinations-fragment">
+ <if test="$provided-destinations!=''">
+ <for-each select="exslstr:tokenize($provided-destinations)">
+ <element name="书社vocab:destination">
+ <value-of select="."/>
+ </element>
+ </for-each>
+ </if>
+ </variable>
+ <variable name="dependencies-fragment">
+ <apply-templates select="." mode="书社:dependencies"/>
+ </variable>
+ <variable name="dependencies" select="exsl:node-set($dependencies-fragment)"/>
+ <variable name="destinations" select="exsl:node-set($destinations-fragment)/node()"/>
+ <variable name="bad-destinations-fragment">
+ <for-each select="$destinations">
+ <variable name="destination-delim" select="concat('/', ., '/')"/>
+ <if test="contains($destination-delim, '//') or contains($destination-delim, '/./') or contains($destination-delim, '/../')">
+ <copy-of select="."/>
+ </if>
+ </for-each>
+ </variable>
+ <variable name="bad-destinations" select="exsl:node-set($bad-destinations-fragment)/node()"/>
+ <copy>
+ <apply-templates select="@*"/>
+ <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>