Note that there are some explanatory texts on larger screens.

plurals
  1. POXSL - Is there a way I can make this template reusable?
    primarykey
    data
    text
    <p>XSL noob here :-)</p> <p>I've got the following template which is being used to produce a dropdown for my ANT script. </p> <pre><code> &lt;!-- Dropdown templates --&gt; &lt;xsl:template name="componentDropdown"&gt; &lt;xsl:text&gt;trunk&lt;/xsl:text&gt; &lt;!-- Branch Data --&gt; &lt;xsl:for-each select="document('../../../temp/components_branches.xml')/lists/list/entry"&gt; &lt;xsl:sort select="commit/@revision" order="descending" /&gt; &lt;xsl:text&gt;;branches/&lt;/xsl:text&gt; &lt;xsl:value-of select="name" /&gt; &lt;/xsl:for-each&gt; &lt;!-- Tag Data --&gt; &lt;xsl:for-each select="document('../../../temp/components_tags.xml')/lists/list/entry"&gt; &lt;xsl:sort select="commit/@revision" order="descending" /&gt; &lt;xsl:if test="name != 'archive'"&gt; &lt;xsl:text&gt;;tags/&lt;/xsl:text&gt; &lt;xsl:value-of select="name" /&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; </code></pre> <p>The thing is that I've got this three times over - cut &amp; paste job - all the same but the reference to "components" is being swapped for "plugins" and "website". We've got a few more ANT scripts I'd like to migrate to this as well so ideally I'd like this as a reusable function-based template of some kind. </p> <p>Working in progress but I've currently got the following:-</p> <pre><code> &lt;xsl:template name="dropdown"&gt; &lt;xsl:param name="type"&gt;website&lt;/xsl:param&gt; &lt;xsl:param name="path"&gt;&lt;/xsl:param&gt; &lt;!-- Branch Data --&gt; &lt;xsl:text&gt;&lt;xsl:value-of select="$path" /&gt;&lt;/xsl:text&gt; &lt;xsl:for-each select="document(concat('../../../temp/{$type}_tags.xml',''))/lists/list/entry"&gt; &lt;xsl:sort select="commit/@revision" order="descending" /&gt; &lt;xsl:text&gt;;branches/&lt;/xsl:text&gt; &lt;xsl:value-of select="name" /&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; </code></pre> <p>The issue seems to be getting the documnet() function to accept dynamic variables. </p> <p>Only other thing I can say is the XSL is declared as 1.0. I don't know if that makes a difference but any pointers are appreciated :).</p> <p>Cheers, James</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload