- From: <denis.maier@unibe.ch>
- Date: Fri, 22 Nov 2024 13:56:41 +0000
- To: <ndw@nwalsh.com>
- CC: <xproc-dev@w3.org>
> -----Ursprüngliche Nachricht-----
> Von: Norm Tovey-Walsh <ndw@nwalsh.com>
> Gesendet: Freitag, 22. November 2024 13:42
> An: Maier, Denis Christian (UB) <denis.maier@unibe.ch>
> Cc: xproc-dev@w3.org
> Betreff: Re: AW: Conditional processing based on option
>
> >> You have to put the whole step in the when/otherwise branches.
> >> This should work, though I haven’t tested it :-)
> >
> > Unfortunately it doesn't.
> > Error in XPath expression 'c:file/@name': Context item is needed, but not
> provided: 11 items found.
>
> Sorry. Something like this:
>
> <p:option name="sorted-files" select="'true'" />
> <p:directory-listing …>
> <p:for-each>
> <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>
> </p:for-each>
>
Ok, this is works. I'm still struggling to understand what exactly might be happeing in these two cases. Am I understanding this correctly that this here is sorting the complete list, which then gets passed to the next p:for-each step? Whereas in Martin's solution, sorting happens inside a single p:for-each step together with the actual processing of the individual files? In Martin's solution, is it correct to assume that the sorting doesn't return a complete sorted list, but just the next item to be processed?
Received on Friday, 22 November 2024 13:56:49 UTC