Re: AW: Aw: AW: AW: Sort directory-list

On 21/11/2024 22:34, 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 Thursday, 21 November 2024 22:16:25 UTC