Re: [xsl] Conditional sort instruction as parameter within group && Syntactic matter of multilevel grouping | XSLT 2.0 | P2

Subject: Re: [xsl] Conditional sort instruction as parameter within group && Syntactic matter of multilevel grouping | XSLT 2.0 | P2
From: "Fiona Chen anonymousjuly1@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 6 Jun 2021 20:59:57 -0000
 The logic is to sort on the <search:highlight>:B 

<search:highlight> contains both string( /*:putCurrencyAmount/*:currency) and
decimal (/*:putCurrencyAmount/*:amount) value in the same parent element
(search:result/search:snippet).B  "sortAmount" is supposed to sortB  /*:amount
(in this search result, only two amount: 26000000 , 38500000)B  not the
/*:currency.
As explained, it is merely my imagination to produce <xsl:param
name="sortAmount"> : WITH or WITHOUT parameter, WITH or WITHOUT group-by, WITH
or WITHOUT "see any further sorting", WITH or WITHOUT anything...I am NOT able
to sort the amount using XSLT alone, it consistently renders the document with
lower-amount first even I specify "descending".
As you can see, with the help of the data engine, the document with
higher-amount stays on top in the UI.

Question One is how to sort <search:highlight> when its value is decimal (
string is ignored ),"descending" or "ascending", in PURE XSLT.

Question Two: I mentioned it is "Syntactic matter". Whenever I use
"xsl:for-each-group" or "current-grouping-key()", the data engine failed
miserably...Before I claim it is the bug of the data engine (I understand it
can't digest XSLT 3.0 and "current-grouping-key" is ONLY available in XSLT), I
want to ensure it is not a syntactic problem.B 
I can't help wondering how to expand the XSLT 2.0+ capabilities within the
data engine...


    On Sunday, June 6, 2021, 3:32:14 p.m. EDT, Martin Honnen
martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

 On 06.06.2021 19:34, Fiona Chen anonymousjuly1@xxxxxxxx wrote:
> Question One: The conditional sort is based on the search:highlight, if
> it is decimal, sort the putAmount and then incarnate the document.
> Notice: The "Rationale" is that currency and amount must be paired. In
> each search:snippet, the currency is one search:highlight while amount
> another. I would imagine a pure XSLT conditional sort in below manner.
>
> =====================================================
>B  B B B  <xsl:param name="sortAmount">
>B  B B B B B B B  <xsl:for-each select="highlight">
>B  B B B B B B B B B B B  <xsl:sort select="if (normalize-space() castable as
> xs:decimal) then descending
>B  B B B B B B B B B B B B B B B  else ()"/>
>B  B B B B B B B  </xsl:for-each>
>B  B B B  </xsl:param>

What kind of value is sortAmount supposed to represent, a sequence of
sort values like the amount, a sequence of sort orders like "descending"?

>
>B  B B B  <xsl:template match="result">
>B  B B B B B B B  <xsl:variable name="doc" select="document(@uri)"/>
>B  B B B B B B B  <xsl:element name="Trade">
>B  B B B B B B B B B B B  <xsl:for-each-group select="." group-by="@uri">
>B  B B B B B B B B B B B B B B B  <xsl:call-template name="sort-render">
>B  B B B B B B B B B B B B B B B B B B B  <xsl:with-param name="sortAmt"
select="$sortAmount"/>
>B  B B B B B B B B B B B <!--B B B B B B B B  <xsl:with-param name="uri"
> select="current-grouping-key()"/> -->
>B  B B B B B B B B B B B B B B B  </xsl:call-template>
>B  B B B B B B B B B B B  </xsl:for-each-group>
>B  B B B B B B B  </xsl:element>
>B  B B B  </xsl:template>
>
>B  B B B  <xsl:template name="sort-render">
>B  B B B B B B B  <xsl:param name="sortAmt"/>
>B  B <!--B B B B B B  <xsl:param name="uri"/> -->
>B  B B B B B B B  <Justification inDocument="{@uri}">
>B  B B B B B B B B B B B  <xsl:for-each select="descendant::match">
>B  B B B B B B B B B B B B B B B  <path><xsl:value-of
select="@path"/></path>
>B  B B B B B B B B B B B B B B B  <highlight><xsl:value-of
select="highlight"/></highlight>
>B  B B B B B B B B B B B  </xsl:for-each>
>B  B B B B B B B  </Justification>
>B  B B B  </xsl:template>

Can you explain where you want to sort? You create a parameter named
sortAmount and pass it on as sortAmt but I do not even see any further
sorting there that uses sortAmt.

Current Thread