0

How do I query the book titles with the BaseX GUI using xpath?

database

Sample XML which loaded into the database:

<?xml version="1.0" encoding="UTF-8"?>

<bookstore>

<book category="cooking">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>

<book category="children">
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

<book category="web">
  <title lang="en">XQuery Kick Start</title>
  <author>James McGovern</author>
  <author>Per Bothner</author>
  <author>Kurt Cagle</author>
  <author>James Linn</author>
  <author>Vaidyanathan Nagarajan</author>
  <year>2003</year>
  <price>49.99</price>
</book>

<book category="web">
  <title lang="en">Learning XML</title>
  <author>Erik T. Ray</author>
  <year>2003</year>
  <price>39.95</price>
</book>

</bookstore> 

directions:

Select all the titles

The following example selects all the title nodes: Example

/bookstore/book/title 

Where and how do I run that query from within BaseX?

rickhg12hs
  • 10,638
  • 6
  • 24
  • 42
Thufir
  • 8,216
  • 28
  • 125
  • 273
  • What do you mean by `xbase`? – rickhg12hs Jan 03 '19 at 12:05
  • pardon, basex I mean. – Thufir Jan 03 '19 at 14:27
  • `xpath` is a subset of `xquery`, yes? I imagine `xpath` will work anywhere you can use an `xquery`. I've used `xpath`s from the [`XQuery` Input Bar](http://docs.basex.org/wiki/Graphical_User_Interface#Input_Bar) and also from the editor. I believe you can also select an xpath from the Explorer and view a selection's `xpath` in the MAP. – rickhg12hs Jan 03 '19 at 16:33
  • After clicking a selection so that the result populates with desired output how do I replicate that with an `xpath` query from the input bar? Rather than run a query first, I want to find the result, then generate the query for that result. – Thufir Jan 03 '19 at 18:13
  • 1
    Hmmm, I'm not aware of a way to select a specific element after clicking in a BaseX visualization. You can "Copy Path" from a visualization but I think it's path is for all elements at that level, etc. I.e., this should work fine for selecting all titles in your example, but I don't think BaseX will calculate a xpath for a specific title. – rickhg12hs Jan 03 '19 at 19:04
  • I was thinking of the `console` in a browser, how that will calculate an `xpath` for a title. The visualization from BaseX is quite helpful. – Thufir Jan 03 '19 at 19:30

0 Answers0