Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT to remove duplicate while concating
    primarykey
    data
    text
    <p>My XML looks like following:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt; &lt;BATCHES&gt; &lt;item&gt; &lt;Material&gt;1000000079&lt;/Material&gt; &lt;Description&gt;330 Bulk&lt;/Description&gt; &lt;Tank&gt;T123&lt;/Tank&gt; &lt;Batch&gt;2013225287&lt;/Batch&gt; &lt;/item&gt; &lt;item&gt; &lt;Material&gt;1000000079&lt;/Material&gt; &lt;Description&gt;330 Bulk&lt;/Description&gt; &lt;Tank&gt;T123&lt;/Tank&gt; &lt;Batch&gt;2013225301&lt;/Batch&gt; &lt;/item&gt; &lt;item&gt; &lt;Material&gt;1000000196&lt;/Material&gt; &lt;Description&gt;340R Bulk&lt;/Description&gt; &lt;Tank&gt;T700&lt;/Tank&gt; &lt;Batch&gt;1000188378&lt;/Batch&gt; &lt;/item&gt; &lt;item&gt; &lt;Material&gt;1000002754&lt;/Material&gt; &lt;Description&gt;43 Bulk&lt;/Description&gt; &lt;Tank&gt;T515&lt;/Tank&gt; &lt;Batch&gt;2013180125&lt;/Batch&gt; &lt;/item&gt; &lt;item&gt; &lt;Material&gt;1000002754&lt;/Material&gt; &lt;Description&gt;43 Bulk&lt;/Description&gt; &lt;Tank&gt;T515&lt;/Tank&gt; &lt;Batch&gt;2013203124&lt;/Batch&gt; &lt;/item&gt; &lt;item&gt; &lt;Material&gt;1000002754&lt;/Material&gt; &lt;Description&gt;43 Bulk&lt;/Description&gt; &lt;Tank&gt;T515&lt;/Tank&gt; &lt;Batch&gt;2013214839&lt;/Batch&gt; &lt;/item&gt; &lt;item&gt; &lt;Material&gt;1000002754&lt;/Material&gt; &lt;Description&gt;OGA 72043 Bulk&lt;/Description&gt; &lt;Tank&gt;T517&lt;/Tank&gt; &lt;Batch&gt;2013214342&lt;/Batch&gt; &lt;/item&gt; &lt;/BATCHES&gt; </code></pre> <p>My XSLT looks like follwoing:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/&gt; &lt;xsl:template match="/"&gt; &lt;Rowsets&gt; &lt;Rowset&gt; &lt;xsl:variable name="materials" select=".//item[Tank!='RECV' and Tank!='PARK'] "/&gt; &lt;xsl:for-each select="$materials"&gt; &lt;xsl:if test="generate-id(.)= generate-id($materials[Material=current()/Material])"&gt; &lt;Row&gt; &lt;Material&gt; &lt;xsl:value-of select="Material"/&gt; &lt;/Material&gt; &lt;Description&gt; &lt;xsl:value-of select="Description"/&gt; &lt;/Description&gt; &lt;Value&gt; &lt;xsl:for-each select="$materials[Material=current()/Material]/Tank"&gt; &lt;xsl:if test="node()"&gt; &lt;xsl:value-of select="concat(.,'||')"/&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/Value&gt; &lt;/Row&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/Rowset&gt; &lt;/Rowsets&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>The result of XSLT is:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt; &lt;Rowsets&gt; &lt;Rowset&gt; &lt;Row&gt; &lt;Material&gt;1000000079&lt;/Material&gt; &lt;Description&gt;330 Bulk&lt;/Description&gt; &lt;Value&gt;T123||T123||&lt;/Value&gt; &lt;/Row&gt; &lt;Row&gt; &lt;Material&gt;1000000196&lt;/Material&gt; &lt;Description&gt;340R Bulk&lt;/Description&gt; &lt;Value&gt;T700||&lt;/Value&gt; &lt;/Row&gt; &lt;Row&gt; &lt;Material&gt;1000002754&lt;/Material&gt; &lt;Description&gt;43 Bulk&lt;/Description&gt; &lt;Value&gt;T515||T515||T515||T517||&lt;/Value&gt; &lt;/Row&gt; &lt;/Rowset&gt; &lt;/Rowsets&gt; </code></pre> <p>My problem is in the field I dont want to concatenate Tank if it is repeated.</p> <p>Sample should be:</p> <pre><code>&lt;Row&gt; &lt;Material&gt;1000002754&lt;/Material&gt; &lt;Description&gt;43 Bulk&lt;/Description&gt; &lt;Value&gt;T515||T517||&lt;/Value&gt; &lt;/Row&gt; </code></pre> <p>I tried various combinations but could not achieve it. Can anyone plz 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