TestSuite: Is this a bug?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

TestSuite: Is this a bug?

Jonathan Rowell

Hi,


Is this a bug in TestSuite - my XQuery is not that good (yet) :-


declare %private function test:normalize-node($node as node()) {
    typeswitch ($node)
        case document-node() return
            test:normalize-node($node/*)
        case element() return
            element { node-name($node) } {
                $node/@*, for $child in $node/node() return test:normalize-node($child)
            }
        case text() return
            let $norm := normalize-space($node)
            return
                if (string-length($norm) eq 0) then () else $node
        default return
            $node
};

In the "case text()" the node is normed and if the string is empty an empty sequence is returned. Otherwise the original node is returned rather than the normed text.


?


regards


Jonathan




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: TestSuite: Is this a bug?

Joe Wicentowski
Hi Jonathan,

> In the "case text()" the node is normed and if the string is empty an empty
> sequence is returned. Otherwise the original node is returned rather than
> the normed text.

I assume you're talking about this, right?

  https://github.com/eXist-db/exist/blob/develop/src/org/exist/xquery/lib/xqsuite/xqsuite.xql#L507-L521

It's hard to say.  It could be that the test is just trying to turn an
empty string into empty sequence and otherwise preserve the content of
the text node.

Joe

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: TestSuite: Is this a bug?

Jonathan Rowell

Hi Joe,


No, I think it is a bug, since the docs say that the contents get "normed". This code seems to leave the text node alone instead of substituting the new one.

The other question is, if a node in the heirarchy of XML being "normed" has an xml:space="preserve" attached to it, the surely the norm should not proceed further. There's no such test.

I think the original author (here Wolfgang) should have a look at it.

I'm trying to get my XML tested (see my mail on "Impracticallity with Test Suite assertEquals" (there's probably a bug there since the lerroring ine number does not appear)) and I stumbled against this one.


regards


Jonathan





From: Joe Wicentowski <[hidden email]>
Sent: Monday, March 20, 2017 7:28 PM
To: Jonathan Rowell
Cc: eXist open
Subject: Re: [Exist-open] TestSuite: Is this a bug?
 
Hi Jonathan,

> In the "case text()" the node is normed and if the string is empty an empty
> sequence is returned. Otherwise the original node is returned rather than
> the normed text.

I assume you're talking about this, right?

  https://github.com/eXist-db/exist/blob/develop/src/org/exist/xquery/lib/xqsuite/xqsuite.xql#L507-L521
github.com
exist - eXist Native XML Database and Application Platform



It's hard to say.  It could be that the test is just trying to turn an
empty string into empty sequence and otherwise preserve the content of
the text node.

Joe

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open