Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>This transformation</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes"/&gt; &lt;xsl:template match="table"&gt; &lt;xsl:for-each select="tr[1]/td"&gt; &lt;xsl:variable name="vRowPos" select="position()"/&gt; &lt;tr&gt; &lt;xsl:for-each select="/table/tr"&gt; &lt;xsl:variable name="vColPos" select="position()"/&gt; &lt;xsl:copy-of select="/table/tr[$vColPos]/td[$vRowPos]"/&gt; &lt;/xsl:for-each&gt; &lt;/tr&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on this XML document</strong>:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;A11&lt;/td&gt; &lt;td&gt;A12&lt;/td&gt; &lt;td&gt;A13&lt;/td&gt; &lt;td&gt;A14&lt;/td&gt; &lt;td&gt;A15&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;A21&lt;/td&gt; &lt;td&gt;A22&lt;/td&gt; &lt;td&gt;A23&lt;/td&gt; &lt;td&gt;A24&lt;/td&gt; &lt;td&gt;A25&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;A31&lt;/td&gt; &lt;td&gt;A32&lt;/td&gt; &lt;td&gt;A33&lt;/td&gt; &lt;td&gt;A34&lt;/td&gt; &lt;td&gt;A35&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p><strong>produces the wanted, correct results</strong>:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;A11&lt;/td&gt; &lt;td&gt;A21&lt;/td&gt; &lt;td&gt;A31&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;A12&lt;/td&gt; &lt;td&gt;A22&lt;/td&gt; &lt;td&gt;A32&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;A13&lt;/td&gt; &lt;td&gt;A23&lt;/td&gt; &lt;td&gt;A33&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;A14&lt;/td&gt; &lt;td&gt;A24&lt;/td&gt; &lt;td&gt;A34&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;A15&lt;/td&gt; &lt;td&gt;A25&lt;/td&gt; &lt;td&gt;A35&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p><strong>Do note</strong>: The assumption is that the table has <em>regular</em> structure.</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