Re: [xsl] Ignoring quotation marks in grouping and sorting

Subject: Re: [xsl] Ignoring quotation marks in grouping and sorting
From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 4 Jan 2019 21:15:05 -0000
I would go to XSLT 3 because if you're using latest Saxon no reason not to.

I would normally create a function called something like "local:getSortKey()"
that takes the context item and returns the sort key:

<xsl:function name="local:getSortKey" as="xs:string">
  <xsl:param name="context" as="element(fmp:ROW)"/>

 <xsl:variable name="result" as="xs:string"
 Select="fmp:COL[2]/fmp:DATA ! replace(., '&quot;', '') ! normalize-space(.)"
/>
<xsl:sequence select="$result"/>
</xsl:function>

Here I'm using the XPath3 "!" operator to do the string processing because I
think it's clearer than nested functions.

Depending on your data there may be more massaging you need to do to make
appropriate sort keys, and the function gives you an easy place to do that.

Here the function is handling a single element type but if it needed to be
more flexible you could apply templates from the function to dispatch the
element-type-specific sort key logic to templates.

And donbt forget that you can have number of sort instructions so you might
need e.g., functions to get the primary and secondary sort keys or whatever it
might be.

Cheers,

Eliot


--
Eliot Kimber
http://contrext.com


o;?On 1/4/19, 2:19 PM, "Michele R Combs mrrothen@xxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

    Pfft, that's too easy ;)



    What would be the solution in 2.0 then?



    -----Original Message-----

    From: Wendell Piez wapiez@xxxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>

    Sent: Friday, January 4, 2019 2:49 PM

    To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx

    Subject: Re: [xsl] Ignoring quotation marks in grouping and sorting



    Hi Michele,



    Goodness (as my mother is apt to say), then why stay with 1.1 (which, in a
sense, never even actually existed)?



    A solution is possible, in theory, under those rules, but many XSLT

    2.0 or 3.0 solutions will be more elegant, concise and intelligible.



    Suggest you try tweaking the version first to satisfy that the XSLT runs
equivalently, which it is likely to do.



    Cheers, Wendell



    On Fri, Jan 4, 2019 at 1:46 PM Michele R Combs mrrothen@xxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

    >

    > > Which XSLT 1.1 processor is that, does it have any extension

    > > function support for easier or more powerful string handling than

    > > Xpath

    > > 1.0 provides?

    >

    > I'm using Saxon9he at the moment.

    >

    > Michele

    >







    --

    Wendell Piez | wendell -dot- piez -at- nist -dot- gov |
http://www.wendellpiez.com pellucidliterature.org | github.com/wendellpiez |
gitlab.coko.foundation/wendell  - pausepress.org

Current Thread