<transform
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
+ xmlns:exslstr="http://exslt.org/strings"
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:xlink="http://www.w3.org/1999/xlink"
xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
xmlns:书社vocab="urn:fdc:ladys.computer:20231231:Shu1She4:vocab:"
- extension-element-prefixes="exsl"
+ extension-element-prefixes="exsl exslstr"
version="1.0"
>
<variable name="builddir" select="//书社vocab:BuildDirectory/@nfo:fileUrl"/>
<template match="//书社vocab:SourceFile[not(nie:interpretedAs/nfo:PlainTextDocument)]" priority="1">
<copy>
<apply-templates select="@*"/>
- <attribute name="书社vocab:destination">
- <value-of select="@书社vocab:path"/>
- </attribute>
<apply-templates select="node()"/>
+ <element name="书社vocab:destination">
+ <value-of select="@书社vocab:path"/>
+ </element>
</copy>
</template>
<template match="//书社vocab:SourceFile[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
<variable name="parsed" select="document(书社vocab:hasParsedFile/@nfo:fileUrl)"/>
- <variable name="destination-delim" select="concat('/', $parsed/*/@书社:destination, '/')"/>
- <variable name="destination">
- <choose>
- <when test="not(contains($destination-delim, '//') or contains($destination-delim, '/./') or contains($destination-delim, '/../'))">
- <value-of select="$parsed/*/@书社:destination"/>
- </when>
- <otherwise>
- <value-of select="@书社vocab:path"/>
- </otherwise>
- </choose>
+ <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="@*"/>
- <attribute name="书社vocab:destination">
- <value-of select="$destination"/>
- </attribute>
<apply-templates select="node()"/>
<for-each select="$dependencies/书社:dependency">
<书社vocab:hasDependencyOn rdf:resource="{.}"/>
<for-each select="$dependencies/书社:recursive-dependency">
<书社vocab:hasRecursiveDependencyOn rdf:resource="{.}"/>
</for-each>
+ <choose>
+ <when test="not($destinations)">
+ <element name="书社vocab:destination">
+ <value-of select="@书社vocab:path"/>
+ </element>
+ </when>
+ <when test="$bad-destinations">
+ <message terminate="no">
+ <text>Bad destinations: </text>
+ <for-each select="$bad-destinations">
+ <if test="position()>1">
+ <text> </text>
+ </if>
+ <text><</text>
+ <value-of select="."/>
+ <text>></text>
+ </for-each>
+ </message>
+ <element name="书社vocab:destination">
+ <value-of select="@书社vocab:path"/>
+ </element>
+ </when>
+ <otherwise>
+ <for-each select="$destinations">
+ <element name="书社vocab:destination">
+ <value-of select="."/>
+ </element>
+ </for-each>
+ </otherwise>
+ </choose>
</copy>
</template>
<template match="//书社vocab:IncludeFile[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
<for-each select="$result//书社vocab:SourceFile">
<value-of select="@rdf:about"/>
<text>|</text>
- <value-of select="@书社vocab:destination"/>
+ <for-each select="书社vocab:destination">
+ <if test="position()>1">
+ <text>;</text>
+ </if>
+ <value-of select="."/>
+ </for-each>
<text>
</text>
</for-each>
</exsl:document>