DeltaXML / vscode-xslt-tokenizer

VSCode extension for highlighting XSLT and XPath (upto 3.0/3.1)
MIT License
46 stars 4 forks source link

Go to the item from collection #122

Open ashahabov opened 1 year ago

ashahabov commented 1 year ago

For example, the XPath /body//div returns a collection with 10 elements. Is it possible to go to the 3rd element from this collection?

XML: Goto XPath -> (/body//div)[3] doesn't work.

pgfearo commented 1 year ago

The Goto XPath command just manages simple XPath steps - not full XPath expressions.

Built-In Symbol Navigation

The standard VS Code Goto Symbol command is probably the closest to what you need.

After pressing Shift-CMD-O and entering div in the edit window you should something like the screenshot below:

Screenshot 2023-04-25 at 16 44 42

You can then navigate the dropdown list of div symbols. The outline (tree) view and breadcrumbs views offer other navigation methods.

Admittedly, these methods aren't too useful if you have a very large number of div elements and you want, for example, the 298th div element selected.

XPath Notebook

Another approach would be to use the companion XPath Notebook extension - unfortunately a recent change in VS Code broke direct navigation of XPath results (I've submitted an issue to fix this) but in the mean time you could copy and paste the generated XPath /html[1]/section[1]/section[1]/div[1] into the Goto XPath edit window:

Screenshot 2023-04-25 at 16 56 36