Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not sure if this is a particularly elegant way of doing it, but you could iterate over the <strong>price</strong> elements rather than the <strong>entry</strong> elements</p> <pre><code>&lt;xsl:for-each select="entries/entry/prices/price"&gt; &lt;xsl:sort select="." order="descending" data-type="number"/&gt; </code></pre> <p>Then, you would need an <strong>xsl:if</strong> condition to check for each <strong>price</strong> element that there is not a higher one for that element</p> <pre><code>&lt;xsl:if test="not(../price &gt; current())"&gt; </code></pre> <p>Here is the full XSLT</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match="/"&gt; &lt;html&gt; &lt;body&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;th&gt;Title&lt;/th&gt; &lt;th&gt;Highest Price&lt;/th&gt; &lt;/tr&gt; &lt;xsl:for-each select="entries/entry/prices/price"&gt; &lt;xsl:sort select="." order="descending" data-type="number"/&gt; &lt;xsl:if test="not(../price &gt; current())"&gt; &lt;tr&gt; &lt;td&gt; &lt;xsl:value-of select="../../title"/&gt; &lt;/td&gt; &lt;td&gt; &lt;xsl:value-of select="."/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>WHen applied to your XML, the following is output</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;th&gt;Title&lt;/th&gt; &lt;th&gt;Highest Price&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Entry 3&lt;/td&gt; &lt;td&gt;500&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Entry 2&lt;/td&gt; &lt;td&gt;300&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Entry 1&lt;/td&gt; &lt;td&gt;50&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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.
    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.
    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