]> Lady’s Gitweb - Shushe/blobdiff - lib/expandmetadata.xslt
Support multiple destinations
[Shushe] / lib / expandmetadata.xslt
index 027aaa74d4b2ae67dd131efc179c9d7ca6ca8f1b..423924a3d35eb889c8ab4bd46e46a937e6d54c02 100644 (file)
@@ -14,13 +14,14 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:exsl="http://exslt.org/common"
 <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:"
        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"/>
        version="1.0"
 >
        <variable name="builddir" select="//书社vocab:BuildDirectory/@nfo:fileUrl"/>
@@ -89,34 +90,40 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="//书社vocab:SourceFile[not(nie:interpretedAs/nfo:PlainTextDocument)]" priority="1">
                <copy>
                        <apply-templates select="@*"/>
        <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()"/>
                        <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)"/>
                </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>
                <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="@*"/>
                <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="{.}"/>
                        <apply-templates select="node()"/>
                        <for-each select="$dependencies/书社:dependency">
                                <书社vocab:hasDependencyOn rdf:resource="{.}"/>
@@ -124,6 +131,36 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        <for-each select="$dependencies/书社:recursive-dependency">
                                <书社vocab:hasRecursiveDependencyOn rdf:resource="{.}"/>
                        </for-each>
                        <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>&lt;</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">
                </copy>
        </template>
        <template match="//书社vocab:IncludeFile[nie:interpretedAs/nfo:PlainTextDocument]" priority="1">
@@ -169,7 +206,12 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        <for-each select="$result//书社vocab:SourceFile">
                                <value-of select="@rdf:about"/>
                                <text>|</text>
                        <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>&#xA;</text>
                        </for-each>
                </exsl:document>
                                <text>&#xA;</text>
                        </for-each>
                </exsl:document>
This page took 0.258417 seconds and 4 git commands to generate.