- From: <denis.maier@unibe.ch>
- Date: Fri, 22 Nov 2024 08:15:19 +0000
- To: <denis.maier@unibe.ch>, <martin.honnen@gmx.de>, <xproc-dev@w3.org>
- Message-ID: <GV0P278MB021176AB679FE512528B6A7E83232@GV0P278MB0211.CHEP278.PROD.OUTLOOK.COM>
After testing with the original source files, I can confirm that your solution works as expected! Thanks again for your help. All the best, Denis Von: denis.maier@unibe.ch <denis.maier@unibe.ch> Gesendet: Freitag, 22. November 2024 00:15 An: martin.honnen@gmx.de; xproc-dev@w3.org Betreff: Re: AW: Aw: AW: AW: Sort directory-list OK. That makes sense. I've just realized a colleague uploaded some files with a different naming pattern (just numbers). I'll test again tomorrow with the original files. I don't think a more robust solution would be needed. We'll either do so normalization in a preprocessing step, or we will use your solution. There's no need to cover both situations. Thanks a lot, Denis ________________________________ From: Martin Honnen <martin.honnen@gmx.de<mailto:martin.honnen@gmx.de>> Sent: Thursday, November 21, 2024 11:16:20 PM To: xproc-dev@w3.org<mailto:xproc-dev@w3.org> <xproc-dev@w3.org<mailto:xproc-dev@w3.org>> Subject: Re: AW: Aw: AW: AW: Sort directory-list On 21/11/2024 22:34, denis.maier@unibe.ch<mailto:denis.maier@unibe.ch> wrote: Now I'm getting another error which directly relates to the code: <c:errors xmlns:c=http://www.w3.org/ns/xproc-step><c:error code="err:XD0030" name="!1.2-!anonymous-in-0" href=... line="20" column="56" xmlns:err=http://www.w3.org/ns/xproc-error><message>Types 'XS_String' and 'XS_Double' are not comparable.</message></c:error></c:errors> I think this means you have file names of various structures e.g. some with no numbers in the file name, others with numbers, my code below kind of assumes their is a pattern like [a-z]+[0-9]+ so that the last argument to the fn:sort function always computes a sequence of sort keys of the same length and the same type of each of the positional keys. Not sure I can come up with something more clever tonight, perhaps someone else can chime in or I will try to ponder this tomorrow. > <p:for-each> > <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:for-each> > > Tested that with MorganaXProc-IIIse 1.4.5 to give e.g. 'sample1.xml', > 'sample2.xml', `sample10.xml' where unsorted gives sample1.xml, > sample10.xml, sample2.xml > Thanks, Martin. I've tried it, but I'm getting this error message: Error in compiling XPath expression '//*:file => sort((), function($file) { analyze-string($file!@name, '[0-9]+')!descendant::*[not(*)]!(if (. instance of element(fn:match)) then number(.) else string(.)) })': Cannot resolve prefix for 'fn:match'. I've just updated to Morgana 1.4.5.
Received on Friday, 22 November 2024 08:15:35 UTC