1.1 --- a/XSLForms/XSL/Input.xsl Sun Oct 16 22:39:02 2005 +0000
1.2 +++ b/XSLForms/XSL/Input.xsl Mon Oct 17 00:14:51 2005 +0000
1.3 @@ -123,21 +123,59 @@
1.4 NOTE: elements are employed, since the only place where keeping them around is
1.5 NOTE: necessary/meaningful is in dynamic element collections. -->
1.6
1.7 - <xsl:for-each select="element">
1.8 - <!-- Define elements which do not have selectors. -->
1.9 - <xsl:variable name="adding-selectors" select="count(//selector[@element=current()/@name])"/>
1.10 + <xsl:call-template name="produce-selection">
1.11 + <xsl:with-param name="path" select="$path"/>
1.12 + <xsl:with-param name="selection" select="concat($path, '/placeholder')"/>
1.13 + <xsl:with-param name="element" select="element[1]"/>
1.14 + </xsl:call-template>
1.15 +
1.16 + </xsl:template>
1.17 +
1.18 +
1.19 +
1.20 + <!-- Produce a selection of collection/dynamic elements.
1.21 + This should produce an apply-templates instruction selecting dynamic elements.
1.22 + For example:
1.23 + ./placeholder|./some-element|./some-other-element -->
1.24 +
1.25 + <xsl:template name="produce-selection">
1.26 + <xsl:param name="path"/>
1.27 + <xsl:param name="selection"/>
1.28 + <xsl:param name="element"/>
1.29
1.30 - <xsl:choose>
1.31 - <!-- Enumerations added first - see above. -->
1.32 - <xsl:when test="@type='multiple-choice-value' or @type='multiple-choice-list-value'"/>
1.33 - <!-- Added elements added first - see above. -->
1.34 - <xsl:when test="(not(@init) or @init = 'auto') and $adding-selectors = 0 or @init = 'yes'"/>
1.35 - <!-- Other elements are only added if found. -->
1.36 - <xsl:otherwise>
1.37 - <axsl:apply-templates select="{$path}/{@name}|{$path}/placeholder"/>
1.38 - </xsl:otherwise>
1.39 - </xsl:choose>
1.40 - </xsl:for-each>
1.41 + <xsl:choose>
1.42 + <!-- After processing all elements, produce the selection instruction. -->
1.43 + <xsl:when test="not($element)">
1.44 + <axsl:apply-templates select="{$selection}"/>
1.45 + </xsl:when>
1.46 + <!-- Otherwise, process the remaining elements. -->
1.47 + <xsl:otherwise>
1.48 +
1.49 + <!-- Define elements which do not have selectors. -->
1.50 + <xsl:variable name="adding-selectors" select="count(//selector[@element=$element/@name])"/>
1.51 +
1.52 + <xsl:choose>
1.53 + <!-- Do not select added elements or enumerations - see process-elements. -->
1.54 + <xsl:when test="((not($element/@init) or $element/@init = 'auto') and $adding-selectors = 0 or $element/@init = 'yes')
1.55 + or (@type='multiple-choice-value' or @type='multiple-choice-list-value')">
1.56 + <xsl:call-template name="produce-selection">
1.57 + <xsl:with-param name="path" select="$path"/>
1.58 + <xsl:with-param name="selection" select="$selection"/>
1.59 + <xsl:with-param name="element" select="$element/following-sibling::element[1]"/>
1.60 + </xsl:call-template>
1.61 + </xsl:when>
1.62 + <!-- Other elements are only added if found. -->
1.63 + <xsl:otherwise>
1.64 + <xsl:call-template name="produce-selection">
1.65 + <xsl:with-param name="path" select="$path"/>
1.66 + <xsl:with-param name="selection" select="concat($selection, '|', $path, '/', $element/@name)"/>
1.67 + <xsl:with-param name="element" select="$element/following-sibling::element[1]"/>
1.68 + </xsl:call-template>
1.69 + </xsl:otherwise>
1.70 + </xsl:choose>
1.71 +
1.72 + </xsl:otherwise>
1.73 + </xsl:choose>
1.74 </xsl:template>
1.75
1.76