[xquery-talk] Are you getting much spam on this list, too?

2018-05-01 Thread Andreas Mixich
Hello,

is it just for me, or are members of this list getting lots of automated
mailings, too?

I just subscribed today and already got "Undeliverable Notices" from
biovigilant.com for each post I did and one "autoreply" from
cicpa.org.cn, sent to me personally.

-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] Doing 'base-uri "{$base-uri}";' fails

2018-05-01 Thread Andreas Mixich
Hello Michael,

thank you for your clarification. I would prefer the catalog way, but
according to the Saxon documentation on XML catalogs it states

  The catalog is NOT currently used for non-XML resources, *including
  query modules*, unparsed text files, collations, and collections.

It seems, BaseX does not use catalogs at this point either, only on
document imports into the database.

I may end up by adding a build script/installer, that does a string
search & replace with a user-supplied value for the base-uri.

-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

[xquery-talk] Doing 'base-uri "{$base-uri}";' fails

2018-05-01 Thread Andreas Mixich
Hello,

Since the application I am writing can be installed on other hosts, the
`base-uri` must be configurable to that foreign host. I want to solve
this with a library module, that keeps domain specific configuration
separate to the user and which gets imported where needed.

Test case:

  declare namespace cfg = "ns:cfg";
  declare base-uri "{$cfg:base-uri}";
  declare variable $cfg:base-uri := "file:/S:/projects/xqfr/src/fragments/";

  let $file := doc("xhtml5-page.xhtml")
  return $file

Doing this test case, both Saxon and BaseX try to find the file in the
directory of their executable installation

  [FODC0002] Resource 'C:/Program Files (x86)/BaseX/xhtml5-page.xhtml'
  does not exist.

When using it in a module context, with Saxon I get:

  Invalid URI config.xqm: Invalid base URI: Illegal character in scheme
  name at index 0: {$cfg:base-uri}: {$cfg:base-uri}

Googling it, it appears to be Java itself, throwing the error message.
Thus the {$base-uri} may get passed verbatim, but when used outside of
the module context, it somehow gets caught, but without a signal.

Long story short: Is there a way to achieve what I want? Is there a
reason against hoisting variables in XQuery, that get 'declared'?

Would it make sense to file an enhancement request on 'www.w3.org/Bugs' ?

-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

[xquery-talk] When to us xs:string or xs:anyURI ?

2019-04-16 Thread Andreas Mixich
Hello,

I wonder, what dis/advantages it would have to use the xs:anyURI
datatype for IRIs
instead of xs:string. Looking around, it seems, that most people do not
care for
the xs:anyURI and use xs:string instead, since that is easier to handle
(type casting works only one-directional with xs:anyURI).

What was the rationale behind creating an xs:anyURI datatype?
According to http://www.datypic.com/sc/xsd/t-xsd_anyURI.html

  [...]The only values that are not accepted are ones that make
inappropriate
  use of reserved characters, such as ones that contain
multiple |#| characters
  or have |%| characters that are not followed by two hexadecimal
digits.[...]

As XQuery users, what would you prefer in a module library for
functions, that take
or return IRIs? What would you expect in a module library, that acts as
a "swiss army
knife" for IRIs?

-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich

___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] When to us xs:string or xs:anyURI ?

2019-04-17 Thread Andreas Mixich
On Wed, Apr 17, 2019 at 11:37 AM Michael Kay  wrote:

> In the standard function library we adopted the approach that for input
> parameters, relevant functions should accept xs:string; for function
> results, they should return an xs:anyURI. That recognizes the one-way
> casting effect.
>

Okay, than that's what I am going to do as well. Thanks.
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] Building a tree from sequence of maps

2019-12-21 Thread Andreas Mixich
Hello,

thank you for the example.

I am totally fine with the HOF style. I have access to XQ3.1 (BaseX and
Saxon-PE/EE with oXygen)

There is still a thing, that I need to solve, namely how to get   aligned,
that's why I will follow up to this in the next days, since I have drained
out for now. :-)

Thanks to Mr. Hager, was well.


-- 
Minden jót, all the best, Alles Gute,
Andreas Mixich
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

[xquery-talk] Building a tree from sequence of maps

2019-12-21 Thread Andreas Mixich
Hi,

I feel like I try to get a hold on a piece of wet soap with this...

Background: Atom Syndication has an extension[1], which allows threading of
entries. These entries are ordered in a flat sequence, one by one.
As a result we end up with an Atom feed, that has a bunch of entries, where
each entry could have a reference to the ID of another entry, which would
then be it's parent.
No nesting is done.

A simplified input could look like this:

declare variable $local:example :=
let $xml := 
  
  
  
  
  
  


The task I want to accomplish is to create an output *tree* of *nested*
sections, resembling the natural flow of replies:


  

  
  

  

  
  


One of the many queries I tried is:

