DotJoshJohnson / vscode-xml

XML Tools for Visual Studio Code
MIT License
324 stars 86 forks source link

XPath Evaluator has no output or unexpected output #377

Open don01001000 opened 2 years ago

don01001000 commented 2 years ago

Description The XPath evaluator does not work. If I use the output of Get Current XPath as the input for Evaluate XPath, it will create an output below with an "outputs" tab below rather than a new pane to the right. Running the same XPath evaluation causes it to simple echo the XPath expression but not show the results. After some amount of time, it seems to start working again. The list of outputs also gets filled up with XPath Results outputs, but these cannot be deleted.

It almost looks like the command never finishes processing.

Screenshots If applicable, add screenshots to help explain your problem.

Extension Version 2.5.1

VS Code Version 1.66.2

Operating System Windows

RyuuOujiXS commented 2 years ago

Output tab, Log (Extension Host): [exthost] [warning] Cannot execute xmlTools.evaluateXPath because there is no active text editor

ipaint commented 1 year ago

XPath Evaluator doesn't work.

justinpenguin45 commented 1 year ago

XPath doesnt work

ewen-r commented 9 months ago

I think the current document loses "focus" after running an xpath command. If you click back into your xml editor pane and then run the xpath command it seems to work.

Steps to reproduce...

  1. Open xml file and click into its editor pane.
  2. ctrl-shift-p evaluate xpath. Enter a valid path
  3. Results window shows correct xpath and value.
  4. Repeat step 2.
  5. Results window shows correct xpath but no value.
  6. FIX.... Click into xml file editor pane.
  7. Repeat step 2.
  8. Results window shows correct xpath and value.
schivmeister commented 6 months ago

I believe this is a core feature and would be great to have working. I have never got it working (Windows 11 + WSL2). Then I decided to look into all log outputs and discovered this under Window:

[error] [Extension Host] [xmldom error] element parse error: Error: invalid attribute:xmlns:default:abc 
@#[line:5,col:1]

So, the XML I'm looking at indeed has the namespace prefix abc. Trying a bare XML file with no namespaces, the query works in some way, resulting in some output in the XPath Results log, but only showing the values of elements under the queried XPath.

Given:

<Party>
    <Member>
        <Assignee>
            John
        </Assignee>
        <Assignee>
            Mary
        </Assignee>
    </Member>
</Party>

Querying /Party/Member yields:

XPath Query: /Party/Member

[Line 2] Member: 

            John

            Mary

Try the same at https://www.freeformatter.com/xpath-tester.html#before-output, you get:

<Member>
        <Assignee>
            John
        </Assignee>
        <Assignee>
            Mary
        </Assignee>
    </Member>

Which is the right kind of output we expect for the given query and data.