Re: [basex-talk] Element construction - namespace error - bug?

2023-09-25 Thread Hans-Juergen Rennau
 Many thanks, Christian! I can confirm that it works also in my environment.
Greetings, Hans-Jürgen
PS: Generic processing requires that namespace bindings do not get lost, as 
they may be required for the interpretation of content. Hence I have to make 
sure that all namespace bindings are preserved. A distinction of namespace 
bindings which would be created anyway - because required by node names - and 
other bindings would be cumbersome. Also, for cosmetic reasons (in order to 
avoid repetitive namespace attributes) the input document may have declared all 
namespace bindings in the root node, and this policy should also be preserved.


Am Montag, 25. September 2023 um 17:31:39 MESZ hat Christian Grün 
 Folgendes geschrieben:  
 
 …a bug fix snapshot is available [1]. Once again, I’d recommend you to skip 
the explicit namespace construction if it’s not really needed.[1] 
https://files.basex.org/releases/latest/


On Mon, Sep 25, 2023 at 2:48 PM Christian Grün  
wrote:

Thanks, Hans-Jürgen,
looks like a bug; we’ll track that down.
I assume you can simply omit the following line, as the necessary namespace 
declarations will automatically be added (unless you want to enforce the 
adoption of namespace declarations that are not required):
  in-scope-prefixes($n) ! namespace {.} {namespace-uri-for-prefix(., $n)},

Best,Christian

On Wed, Sep 20, 2023 at 6:34 PM Hans-Juergen Rennau  wrote:

Dear BaseX folks,
constructing elements, I encounter a problem with namespaces which I do not 
understand. Is it a bug or do I overlook something?
To reproduce the problem you need to create an XML file "doc.xml" with this 
content:
http://basex.org/simply/the/best;>              
   
And here's the query:
declare namespace f="http://basex.org/does/its/thing;;
declare function f:pretty($n as node())        as node()? {    typeswitch($n)   
 case document-node() return document {$n/node() ! f:pretty(.)}    case 
element() return        element {node-name($n)} {            
in-scope-prefixes($n) ! namespace {.} {namespace-uri-for-prefix(., $n)},        
    $n/@* ! f:pretty(.),            $n/node() ! f:pretty(.)        }    default 
return $n};    
let $doc := doc('doc.xml')return f:pretty($doc)
What I get is this error:
Stopped at 
C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq, 
8/33:[XQDY0102] Duplicate declaration of namespace 
'http://basex.org/simply/the/best'.
Stack Trace:- 
C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq, 
11/33- 
C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq, 
11/33- 
C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq, 
6/63- 
C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq, 
17/16
Strangely enough, you do not get the error if you copy the contents of doc.xml 
into the query:
let $doc := return f:pretty($doc)
You also do not get the error if you remove the @bar attribute in the document.
Kind regards,Hans-Jürgen

  

Re: [basex-talk] Element construction - namespace error - bug?

2023-09-25 Thread Christian Grün
…a bug fix snapshot is available [1]. Once again, I’d recommend you to skip
the explicit namespace construction if it’s not really needed.
[1] https://files.basex.org/releases/latest/



On Mon, Sep 25, 2023 at 2:48 PM Christian Grün 
wrote:

> Thanks, Hans-Jürgen,
>
> looks like a bug; we’ll track that down.
>
> I assume you can simply omit the following line, as the necessary
> namespace declarations will automatically be added (unless you want to
> enforce the adoption of namespace declarations that are not required):
>
>   in-scope-prefixes($n) ! namespace {.} {namespace-uri-for-prefix(., $n)},
>
> Best,
> Christian
>
>
> On Wed, Sep 20, 2023 at 6:34 PM Hans-Juergen Rennau 
> wrote:
>
>> Dear BaseX folks,
>>
>> constructing elements, I encounter a problem with namespaces which I do
>> not understand. Is it a bug or do I overlook something?
>>
>> To reproduce the problem you need to create an XML file "doc.xml" with
>> this content:
>>
>> http://basex.org/simply/the/best;>
>> 
>> 
>> 
>> 
>>
>> And here's the query:
>>
>> declare namespace f="http://basex.org/does/its/thing;;
>>
>> declare function f:pretty($n as node())
>> as node()? {
>> typeswitch($n)
>> case document-node() return document {$n/node() ! f:pretty(.)}
>> case element() return
>> element {node-name($n)} {
>> in-scope-prefixes($n) ! namespace {.}
>> {namespace-uri-for-prefix(., $n)},
>> $n/@* ! f:pretty(.),
>> $n/node() ! f:pretty(.)
>> }
>> default return $n
>> };
>>
>> let $doc := doc('doc.xml')
>> return f:pretty($doc)
>>
>> What I get is this error:
>>
>> Stopped at
>> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
>> 8/33:
>> [XQDY0102] *Duplicate declaration of namespace* '
>> http://basex.org/simply/the/best'.
>>
>> Stack Trace:
>> -
>> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
>> 11/33
>> -
>> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
>> 11/33
>> -
>> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
>> 6/63
>> -
>> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
>> 17/16
>>
>> Strangely enough, you do not get the error if you copy the contents of
>> doc.xml into the query:
>>
>> let $doc := 
>> return f:pretty($doc)
>>
>> You also do not get the error if you remove the @bar attribute in the
>> document.
>>
>> Kind regards,
>> Hans-Jürgen
>>
>


Re: [basex-talk] Element construction - namespace error - bug?

2023-09-25 Thread Christian Grün
Thanks, Hans-Jürgen,

looks like a bug; we’ll track that down.

I assume you can simply omit the following line, as the necessary namespace
declarations will automatically be added (unless you want to enforce the
adoption of namespace declarations that are not required):

  in-scope-prefixes($n) ! namespace {.} {namespace-uri-for-prefix(., $n)},

Best,
Christian


On Wed, Sep 20, 2023 at 6:34 PM Hans-Juergen Rennau 
wrote:

> Dear BaseX folks,
>
> constructing elements, I encounter a problem with namespaces which I do
> not understand. Is it a bug or do I overlook something?
>
> To reproduce the problem you need to create an XML file "doc.xml" with
> this content:
>
> http://basex.org/simply/the/best;>
> 
> 
> 
> 
>
> And here's the query:
>
> declare namespace f="http://basex.org/does/its/thing;;
>
> declare function f:pretty($n as node())
> as node()? {
> typeswitch($n)
> case document-node() return document {$n/node() ! f:pretty(.)}
> case element() return
> element {node-name($n)} {
> in-scope-prefixes($n) ! namespace {.}
> {namespace-uri-for-prefix(., $n)},
> $n/@* ! f:pretty(.),
> $n/node() ! f:pretty(.)
> }
> default return $n
> };
>
> let $doc := doc('doc.xml')
> return f:pretty($doc)
>
> What I get is this error:
>
> Stopped at
> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
> 8/33:
> [XQDY0102] *Duplicate declaration of namespace* '
> http://basex.org/simply/the/best'.
>
> Stack Trace:
> -
> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
> 11/33
> -
> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
> 11/33
> -
> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
> 6/63
> -
> C:/projects/tableman/prototype/thieme-showcase/xq/demo-namespace-problem.xq,
> 17/16
>
> Strangely enough, you do not get the error if you copy the contents of
> doc.xml into the query:
>
> let $doc := 
> return f:pretty($doc)
>
> You also do not get the error if you remove the @bar attribute in the
> document.
>
> Kind regards,
> Hans-Jürgen
>