Note that there are some explanatory texts on larger screens.

plurals
  1. POTransform XML with nested attributes using XSLT
    primarykey
    data
    text
    <p>I have an XML file with layout like this:</p> <pre><code>&lt;root&gt; &lt;node&gt; &lt;descriptors&gt; &lt;attribute attr="important"/&gt; &lt;/descriptors&gt; &lt;value&gt; Some &lt;/value&gt; &lt;value&gt; text &lt;/value&gt; &lt;value&gt; here. &lt;/value&gt; &lt;node&gt; &lt;/root&gt; </code></pre> <p>There are many nodes and each one is differentiated by the elements in the <code>descriptors</code> element. I need to extract the text so that I'd have this:</p> <pre><code>&lt;element&gt; Sometexthere. &lt;/element&gt; </code></pre> <p>I have an xsl transformation:</p> <pre><code>&lt;xsl:template match="//attribute[@attr='important']"&gt; &lt;element&gt; &lt;xsl:for-each select="../../value"&gt; &lt;xsl:value-of select="." /&gt; &lt;/xsl:for-each&gt; &lt;/element&gt; &lt;/xsl:template&gt; </code></pre> <p>This instead just writes all the <code>value</code> elements in every <code>node</code> element in the file. I think I don't really understand the way scoping works (like when <code>.</code> points to the current element/node, but what is the current element/node in the loop).</p> <p>How should I approach this?</p> <p><strong>EDIT</strong></p> <p>My actual xsl stylesheet (I'm transforming a docx file):</p> <pre><code>&lt;xsl:template match="/"&gt; &lt;order&gt; &lt;xsl:apply-templates/&gt; &lt;/order&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/w:document/w:body/w:p[w:pPr/w:pStyle/@w:val='Pealkiri1']"&gt; &lt;name&gt; &lt;xsl:for-each select="w:t"&gt; &lt;xsl:value-of select="." /&gt; &lt;/xsl:for-each&gt; &lt;/name&gt; &lt;/xsl:template&gt; </code></pre>
    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. 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