Note that there are some explanatory texts on larger screens.

plurals
  1. POList a given attribute of specific child elements
    text
    copied!<p>I have some XML code that looks like this</p> <pre><code>&lt;SEARCHRESULTS&gt; &lt;FUNCTION name="BarGraph"&gt; &lt;PARAMETER name="numList"&gt;&lt;/PARAMETER&gt; &lt;PARAMETER name="maxValue"&gt;&lt;/PARAMETER&gt; &lt;CODE&gt;Some code&lt;/CODE&gt; &lt;/FUNCTION&gt; &lt;/SEARCHRESULTS&gt; </code></pre> <p>And I want to extract a list of parameter names for each function, so far I've got the following xsl code</p> <pre><code>&lt;xsl:for-each select="SEARCHRESULTS/FUNCTION"&gt; &lt;ROW&gt; &lt;COL&gt;&lt;DATA&gt;&lt;xsl:value-of select="@name" /&gt;&lt;/DATA&gt;&lt;/COL&gt; &lt;COL&gt;&lt;DATA&gt;&lt;xsl:value-of select="PARAMETER/@name" /&gt;&lt;/DATA&gt;&lt;/COL&gt; &lt;COL&gt;&lt;DATA&gt;&lt;xsl:value-of select="CODE" /&gt;&lt;/DATA&gt;&lt;/COL&gt; &lt;/ROW&gt; &lt;/xsl:for-each&gt; </code></pre> <p>which of course returns the name of the first parameter along with the function name and code.</p> <p>I want a list of all the parameters for the function in a text string. Return separated is best, but as long as all the names are in the string I can parse it later on.</p> <p>I could normalise the parameter records out in the target database - but I'm not going to, I just need them for display purposes really so I don't want to put too much effort in. This is why I'm looking for a simple text string.</p> <p>I thought there might be some way of just putting an asterisk in or something. If not I'll create a variable and add another for-each to build a string - but it just seems like there should be a simpler way</p> <p>The resulting XML should look like</p> <pre><code>&lt;ROW&gt; &lt;COL&gt;&lt;DATA&gt;BarGraph&lt;/DATA&gt;&lt;/COL&gt; &lt;COL&gt;&lt;DATA&gt;numList;maxValue&lt;/DATA&gt;&lt;/COL&gt; &lt;COL&gt;&lt;DATA&gt;Some code&lt;/DATA&gt;&lt;/COL&gt; &lt;/ROW&gt; </code></pre> <p>Where the ';' in the second column could be a carriage return or another character that I can specify</p>
 

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