Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT add parent node name as element in child node
    primarykey
    data
    text
    <p><em><strong>Input</em></strong></p> <pre><code>&lt;root&gt; &lt;category1&gt; &lt;node&gt; &lt;subnode&gt;value&lt;/subnode&gt; &lt;/node&gt; &lt;/category1&gt; &lt;category2&gt; &lt;node&gt; &lt;subnode&gt;value&lt;/subnode&gt; &lt;/node&gt; &lt;/category2&gt; &lt;/root&gt; </code></pre> <p><em><strong>Output</em></strong></p> <pre><code>&lt;root&gt; &lt;node&gt; &lt;subnode&gt;value&lt;/subnode&gt; &lt;/category1&gt; &lt;/node&gt; &lt;node&gt; &lt;subnode&gt;value&lt;/subnode&gt; &lt;/category2&gt; &lt;/node&gt; &lt;/root&gt; </code></pre> <p>Or</p> <pre><code>&lt;root&gt; &lt;node&gt; &lt;subnode&gt;value&lt;/subnode&gt; &lt;status&gt;category1&lt;/status&gt; &lt;/node&gt; &lt;node&gt; &lt;subnode&gt;value&lt;/subnode&gt; &lt;status&gt;category2&lt;/status&gt; &lt;/node&gt; &lt;/root&gt; </code></pre> <p><em><strong>Attempt</em></strong></p> <pre><code>&lt;xsl:template match="//node"&gt; &lt;xsl:copy&gt; &lt;xsl:copy-of select="child::node()" /&gt; &lt;xsl:copy-of select=".." /&gt; &lt;!-- Why isn't something like this possible? &lt;xsl:copy-of select="ancestor::local-name()"/&gt; --&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; </code></pre> <p><em><strong>Details</em></strong></p> <p>Hopefully, the above was clear enough :). </p> <p><hr><hr></p> <p><em><strong>Additional Details (Optional)</em></strong></p> <p>For those feeling especially generous this Christmas I invite you to continue reading :D. </p> <p>I'm having some trouble learning XSLT and feel like I'm missing some general/syntactical concepts but I also need to do some 'complicated' transforms. For example:</p> <p><em><strong>Input</em></strong></p> <pre><code>&lt;root&gt; &lt;category1&gt; &lt;node&gt; &lt;name&gt;category1 node pk&lt;/name&gt; &lt;/node&gt; &lt;/category1&gt; &lt;groups&gt; &lt;node&gt; &lt;name&gt;First Group&lt;/name&gt; &lt;members&gt; &lt;name&gt;category1 node pk&lt;/name&gt; &lt;/members&gt; &lt;/node&gt; &lt;node&gt; &lt;name&gt;Second Group&lt;/name&gt; &lt;members&gt; &lt;name&gt;category1 node pk&lt;/name&gt; &lt;/members&gt; &lt;/node&gt; &lt;/groups&gt; &lt;/root&gt; </code></pre> <p><em><strong>Output</em></strong></p> <pre><code>&lt;root&gt; &lt;node&gt; &lt;name&gt;category1 node pk&lt;/name&gt; &lt;group&gt;All&lt;/group&gt; &lt;status&gt;category1&lt;/status&gt; &lt;/node&gt; &lt;node&gt; &lt;name&gt;category1 node pk&lt;/name&gt; &lt;group&gt;First Group&lt;/group&gt; &lt;status&gt;category1&lt;/status&gt; &lt;/node&gt; &lt;node&gt; &lt;name&gt;category1 node pk&lt;/name&gt; &lt;group&gt;Second Group&lt;/group&gt; &lt;status&gt;category1&lt;/status&gt; &lt;/node&gt; &lt;/root&gt; </code></pre> <p>So for the XSLT experts out there what I would like to know is how you went about learning <strong><em>XSLT 1.0</em></strong>? Especially to deal with more complicated transforms. </p> <p>Are there any books or tutorials that you found especially useful?</p> <p>Finally how long do you think it would take for someone new to become proficient enough to pull off the above transform w/o help?</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