- From: Piez, Wendell A. (Fed) <wendell.piez@nist.gov>
- Date: Fri, 22 Nov 2024 15:37:13 +0000
- To: XProc Dev <xproc-dev@w3.org>
Hello,
Would p:filter work as an alternative to p:identity[p:with-input] here? I suppose I could try and see...
Regards, Wendell
-----Original Message-----
From: Norm Tovey-Walsh <ndw@nwalsh.com>
Sent: Friday, November 22, 2024 4:03 AM
To: denis.maier@unibe.ch
Cc: xproc-dev@w3.org
Subject: Re: Conditional processing based on option
> But, apparently this does not work as p:with-input is not allowed under p:when and p:otherwise.
You have to put the whole step in the when/otherwise branches.
This should work, though I haven’t tested it :-)
<p:option name="sorted-files" select="'true'" />
<p:choose>
<p:when test="$sorted-files = 'false'">
<p:identity>
<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:identity>
</p:when>
<p:otherwise>
<p:identity>
<p:with-input select="//*:file"/>
</p:identity>
</p:otherwise>
</p:choose>
> Is there a way to make this work?
Martin showed another alternative, using a larger and more complex XPath expression. That will work too. I tend to think of XProc pipelines in terms of step composition, so I prefer to have more smaller steps rather than fewer steps with more complex XPath expressions. YMMV.
When I was first reading this thread, I thought, I wonder if we need a p:sort step. Fun challenge: can you implement a generalized sort step in XProc? You can certainly do it with p:run, but can you do it without p:run?
Be seeing you,
norm
--
Norm Tovey-Walsh <ndw@nwalsh.com>
https://norm.tovey-walsh.com/
> Everything is temporary.
Received on Friday, 22 November 2024 15:37:19 UTC