Extracting namespace from xml
Saturday, 18 June 2016 · 2 messages
HP
Henning Phan18 Jun 2016 01:47 #
Hello,
When using basexgui, after opening a database and go to properties and then information one can see all the namespaces in the document. When not using the gui how does one extract the same information? Been reading the wiki but I have not been able to find a module or a function that accomplish exactly that. Also Im trying to use the information from
index:facets("db") to create a simple visual interface so users, without xquery knowledge, can click on nodes and add filters and those choices are then translated into xquery commands. Any information in this area would greatly appreciated.
- Henning
Virusfritt. www.avast.comCG
Christian Grün18 Jun 2016 14:23 #
Hi Henning,
Quoted text · Henning Phan · 1 line
> When using basexgui, after opening a database and go to properties and then information one can see all the namespaces in the document. When not using the gui how does one extract the same information?
the INFO STORAGE command will list the database structure and, at the very end, the used namespaces.
Apart from that, you can always use XQuery to dump namespaces. If you don’t care about namespace hierarchy, and namespaces overwriting other namespaces, the attached query may help.
Quoted text · Henning Phan · 1 line
> Also Im trying to use the information from index:facets("db") to create a simple visual interface so users, without xquery knowledge, can click on nodes and add filters and those choices are then translated into xquery commands. Any information in this area would greatly appreciated.
What information do you need?
Christian
______________________________________________
distinct-values(
for $node in //*/(self::*, attribute::*)
let $name := $node/node-name()
let $uri := namespace-uri-from-QName($name)
where $uri
let $pref := prefix-from-QName($name)
return if ($pref) then (
$pref || ' = ' || '"' || $uri || '"'
) else (
'"' || $uri || '"'
)
)Example document:
<a:a xmlns:a='A'>
<b xmlns='B'>
<c c:c='c' xmlns:c='C'/>
</b>
</a:a>Output (similar to the one you find in the database properties dialog):
a = "A"
"B"
c = "C"
Quoted text · Henning Phan · 12 lines
On Sat, Jun 18, 2016 at 1:47 AM, Henning Phan <henningphan at hotmail.com> wrote: > > Hello, > > When using basexgui, after opening a database and go to properties and then information one can see all the namespaces in the document. When not using the gui how does one extract the same information? Been reading the wiki but I have not been able to find a module or a function that accomplish exactly that. > > Also Im trying to use the information from index:facets("db") to create a simple visual interface so users, without xquery knowledge, can click on nodes and add filters and those choices are then translated into xquery commands. Any information in this area would greatly appreciated. > > > - Henning > > Virusfritt. www.avast.com
Written for BaseX 8.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery