Namespaces ...

Friday, 21 March 2014 · 3 messages
ML
Marco Lettere21 Mar 2014 09:58 #
Hello all, I've a few questions related to namespaces. I've noticed that on one of the info panels of the the GUI all the namespaces of the documents stored in a DB are listed. Is there a way to get this information from inside an XQuery? My problem is that I have to perform queries that are dynamically generated on a heterogeneuos set of documents. By now I have to store somewhere an association between one input parameter of the query and a corresponding set of namespaces to be used. This is then transformed into a list of "declare namespace ..." statements. I thought I could pregenerate a declare statement for every namespace in the DB by default thus avoiding to maintain the association. Would there be a significant impact on query or query compilation performance? Thanks, Marco.
AG
Arve Gengelbach21 Mar 2014 11:22 #
Hi Marco, you could generate this list using the functions fn:in-scope-prefixes#1 and fn:namespace-uri-for-prefix#2 As far as I know there is no such function. But maybe I am wrong – as there is plenty of undiscovered features in BaseX :) hope this helps Arve
Quoted text · Marco Lettere · 12 lines
On 21 Mar 2014, at 09:58, Marco Lettere <marco.lettere at dedalus.eu> wrote: > Hello all, > I've a few questions related to namespaces. I've noticed that on one of the info panels of the the GUI all the namespaces of the documents stored in a DB are listed. Is there a way to get this information from inside an XQuery? > My problem is that I have to perform queries that are dynamically generated on a heterogeneuos set of documents. By now I have to store somewhere an association between one input parameter of the query and a corresponding set of namespaces to be used. This is then transformed into a list of "declare namespace ..." statements. > I thought I could pregenerate a declare statement for every namespace in the DB by default thus avoiding to maintain the association. > Would there be a significant impact on query or query compilation performance? > Thanks, > Marco. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Christian Grünin reply to Marco Lettere, 21 Mar 2014, 09:5821 Mar 2014 11:22 #
Hi Marco,
Quoted text · Marco Lettere · 3 lines
> I've a few questions related to namespaces. I've noticed that on one of the > info panels of the the GUI all the namespaces of the documents stored in a > DB are listed. Is there a way to get this information from inside an XQuery?
Something like this may help:
  let $names := db:open('db')//*/node-name()
  let $ns := map:new(
    for $name in $names
    return map {
      prefix-from-QName($name):
      namespace-uri-from-QName($name) }
  )
  return map:serialize($ns)
Best, Christian
Quoted text · Marco Lettere · 15 lines
> My problem is that I have to perform queries that are dynamically generated > on a heterogeneuos set of documents. By now I have to store somewhere an > association between one input parameter of the query and a corresponding set > of namespaces to be used. This is then transformed into a list of "declare > namespace ..." statements. > I thought I could pregenerate a declare statement for every namespace in the > DB by default thus avoiding to maintain the association. > Would there be a significant impact on query or query compilation > performance? > Thanks, > Marco. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

⚡Generated with XQuery