After installing, open a buffer containing an XML document, and call:
M-x xquery-tool-query RET
. Then enter an XPath that works for your
document.
For simple cases, an XQuery preamble including namespaces will be set automatically.
Calling M-x xquery-tool-query RET //title RET RET
with this document
(see http://www.w3schools.com/xsl/xpath_syntax.asp) open:
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
<title lang="en">The Colour of Magic</title>
<price unit="euro">29.99</price>
</book>
<book>
<title lang="en">Learning XML</title>
<price unit="euro">39.95</price>
</book>
</bookstore>
Will give you a buffer with these results:
<title lang="en">Harry Potter</title>
<title lang="en">Learning XML</title>
The results are linked back to the original buffer when possible.
- saxon basic (http://saxon.sourceforge.net/; on Debian,
aptitude install libsaxonb-java
)
- Open an XML document, like the one in Simple XML Doc
- Run an xquery on the buffer
- Watch out for links back to the main document
- NOTE: Links are to locations in the buffer, not to the elements as such. That’s why editing around point A might move the text that follows, making the links invalid.
- Solution: either
reverse()
your xquery (later occurrences will be at the top), or go through the list of results backwards.
- You can now work on the results, for example:
- Keyboard macros (try
F3
andF4
)
- Keyboard macros (try
In GNU/Emacs (with melpa packaging set up):
M-x package-install RET xquery-tool
This will install the Melpa package: https://melpa.org/#/xquery-tool
To install from git, clone this repository and make sure to load file:xquery-tool.el (see Testing below for an example).
emacs --no-init-file --no-site-file -batch \
-l xquery-tool.el \
-l tests/xquery-tool-tests.el \
-f ert-run-tests-batch-and-exit