Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] typeswitch on CDATA logs error(s) "Unknown node type: 4" #4740

Closed
line-o opened this issue Feb 11, 2023 · 1 comment · Fixed by #4741
Closed

[BUG] typeswitch on CDATA logs error(s) "Unknown node type: 4" #4740

line-o opened this issue Feb 11, 2023 · 1 comment · Fixed by #4741

Comments

@line-o
Copy link
Member

line-o commented Feb 11, 2023

Describe the bug

When traversing node-trees with CDATA the exist.log is littered with

2023-02-10 12:18:46,413 [qtp918738473-4154] ERROR (StoredNode.java [getQName]:218) - Unknown node type: 4

Even though the node type 4 is known (it's a CDATA node).

UPDATE

Turns out that this issue also causes an NPE when attempting to get the name of the CDATA section:

doc('has-cdata.html')//script/node()/name()

Expected behavior

The log not to be littered with false errors.
In memory CDATA section returns an empty string, that should happen for stored ones as well.

To Reproduce

With a simple main module that traverses a node-tree using typeswitch (traverse.xq).

xquery version "3.1";

declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method "html";
declare option output:html-version "5";
declare option output:media-type "text/html";

declare function local:traverse ($node as node()) {
    typeswitch($node)
        case document-node() return 
            $node/node() ! local:traverse(.)
        case element() return
            element { node-name($node) } {
                $node/@*,
                $node/node() ! local:traverse(.)
            }
        default return $node
};

local:traverse(doc('has-cdata.html'))

And an HTML file with a CDATA node (has-cdata.html).

<html>
    <body>
        <script type="text/javascript"><![CDATA[ console.log(true && 1 < 2) ]]></script>
    </body>
</html>
  1. store both files in /db/apps/test
    NOTE: you cannot use eXide to store the HTML file because the CDATA node will be swallowed.
    rest or XML-RPC (I used xst) will work though (as does when uploading it within a XAR).
    (see [BUG] HTML is modified when saved eXide#593)
  2. curl http://localhost:8080/exist/apps/test/traverse.xq
  3. check exist.log it should now contain three consecutive error message with Unknown node type: 4

Context (please always complete the following information)

Build: eXist-6.2.0
Java: 1.8.0_362 (Azul Systems, Inc.)
OS: Mac OS X 12.6.3 (aarch64)

Additional context

  • How is eXist-db installed? built from source
  • Any custom changes in e.g. conf.xml? none
@line-o
Copy link
Member Author

line-o commented Feb 11, 2023

I create a gist for easier setup and testing https://gist.github.com/line-o/4896d177c5d9b429d08c81b24c3fda3c

line-o added a commit to line-o/exist that referenced this issue Feb 11, 2023
fixes eXist-db#4740

Do not log an error each time typeswitch is called on a CDATA section.
line-o added a commit to line-o/exist that referenced this issue Feb 12, 2023
fixes eXist-db#4740

Do not log an error each time typeswitch is called on a CDATA section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant