Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I selectively include elements from one or the other xml file based on the contents of a plain text file?
    primarykey
    data
    text
    <p>I have two source xml files and I need to construct a new xml file which contains elements chosen for one or other of the files depending on whether their 'name' is contained in a plain text file.</p> <p>xml file a:</p> <pre class="lang-xml prettyprint-override"><code>&lt;data name="name1"&gt; &lt;value&gt;abc1&lt;/value&gt; &lt;/data&gt; &lt;data name="name2"&gt; &lt;value&gt;abc2&lt;/value&gt; &lt;/data&gt; &lt;data name="name3"&gt; &lt;value&gt;abc3&lt;/value&gt; &lt;/data&gt; </code></pre> <p>xml file b:</p> <pre class="lang-xml prettyprint-override"><code>&lt;data name="name1"&gt; &lt;value&gt;xyz1&lt;/value&gt; &lt;/data&gt; &lt;data name="name2"&gt; &lt;value&gt;xyz2&lt;/value&gt; &lt;/data&gt; &lt;data name="name3"&gt; &lt;value&gt;xyz3&lt;/value&gt; &lt;/data&gt; </code></pre> <p>text file:</p> <pre class="lang-xml prettyprint-override"><code>name1 name3 </code></pre> <p>desired output:</p> <pre class="lang-xml prettyprint-override"><code>&lt;data name="name1"&gt; &lt;value&gt;abc1&lt;/value&gt; &lt;/data&gt; &lt;data name="name2"&gt; &lt;value&gt;xyz2&lt;/value&gt; &lt;---- note this element is from file 'b' &lt;/data&gt; &lt;data name="name3"&gt; &lt;value&gt;abc3&lt;/value&gt; &lt;/data&gt; </code></pre> <p>So the elements with names 'name1' and 'name3' come from 'xml file a' because they are listed in the text file, but 'name2' comes from 'xml file b' because it isn't. </p> <p>The actual names aren't 'name1' etc, but arbitrary string identifiers, but they are unique within the files.</p> <p>Is it possible to do this with XSLT? </p>
    singulars
    1. This table or related slice is empty.
    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