declare function local:rec($data) {
  if (empty($data))
  then ()
  else (
 let $current := head($data)
 let $children := tail($data)[@refid = $current/@id]
 return (
  
  {
$current/*
(:  , prof:dump("current: " || $current/@id/data() || "
children: " || $children/@id/data() => string-join())
:)
  , for $child in $children
return local:rec($children)
  }
  
  , local:rec(tail($data))
)
   )
};


  { local:rec($local:example/item) }


Of course, this has not yet any logic, to keep out the already processed
items (besides other issues).
When I tried that, however, by removing them from the return sequence, I
found no way to break out
of scope and have that modified return sequence go back to the next
recursion.

Previous example results in this, btw.:


  


  
  
  
  



  




I can't believe, that there is no super easy way to do it. Any help would
be greatly appreciated!

-- 
Minden jót, all the best, Alles Gute,
Andreas Mixich
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] Building a tree from sequence of maps

2019-12-30 Thread Andreas Mixich
Staying away from an issue for a few days can be quite clearing! When I
revisited the task, I saw it right on! Or so I think...
This is the solution I came up with:

declare variable $local:xml :=


  
  
  
  
  
  
  
  
  
  
;

declare function local:get-parents($item) { $local:xml/item[not(@refid !=
$item/@id)] };
declare function local:get-children($item) { $local:xml/item[@refid =
$item/@id] };

declare function local:process-item($item) {
  
  {
  let $t := $item/(@*, local:get-children($item)/local:process-item(.))
return $t
  }
  
};

let $root := local:get-parents($local:xml/item)
for $item in $root
return local:process-item($item)

which produces:



   
  
  
 
  
   



   
   
  
   



and that seems to match the case. Thank you.

-- 
Minden jót, all the best, Alles Gute,
Andreas Mixich
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] Wrap element constructor and output disappears

2020-08-15 Thread Andreas Mixich
Ihe Onwuka wrote:
> But if I try to wrap an element around that output like below nothing
> is returned
> |{ let $root :=  for
> $prefix in in-scope-prefixes($root)[not(. = ('xml', 'xsi'))] return
> namespace-uri-for-prefix($prefix,$root) !  value="{.}"/> } |
>
> So what is wrong and how do I wrap the output in a parameters element?
>

Not sure, whether such a late reply is of any use to you, sorry, I just
discovered it now. I want to confirm, that it works with BaseX 9.4.
The output I get is:

    
      
      
    

-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich

___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] Purely recursive deduplication of sequence?

2020-08-01 Thread Andreas Mixich
Am 01.08.2020 um 14:57 schrieb Christian Grün:

Thank you so much for all three examples!

Of course, in the end, I am going to take the one, which has the
best performance. Do you expect it to be the `FLOWR` based or
the `fold-left#3` based, you demonstrated in the follow-up?

Still, I am glad to see this one, since it surprises me, as to how
short this can be! My own ponderings started to get out of hand by
adding more and more code - to no avail. That was when I gave up
and just asked.

> declare function local:distinct-items($items as item()*) as item()* {
>   if (empty($items)) then () else (
> head($items),
> local:distinct-items(tail($items)[not(deep-equal(., head($items)))])
>   )
> };


-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich

___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

[xquery-talk] Purely recursive deduplication of sequence?

2020-08-01 Thread Andreas Mixich
Hello,

I wonder, whether it could be possible to deduplicate a sequence by a
purely recursive approach,
without creating state in any form.

What I have, so far, is only capable of removing consecutive dupes, so,
nothing fancy.

  (:~
    Removes all consecutive duplicate items from a sequence, returning
    the deduped sequence.
  
    @param   $items  a sequence, that may contain duplicates
    @return  a sequence, in which all 'pairs' have been 'singled'
    :)
  declare function local:dedupe-pairs($items as item()*) as item()* {
    if (count($items) <= 1)
    then $items
    else if (deep-equal(head($items), head(tail($items
 then local:dedupe-pairs(tail($items))
 else (
    head($items)
  , local:dedupe-pairs(tail($items))
  )
  };

  (: following sequence has 19 items :)
  let $a3 := (
   array {"One", "Two", 3}
 , array {"One", "Two", 1}
 , array {"One", "Two", 3}
 , 
 , 
 , array {"apples","oranges"}
 , array {"apples","oranges"}
 , 
 , array {"One",5,}
 , array {3,7,"Hello World!"}
 , array {3,7,"Hello World!"}
 , map{'key':'value'}
 , false()
 , false()
 , array {"One","lorem",,2,"Naomi"}
 , array {"One", "Two", 3}
 , array {"One","lorem",,2,"Naomi"}
 , array {,map{'key':'value'},true()}
 , false()
 )
  return local:dedupe-pairs($a3)

serializes to:

  ["One","Two",3]
  ["One","Two",1]
  ["One","Two",3]
  
  ["apples","oranges"]
  
  ["One",5,]
  [3,7,"Hello World!"]
  map{"key":"value"}
  false
  ["One","lorem",,2,"Naomi"]
  ["One","Two",3]
  ["One","lorem",,2,"Naomi"]
  [,map{"key":"value"},true()]
  false

However, this is not what I want. I want to understand, whether a
function would be possible, that completely dedupes given sequence,
like `fn:distinct-values#1`, however, for any kind of item, not just
atomic ones:

  `local:distinct-items($items as item()*) as item()*`

It should no use state in any form (typically creating and revolving
a second list or sending a flag throughout recursion).

Also, I do not want to use any manipulative functions (like fn:remove#2)
and, ideally, no `FOR..IN..` construct.

The deduped list would be purely the result of the recursive walk through
the list, grown organically, so to say.

Only, I can not come up with such a thing. Is there a way to do it?

Thank you.

-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk