Note that there are some explanatory texts on larger screens.

plurals
  1. POXSL outputting more than expected
    primarykey
    data
    text
    <p>I'm fairly new to XSLT and XPath and have been banging my head against the wall for a while on this problem.</p> <p>I have the following XML:</p> <pre><code>&lt;reply&gt; &lt;multi-results&gt; &lt;multi-item&gt; &lt;name&gt;node1&lt;/name&gt; &lt;information&gt; &lt;block&gt; &lt;slot&gt;A&lt;/slot&gt; &lt;state&gt;Online&lt;/state&gt; &lt;colour&gt;purple&lt;/colour&gt; &lt;/block&gt; &lt;block&gt; &lt;slot&gt;B&lt;/slot&gt; &lt;state&gt;Online&lt;/state&gt; &lt;colour&gt;yellow&lt;/colour&gt; &lt;/block&gt; &lt;block&gt; &lt;slot&gt;C&lt;/slot&gt; &lt;state&gt;Online&lt;/state&gt; &lt;colour&gt;red&lt;/colour&gt; &lt;/block&gt; &lt;block&gt; &lt;slot&gt;D&lt;/slot&gt; &lt;state&gt;Online&lt;/state&gt; &lt;colour&gt;blue&lt;/colour&gt; &lt;/block&gt; &lt;/information&gt; &lt;/multi-item&gt; &lt;/multi-results&gt; &lt;address&gt; &lt;label&gt;this is an arbitrary bit of text included for this example&lt;/label&gt; &lt;/address&gt; &lt;/reply&gt; </code></pre> <p>There are a variable number of "block" entries per file.</p> <p>I want to "CSV" the data, and I'm using the following XSL:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="text"/&gt; &lt;xsl:template match="*/text()[normalize-space()]"&gt; &lt;xsl:value-of select="normalize-space()"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="*/text()[not(normalize-space())]" /&gt; &lt;xsl:template match="block"&gt; &lt;xsl:value-of select="slot"/&gt; &lt;xsl:text&gt;|&lt;/xsl:text&gt; &lt;xsl:value-of select="state"/&gt; &lt;xsl:text&gt;|&lt;/xsl:text&gt; &lt;xsl:value-of select="colour"/&gt; &lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Output:</p> <pre><code>node1A|Online|purple B|Online|yellow C|Online|red D|Online|blue this is an arbitrary bit of text included for this example </code></pre> <p>However, the output includes both the "name" and the "label"... </p> <p>I want only what I'm explicitly asking for in the XSL:</p> <pre><code>A|Online|purple B|Online|yellow C|Online|red D|Online|blue </code></pre> <p>I don't understand why. Can someone explain please?</p> <p>Also, there may be multiple "name" elements, each with its own number of "block" elements.</p> <p>Many thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    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