+ <variable name="children" select="exsl:node-set($children-fragment)/*"/>
+ <variable name="child-paths-fragment">
+ <for-each select="$children">
+ <choose>
+ <when test="self::书社:recursive-dependency">
+ <书社:dependency-path>
+ <copy-of select="$path/*[string()=current()][1]/preceding-sibling::*"/>
+ <copy-of select="."/><!-- replace first instance with recursive dependency -->
+ </书社:dependency-path>
+ </when>
+ <when test="$parent/self::书社:transitive-soft-dependency and string(@name)!=string($parent/@name)"/>
+ <when test="self::书社:soft-dependency">
+ <书社:dependency-path>
+ <copy-of select="$path"/>
+ <copy-of select="."/>
+ </书社:dependency-path>
+ </when>
+ <otherwise>
+ <variable name="path-fragment">
+ <copy-of select="$path"/>
+ <choose>
+ <when test="self::书社:dependency and $path/书社:transitive-soft-dependency">
+ <书社:transitive-soft-dependency name="{@name}">
+ <value-of select="."/>
+ </书社:transitive-soft-dependency>
+ </when>
+ <otherwise>
+ <copy-of select="."/>
+ </otherwise>
+ </choose>
+ </variable>
+ <call-template name="书社:collect-dependency-paths">
+ <with-param name="path" select="exsl:node-set($path-fragment)"/>
+ </call-template><!-- a little inefficient in the case of reflexive dependencies, as the path will be traversed once in each direction, but improving on this is a hard problem in X·S·L·T -->
+ </otherwise>
+ </choose>
+ </for-each>
+ </variable>
+ <variable name="child-paths" select="exsl:node-set($child-paths-fragment)/*"/>