- From: Norm Tovey-Walsh <ndw@nwalsh.com>
- Date: Fri, 22 Nov 2024 09:03:19 +0000
- To: <denis.maier@unibe.ch>
- Cc: <xproc-dev@w3.org>
- Message-ID: <m2y11b8wtk.fsf@nwalsh.com>
> 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 09:03:27 UTC