- From: Martin Honnen <martin.honnen@gmx.de>
- Date: Fri, 22 Nov 2024 09:48:19 +0100
- To: xproc-dev@w3.org
- Message-ID: <53187038-1082-4004-a23d-56baa88675d7@gmx.de>
On 22/11/2024 09:43, denis.maier@unibe.ch wrote:
>
> Hi,
>
> A follow up on my question from yesterday regarding filesorting. As we
> haven’t yet decided if we will sort the files within the pipeline or
> if we should normalize the file names during preprocessing, I’ve
> thought I could keep both ways in the pipeline, but use an option to
> determine which one is being use. I thought this should be
> straightforward, but this approach won’t work.
>
> <p:option name="sorted-files" select="'true'" />
>
> <p:choose>
>
> <p:when test="$sorted-files = 'false'">
>
> <p:with-input select="//*:file => sort((), function($file) {
> analyze-string($file!@name, '[0-9]+')!descendant::*[not(*)]!(if (.
>
> instance of element(fn:match)) then number(.) else string(.)) })"/>
>
> </p:when>
>
> <p:otherwise>
>
> <p:with-input select="//*:file"/>
>
> </p:otherwise>
>
> </p:choose>
>
> But, apparently this does not work as p:with-input is not allowed
> under p:when and p:otherwise.
>
> Is there a way to make this work?
>
XPath 3 has an
if (condition) then exp1 else exp2
expression so perhaps simply
<p:option name="sorted-files" select="true()" />
<p:with-input select="if ($sorted-files) then //*:file else
(//*:file => sort((), function($file) { analyze-string($file!@name,
'[0-9]+')!descendant::*[not(*)]!(if (.
instance of element(fn:match)) then number(.) else
string(.)) }))"/>
Received on Friday, 22 November 2024 08:48:23 UTC