Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This should help you to get started. I am aware that your actual XML input is more complex than that, but this produces exactly the output you describe (for the look-at-this-if-you-are-feeling-generous part).</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" indent="yes"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="root"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="category1"&gt; &lt;node&gt; &lt;name&gt; &lt;xsl:value-of select="node/name"/&gt; &lt;/name&gt; &lt;group&gt; &lt;xsl:text&gt;ALL&lt;/xsl:text&gt; &lt;/group&gt; &lt;status&gt; &lt;xsl:text&gt;category1&lt;/xsl:text&gt; &lt;/status&gt; &lt;/node&gt; &lt;/xsl:template&gt; &lt;xsl:template match="groups"&gt; &lt;xsl:for-each select="node"&gt; &lt;node&gt; &lt;name&gt; &lt;xsl:value-of select="members/name"/&gt; &lt;/name&gt; &lt;group&gt; &lt;xsl:value-of select="name"/&gt; &lt;/group&gt; &lt;status&gt; &lt;xsl:text&gt;category1&lt;/xsl:text&gt; &lt;/status&gt; &lt;/node&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>You get the following output:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &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>Now, to your question about learning XSLT. If you meant books on the subject, Michael Kay's "Programmers Reference for XSLT 2.0 and XPATH" is by far the best resource if you do not mind technical details. See for example here: <a href="http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764569090.html" rel="nofollow">http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764569090.html</a>.</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. This table or related slice is empty.
    1. 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