Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>This transformation</strong>:</p> <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:variable name="vNames" select= "tokenize(unparsed-text('file:///c:/temp/delete/Names.txt'), '\s')"/&gt; &lt;xsl:variable name="vDoc1" select="document('file:///c:/temp/delete/FileA.xml')"/&gt; &lt;xsl:variable name="vDoc2" select="document('file:///c:/temp/delete/FileB.xml')"/&gt; &lt;xsl:template match="/"&gt; &lt;t&gt; &lt;xsl:sequence select= "$vDoc1/*/*[@name = $vNames], $vDoc2/*/*[not(@name = $vNames)] "/&gt; &lt;/t&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on any XML document (not used) and having these two files</strong>:</p> <p><strong>c:/temp/delete/FileA.xml</strong>:</p> <pre><code>&lt;t&gt; &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; &lt;/t&gt; </code></pre> <p><strong>c:/temp/delete/FileB.xml</strong>:</p> <pre><code>&lt;t&gt; &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; &lt;/t&gt; </code></pre> <p><strong>c:/temp/delete/Names.txt</strong>:</p> <pre><code>name1 name3 </code></pre> <p><strong>produces the wanted, correct result:</strong></p> <pre><code>&lt;t&gt; &lt;data name="name1"&gt; &lt;value&gt;abc1&lt;/value&gt; &lt;/data&gt; &lt;data name="name3"&gt; &lt;value&gt;abc3&lt;/value&gt; &lt;/data&gt; &lt;data name="name2"&gt; &lt;value&gt;xyz2&lt;/value&gt; &lt;/data&gt; &lt;/t&gt; </code></pre> <p><strong>Explanation</strong>:</p> <p>Proper use of the standard XSLT functions: <strong><a href="http://www.w3.org/TR/xslt20/#function-unparsed-text" rel="nofollow"><code>unparsed-text()</code></a></strong> (2.0 and up only) and <strong><a href="http://www.w3.org/TR/1999/REC-xslt-19991116#function-document" rel="nofollow"><code>document()</code></a></strong> and the standard XPath 2.0 function <strong><a href="http://www.w3.org/TR/xpath-functions/#func-tokenize" rel="nofollow"><code>tokenize()</code></a></strong></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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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