After creating and populating a database:
try { new DropDB(databaseName).execute(context); } catch (BaseXException ex) {
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex); LOG.fine("no databases to drop"); }
how would I query it? The query:
db:open("note")//note
thanks,
Thufir
There are various open issues in your question:
After creating and populating a database:
It seems that you are actualling dropping an existing database in your Java example.
how would I query it?
If you use Java, there is quite a variety on running queries. Maybe you could give us some insight into your use case first? For example, what do you want to do with the result?
Thanks in advance Christian
On 2019-01-03 6:00 a.m., Christian Grün wrote:
If you use Java, there is quite a variety on running queries. Maybe you could give us some insight into your use case first? For example, what do you want to do with the result?
Yes, bit spaghetti-ish, pardon. The notion is to first drop the database, then populate, then query. For grabbing xml from w3schools, popping in a database, running an xquery, that works fine.
Moving to html, it then sortof works. The db is dropped, a db is created and then populated. Browsing in the GUI I can see, for example, a list of book categories -- so there's data to work from. (Which tagsoup has fixed so that basex can parse it.)
That's really the end goal: just running XQuery against html.
The only query I can get working against the html is for the query string to be "text()" or perhaps "/text()" which then returns all the html. Rather, I'd want to traverse to pick out specific parts.
It's related, to a degree, with Selenium efforts.
---
The upshot being that the way tagsoup fixes malformed html either causes (me) problems with running xquery queries, or, more likely, I'm not understanding how to run xpath and xquery against the db properly.
The GUI is very interesting in this respect because it allows me to visualize the raw data, it's "clickable", and I can run type xpath queries right in the GUI.
However, the *only* xpath query I can get results on is "text()". Not so with "raw" xml from w3schools. With that xml I can drill down to varying degrees as expected.
-------
Either tagsoup is mashing the html too extremely, or it's my lack of knowledge.
Hey, I appreciate the input. Hope I made sense.
-Thufir
The project is:
https://github.com/THUFIR/helloWorldBaseX
While I've been through many of the Java examples it's also entirely possible that I overlooked something. Learning XQuery and Xpath syntax and capabilities.
-thufir
Hi Thufir,
That's really the end goal: just running XQuery against html.
In that case, you can simply use "new XQuery(...).execute(ctx)". Any query that works in the GUI can be supplied as argument.
The only query I can get working against the html is for the query string to be "text()" or perhaps "/text()" which then returns all the html. Rather, I'd want to traverse to pick out specific parts.
If you want to process the single results of your query, you should have a look at the examples [1], specifically [2].
Best, Christian
[1] http://docs.basex.org/wiki/Java_Examples [2] https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/or...
basex-talk@mailman.uni-konstanz.de