- <template name="书社:process-dependencies">
- <param name="processed"/>
- <param name="unprocessed"/>
- <variable name="queue">
- <copy-of select="exsl:node-set($unprocessed)/书社:dependency-root"/>
- <for-each select="exsl:node-set($unprocessed)/书社:dependency">
- <if test="not((exsl:node-set($processed)/书社:*|preceding-sibling::书社:*|following-sibling::书社:recursive-dependency)[string()=string(current())])">
- <copy-of select="."/>
- </if>
- </for-each>
- </variable>
- <variable name="old">
- <copy-of select="exsl:node-set($processed)/书社:dependency-root"/>
- <copy-of select="exsl:node-set($processed)/书社:recursive-dependency"/>
- <for-each select="exsl:node-set($unprocessed)/书社:recursive-dependency">
- <if test="not((exsl:node-set($processed)/书社:recursive-dependency|preceding-sibling::书社:recursive-dependency)[string()=string(current())])">
- <copy-of select="."/>
- </if>
- </for-each>
- <for-each select="exsl:node-set($processed)/书社:dependency">
- <if test="not(exsl:node-set($unprocessed)/书社:recursive-dependency[string()=string(current())])">
- <copy-of select="."/>
- </if>
- </for-each>
- <copy-of select="$queue"/>
- </variable>
- <variable name="new">
- <for-each select="exsl:node-set($queue)/书社:*">
- <for-each select="$files[@rdf:about=string(current()) and nie:interpretedAs/nfo:PlainTextDocument]">
- <variable name="parent" select="@rdf:about"/>
- <variable name="uri" select="书社vocab:hasParsedFile/@nfo:fileUrl"/>
- <for-each select="document($uri)//书社:link[@xlink:show='embed']">
- <if test="exsl:node-set($old)/书社:dependency-root[string()=string(current()/@xlink:href)]">
- <书社:recursive-dependency>
- <value-of select="$parent"/>
+ <variable name="stated-dependencies-fragment">
+ <for-each select="$files[nie:interpretedAs/nfo:PlainTextDocument]">
+ <variable name="uri" select="书社vocab:hasParsedFile/@nfo:fileUrl"/>
+ <书社:Dependencies for="{@rdf:about}">
+ <for-each select="document($uri)//书社:link">
+ <variable name="spaced-show">
+ <choose>
+ <when test="@xlink:show">
+ <text> </text>
+ <value-of select="@xlink:show"/>
+ <text> </text>
+ </when>
+ <otherwise>
+ <text> none </text>
+ </otherwise>
+ </choose>
+ </variable>
+ <variable name="actuate">
+ <choose>
+ <when test="@xlink:actuate">
+ <value-of select="@xlink:actuate"/>
+ </when>
+ <otherwise>
+ <text>none</text><!-- not the true default in all cases, but in the ones that matter -->
+ </otherwise>
+ </choose>
+ </variable>
+ <variable name="name" select="string(@name)"/>
+ <if test="contains(' embed other none ', $spaced-show) and $actuate='none'">
+ <variable name="identifier" select="string(@xlink:href)"/>
+ <variable name="is-dir" select="substring($identifier, string-length($identifier))='/'"/>
+ <for-each select="$files/@rdf:about[string(.)=$identifier or $is-dir and starts-with(., $identifier)]">
+ <sort select="." data-type="text" lang="zxx" case-order="upper-first"/>
+ <choose>
+ <when test="$spaced-show=' embed '">
+ <书社:dependency name="{$name}">
+ <value-of select="."/>
+ </书社:dependency>
+ </when>
+ <when test="$spaced-show=' other '">
+ <书社:transitive-soft-dependency name="{$name}">
+ <value-of select="."/>
+ </书社:transitive-soft-dependency>
+ </when>
+ <otherwise>
+ <书社:soft-dependency name="{$name}">
+ <value-of select="."/>
+ </书社:soft-dependency>
+ </otherwise>
+ </choose>
+ </for-each>
+ </if>
+ </for-each>
+ </书社:Dependencies>
+ </for-each>
+ </variable>
+ <variable name="stated-dependencies" select="exsl:node-set($stated-dependencies-fragment)/*"/>
+ <template name="书社:collect-dependency-paths">
+ <param name="path" select="/.."/>
+ <variable name="parent" select="$path/*[last()]"/>
+ <variable name="children-fragment">
+ <for-each select="$stated-dependencies[@for=string($parent)]/*">
+ <choose>
+ <when test="$path/*[string()=current()]">
+ <if test="self::书社:dependency">
+ <书社:recursive-dependency name="{@name}">
+ <value-of select="."/>