Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to check lookup table tags with documents tags
    primarykey
    data
    text
    <p>Halo,</p> <p>I have this xml document:</p> <pre><code>&lt;document&gt; &lt;Line&gt; &lt;Line-Item&gt; &lt;ID&gt;5&lt;/ID&gt; &lt;Quantity&gt;100&lt;/Quantity&gt; &lt;/Line-Item&gt; &lt;/Line&gt; &lt;Line&gt; &lt;Line-Item&gt; &lt;ID&gt;6&lt;/ID&gt; &lt;Quantity&gt;9&lt;/Quantity&gt; &lt;/Line-Item&gt; &lt;/Line&gt; &lt;Line&gt; &lt;Line-Item&gt; &lt;ID&gt;60&lt;/ID&gt; &lt;Quantity&gt;3020&lt;/Quantity&gt; &lt;/Line-Item&gt; &lt;/Line&gt; &lt;/document&gt; </code></pre> <p>And lookup file with table:</p> <pre><code>&lt;lookup&gt; &lt;Code&gt; &lt;LookupID&gt;5&lt;/LookupID&gt; &lt;LookupQuantity&gt;25&lt;/LookupQuantity&gt; &lt;/Code&gt; &lt;Code&gt; &lt;LookupID&gt;6&lt;/LookupID&gt; &lt;LookupQuantity&gt;3&lt;/LookupQuantity&gt; &lt;/Code&gt; &lt;Code&gt; &lt;LookupID&gt;70&lt;/LookupID&gt; &lt;LookupQuantity&gt;3&lt;/LookupQuantity&gt; &lt;/Code&gt; &lt;/lookup&gt; </code></pre> <p>I should check lookup tables field lookup/Code/LookupId with document Line/Line-Item/ID. if lookup/Code/LookupId=document/Line/Line-Item/ID then document/Line/Line-Item/Quantity=document/Line/Line-Item/Quantity div lookup/Code/LookupQuantity, otherwise document/Line/Line-Item/Quantity=document/Line/Line-Item/Quantity</p> <p>Needed result:</p> <pre><code>&lt;document&gt; &lt;Line&gt; &lt;Line-Item&gt; &lt;ID&gt;5&lt;/ID&gt; &lt;Quantity&gt;4&lt;/Quantity&gt; &lt;/Line-Item&gt; &lt;/Line&gt; &lt;Line&gt; &lt;Line-Item&gt; &lt;ID&gt;6&lt;/ID&gt; &lt;Quantity&gt;3&lt;/Quantity&gt; &lt;/Line-Item&gt; &lt;/Line&gt; &lt;Line&gt; &lt;Line-Item&gt; &lt;ID&gt;60&lt;/ID&gt; &lt;Quantity&gt;3020&lt;/Quantity&gt; &lt;/Line-Item&gt; &lt;/Line&gt; &lt;/document&gt; </code></pre> <p>My xslt:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date"&gt; &lt;xsl:output method="xml" encoding="UTF-8" indent="yes"/&gt; &lt;xsl:key name="skRez" match="LookupQuantity" use="../LookupID"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Line/Line-Item/Quantity"&gt; &lt;xsl:variable name="inputS" select="..//ID"/&gt; &lt;xsl:variable name="inputQ" select="..//Quantity"/&gt; &lt;OrderedQuantity&gt; &lt;xsl:for-each select="document('lookup.xml')"&gt; &lt;xsl:for-each select="key('skRez',$inputS)"&gt; &lt;xsl:variable name="Quantity" select="."/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$Quantity"&gt;&lt;xsl:value-of select="ceiling($inputQ div $Quantity)"/&gt;&lt;/xsl:when&gt; &lt;xsl:otherwise&gt;&lt;xsl:value-of select="$inputQ"/&gt;&lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; &lt;/OrderedQuantity&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre>
    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.
 

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