Note that there are some explanatory texts on larger screens.

plurals
  1. POCut and paste at the end of existing node
    text
    copied!<p>Simple question for you today :). I am trying to cut data from a node and paste it at the end of data in another node. </p> <p>So it should look like this:</p> <pre><code>&lt;x&gt; &lt;a&gt;1234&lt;/a&gt; &lt;b&gt;5678&lt;/b&gt; &lt;/x&gt; </code></pre> <p>desired output</p> <pre><code>&lt;x&gt; &lt;a&gt;12345678&lt;/a&gt; &lt;/x&gt; </code></pre> <p>My current testing xslt is:</p> <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" &gt; &lt;xsl:param name="ename"&gt;Test&lt;/xsl:param&gt; &lt;xsl:param name="evalue"&gt;Test1234&lt;/xsl:param&gt; &lt;xsl:param name="removeElementsNamed" select="'Test'"/&gt; &lt;xsl:output method="xml" encoding="utf-8"/&gt; &lt;xsl:template match="@*|node()" name="input"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()" /&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Record"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates/&gt; &lt;xsl:if test="not(c)"&gt; &lt;xsl:element name="{$ename}"&gt;&lt;xsl:value-of select="$evalue"/&gt;&lt;/xsl:element&gt; &lt;/xsl:if&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Record"&gt; &lt;xsl:if test="not(name() = $removeElementsNamed)"&gt; &lt;xsl:call-template name="input"/&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; </code></pre> <p></p> <p>I know that something should be in <code>&lt;xsl:copy&gt;</code> tags but i dont really know what. Tried few things none worked. Help appreciated thank you</p> <p><strong>EDIT</strong>: i just realized that my problem is slightly more complex and i should now show why.</p> <p>My xml file has the following structure</p> <pre><code> &lt;root&gt; &lt;payload&gt;01234&lt;/payload&gt; &lt;metadata&gt; &lt;metadata-element&gt; &lt;key&gt;key&lt;/key&gt; &lt;value&gt;value&lt;/value&gt; &lt;/metadata-element&gt; &lt;/metadata&gt; &lt;metadata&gt; &lt;metadata-element&gt; &lt;key&gt;foo&lt;/key&gt; &lt;value&gt;5678&lt;/value&gt; &lt;/metadata-element&gt; &lt;/metadata&gt; &lt;/root&gt; </code></pre> <p>desired output</p> <pre><code>&lt;root&gt; &lt;payload&gt;012345678&lt;/payload&gt; &lt;metadata&gt; &lt;metadata-element&gt; &lt;key&gt;key&lt;/key&gt; &lt;value&gt;value&lt;/value&gt; &lt;/metadata-element&gt; &lt;/metadata&gt; &lt;/root&gt; </code></pre>
 

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