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>

> Yeah, a p:sort sounds like a good idea, and I was perplexed to see that it doesn't exist. (Appararently, ChatGPT also thinks that such a step already exists, as well as p:log and p:message.)

Yes. Well. When I think of ChatGPT I invariable think of one of my mother’s favorite expressions involving a long walk and a short pier.

If it didn’t just hallucinate those steps out of whole cloth, I suppose it was trained on web scrapings that may have included discussions of those steps.

                                        Be seeing you,
                                          norm

--
Norm Tovey-Walsh <ndw@nwalsh.com>
https://norm.tovey-walsh.com/

> We are constantly invited to be who we are.--Henry David Thoreau

Received on Friday, 22 November 2024 12:41:57 UTC