I can sort on putAmount by exploiting the data engine through API. But I can't
seem to achieve the same sort effect in pure XSLT.
Below is my XSLT module extract as part of the Stage Two implementation:
<xsl:template match="result">
<xsl:variable name="doc" select="document(@uri)"/>
<xsl:element name="Trade">
<xsl:element name="documentId"><xsl:value-of
select="$doc/product:requestProduct/product:_metaData/product:docId"/></xsl:element><!--
Line 55 -->
<Justification>
<xsl:for-each select="descendant::match">
<path><xsl:value-of select="@path"/></path>
<highlight><xsl:value-of select="highlight"/></highlight>
</xsl:for-each>
</Justification><!-- Line 60 -->
<!-- Line 71:: Traverse XML and JSON -->
<xsl:copy-of
select="incarnation:render-def(fn:normalize-space(@uri))"/>
</xsl:element>
</xsl:template>
Thus,
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.
===================================================== <xsl:param
name="sortAmount">
<xsl:for-each select="highlight">
<xsl:sort select="if (normalize-space() castable as xs:decimal)
then descending
else ()"/>
</xsl:for-each>
</xsl:param>
<xsl:template match="result">
<xsl:variable name="doc" select="document(@uri)"/>
<xsl:element name="Trade">
<xsl:for-each-group select="." group-by="@uri">
<xsl:call-template name="sort-render">
<xsl:with-param name="sortAmt" select="$sortAmount"/>
<!-- <xsl:with-param name="uri"
select="current-grouping-key()"/> -->
</xsl:call-template>
</xsl:for-each-group>
</xsl:element>
</xsl:template>
<xsl:template name="sort-render">
<xsl:param name="sortAmt"/>
<!-- <xsl:param name="uri"/> -->
<Justification inDocument="{@uri}">
<xsl:for-each select="descendant::match">
<path><xsl:value-of select="@path"/></path>
<highlight><xsl:value-of select="highlight"/></highlight>
</xsl:for-each>
</Justification>
</xsl:template>
======================================================Above doesn't sort the
decimal search:highlight. The /a.xml is still incarnated first in the Oxygen
(without the data engine support). I don't know if there is a pure XSLT
solution for this. Can the XSLT expert help?
Question Two: Below produces the same result by replacing Line 55 - 60 in my
original XSLT module. Can someone point out if below module is syntactically
correct? (It runs fine in the Oxygen.)
<xsl:for-each-group select="." group-by="@uri">
<Justification inDocument="{current-grouping-key()}">
<xsl:for-each-group select="current-group()" group-by="snippet">
<xsl:for-each select="descendant::match">
<path><xsl:value-of select="@path"/></path>
<highlight><xsl:value-of
select="highlight"/></highlight>
</xsl:for-each>
</xsl:for-each-group>
</Justification>
</xsl:for-each-group>
Thank you...
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--