Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you just want to make the code more readable, then I'd suggest something simple, like:</p> <pre><code>&lt;!-- expected columns --&gt; &lt;xsl:variable name="NAME" value="1" /&gt; &lt;xsl:variable name="LOCATION" value="2" /&gt; &lt;!-- ... --&gt; &lt;people&gt; &lt;xsl:for-each select="fm:FMPXMLRESULT/fm:RESULTSET/fm:ROW"&gt; &lt;person&gt; &lt;name&gt; &lt;xsl:value-of select="fm:COL[$NAME]/fm:DATA"/&gt; &lt;/name&gt; &lt;location&gt; &lt;xsl:value-of select="fm:COL[$LOCATION]/fm:DATA"/&gt; &lt;/location&gt; &lt;/person&gt; &lt;/xsl:for-each&gt; &lt;/people&gt; </code></pre> <p>BTW, with <code>&lt;xsl:value-of /&gt;</code> you can omit the <code>fm:DATA</code>, i.e. use:</p> <pre><code>&lt;xsl:value-of select="fm:COL[$LOCATION] /&gt; </code></pre> <p>It will return the same result.</p> <p>If you need something more sophisticated, please explain.</p> <p><strong>Update:</strong></p> <p>To refer to columns by column names is harder, but possible with something like that:</p> <pre><code>&lt;!-- Define a key to get a field and all fields that precede it by the field name --&gt; &lt;xsl:key name="N" match="/fm:FMPXMLRESULT/fm:METADATA/fm:FIELD" use="@NAME" /&gt; &lt;xsl:key name="N" match="/fm:FMPXMLRESULT/fm:METADATA/fm:FIELD" use="following-sibling::fm:FIELD/@NAME" /&gt; &lt;!-- Then *count* them it in the code like that --&gt; &lt;people&gt; &lt;xsl:for-each select="fm:FMPXMLRESULT/fm:RESULTSET/fm:ROW"&gt; &lt;person&gt; &lt;name&gt; &lt;xsl:value-of select="fm:COL[count(key('N', 'name'))]" /&gt; &lt;/name&gt; &lt;location&gt; &lt;xsl:value-of select="fm:COL[count(key('N', 'location'))]" /&gt; &lt;/location&gt; &lt;/person&gt; &lt;/xsl:for-each&gt; &lt;/people&gt; </code></pre> <p>Not utterly elegant, but works.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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