Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT 1.0 variant for distinct-values
    primarykey
    data
    text
    <p>I have an XSLT in which I create (from the input data) intermediary variables like the following (hard-coded example, but dynamic in nature):</p> <pre><code>&lt;xsl:variable name="variableX"&gt; &lt;ValidCode CodePart="CP1" Code="C1"/&gt; &lt;ValidCode CodePart="CP2" Code="C2"/&gt; &lt;ValidCode CodePart="CP1" Code="C3"/&gt; &lt;ValidCode CodePart="CP2" Code="C4"/&gt; &lt;ValidCode CodePart="CP2" Code="C5"/&gt; &lt;/xsl:variable&gt; </code></pre> <p>I wish to loop over the distinct occurrences of CodePart values. In XSLT 2.0 it's easy:</p> <pre><code>&lt;xsl:for-each select="distinct-values($variableX/ValidCode/@CodePart)"&gt;...&lt;/xsl:for-each&gt; </code></pre> <p>But how best do this in XSLT 1.0?<br> Note that I can't use a key, as it's a dynamically determined variable and not part of the input file.</p> <p>My input file does contain a list of all possible code parts as follows:</p> <pre><code>&lt;root&gt; &lt;CodePart&gt;&lt;value&gt;CP1&lt;/value&gt;&lt;/CodePart&gt; &lt;CodePart&gt;&lt;value&gt;CP2&lt;/value&gt;&lt;/CodePart&gt; &lt;CodePart&gt;&lt;value&gt;CP3&lt;/value&gt;&lt;/CodePart&gt; &lt;/root&gt; </code></pre> <p>So I thought of looping over <code>//CodePart/value</code> instead, ensuring uniqueness for starters. But then I need some Xpath expression that includes the condition </p> <p>"value occurs in the node-set of all $variableX/ValidCode/@CodePart values"</p> <p>and use something like</p> <pre><code>&lt;xsl:for-each select="//CodePart[..condition..]/value"&gt;...&lt;/xsl:for-each&gt; </code></pre> <p>Is there a simple form of the Xpath expression I am looking for?<br> Or is another approach preferable?</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.
 

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