Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with xsl:for-each
    primarykey
    data
    text
    <p>I must be missing some fundamental concept of processing an XML document. Here is my source XML:</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;Root&gt; &lt;Element&gt;visitorNameAlt&lt;/Element&gt; &lt;Element&gt;visitorScore&lt;/Element&gt; &lt;Element&gt;visitorTimeouts&lt;/Element&gt; &lt;Element&gt;Blank&lt;/Element&gt; &lt;Element&gt;homeNameAlt&lt;/Element&gt; &lt;Element&gt;homeScore&lt;/Element&gt; &lt;Element&gt;homeTimeouts&lt;/Element&gt; &lt;Element&gt;Blank&lt;/Element&gt; &lt;Element&gt;period&lt;/Element&gt; &lt;Element&gt;optionalText&lt;/Element&gt; &lt;Element&gt;flag&lt;/Element&gt; &lt;Element&gt;Blank&lt;/Element&gt; &lt;Element&gt;scoreLogo&lt;/Element&gt; &lt;Element&gt;sponsorLogo&lt;/Element&gt; &lt;/Root&gt; </code></pre> <p>And my XSL stylesheet:</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" version="1.0" indent="yes"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:for-each select="/Root"&gt; &lt;xsl:value-of select="position()"/&gt; &lt;xsl:value-of select="Element"/&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>All I want is to pluck the "Element" names from the source XML doc with their relative position in front.</p> <p>My output is just "1" followed by the first element and nothing more.</p> <p>I am new to XSLT, but have processed other documents successfully with for-each.</p> <p>Thanks in advance.</p> <p>Bill</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.
 

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