querying xml with namespaces.
Wednesday, 1 March 2017 · 4 messages
WW
Witold E Wolski1 Mar 2017 10:17 #
Apologies if I am hard to understand but I am new to the XML querying. I would like to query an XML with namespaces.
As I did learn, you can do it in BaseX by including an *: in your path, e.g.,
db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/*:MzIdentML/*:SequenceCollection/*:PeptideBut I would like to be more specific than *. I did search the schema for the XML and all I found related to the search term namespace is not brief name, but:
targetNamespace="http://psidev.info/psi/pi/mzIdentML/1.1"
I did also found the following entry on stack overflow:
http://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-xpath
And If I interpret the answer there correctly somehow one can register his own acronym for a namespace?
Is this correct? So I am wondering if I could do the same somehow in BaseX?
Alternatively, I am wondering if I could tell BaseX to disable namespace checking?
Thank you a lot
--
Witold Eryk Wolski
FE
Fabrice ETANCHAUD1 Mar 2017 10:30 #
Hi, from what I remember,
You can get rid of namespace wildcards if you just declare a default element namespace for your query :
declare default element namespace 'http://psidev.info/psi/pi/mzIdentML/1.1';
db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/MzIdentML/SequenceCollection/PeptideAnother way is to declare explicitly your namespace (here named mz but you could choose any other name) :
declare namespace mz = 'http://psidev.info/psi/pi/mzIdentML/1.1';
db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/mz:MzIdentML/mz:SequenceCollection/mz:PeptideBest regards,
Fabrice Etanchaud
-----Message d'origine-----
Quoted text · Witold E Wolski · 18 lines
De : basex-talk-bounces at mailman.uni-konstanz.de [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de Witold E Wolski Envoyé : mercredi 1 mars 2017 10:18 À : basex-talk at mailman.uni-konstanz.de Objet : [basex-talk] querying xml with namespaces. Apologies if I am hard to understand but I am new to the XML querying. I would like to query an XML with namespaces. As I did learn, you can do it in BaseX by including an *: in your path, e.g., db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/*:MzIdentML/*:SequenceCollection/*:Peptide But I would like to be more specific than *. I did search the schema for the XML and all I found related to the search term namespace is not brief name, but: targetNamespace="http://psidev.info/psi/pi/mzIdentML/1.1" I did also found the following entry on stack overflow: http://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-xpath And If I interpret the answer there correctly somehow one can register his own acronym for a namespace? Is this correct? So I am wondering if I could do the same somehow in BaseX? Alternatively, I am wondering if I could tell BaseX to disable namespace checking? Thank you a lot -- Witold Eryk Wolski
WW
Witold E Wolski1 Mar 2017 10:57 #
Awesome. Both work! Thank you.
Quoted text · Fabrice ETANCHAUD · 47 lines
On 1 March 2017 at 10:30, Fabrice ETANCHAUD <fetanchaud at groupefbo.com> wrote: > Hi, from what I remember, > > You can get rid of namespace wildcards if you just declare a default element namespace for your query : > > declare default element namespace 'http://psidev.info/psi/pi/mzIdentML/1.1'; > > db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/MzIdentML/SequenceCollection/Peptide > > Another way is to declare explicitly your namespace (here named mz but you could choose any other name) : > > declare namespace mz = 'http://psidev.info/psi/pi/mzIdentML/1.1'; > > db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/mz:MzIdentML/mz:SequenceCollection/mz:Peptide > > Best regards, > Fabrice Etanchaud > > -----Message d'origine----- > De : basex-talk-bounces at mailman.uni-konstanz.de [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de Witold E Wolski > Envoyé : mercredi 1 mars 2017 10:18 > À : basex-talk at mailman.uni-konstanz.de > Objet : [basex-talk] querying xml with namespaces. > > Apologies if I am hard to understand but I am new to the XML querying. > I would like to query an XML with namespaces. > > As I did learn, you can do it in BaseX by including an *: in your path, e.g., > > db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/*:MzIdentML/*:SequenceCollection/*:Peptide > > > But I would like to be more specific than *. I did search the schema for the XML and all I found related to the search term namespace is not brief name, but: > targetNamespace="http://psidev.info/psi/pi/mzIdentML/1.1" > > I did also found the following entry on stack overflow: > http://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-xpath > > And If I interpret the answer there correctly somehow one can register his own acronym for a namespace? > Is this correct? So I am wondering if I could do the same somehow in BaseX? > > Alternatively, I am wondering if I could tell BaseX to disable namespace checking? > > Thank you a lot > > -- > Witold Eryk Wolski
--
Witold Eryk Wolski
FE
Fabrice ETANCHAUD1 Mar 2017 11:14 #
You are right,
BaseX and XQuery are awesome !
And one day you should take a look at REST-XQ and XForms (like Orbeon) to embrace the whole picture...
Best regards,
Fabrice
-----Message d'origine-----
Quoted text · Witold E Wolski · 62 lines
De : Witold E Wolski [mailto:wewolski at gmail.com] Envoyé : mercredi 1 mars 2017 10:58 À : Fabrice ETANCHAUD <fetanchaud at groupefbo.com> Cc : basex-talk at mailman.uni-konstanz.de Objet : Re: [basex-talk] querying xml with namespaces. Awesome. Both work! Thank you. On 1 March 2017 at 10:30, Fabrice ETANCHAUD <fetanchaud at groupefbo.com> wrote: > Hi, from what I remember, > > You can get rid of namespace wildcards if you just declare a default element namespace for your query : > > declare default element namespace > 'http://psidev.info/psi/pi/mzIdentML/1.1'; > > db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/MzId > entML/SequenceCollection/Peptide > > Another way is to declare explicitly your namespace (here named mz but you could choose any other name) : > > declare namespace mz = 'http://psidev.info/psi/pi/mzIdentML/1.1'; > > db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/mz:M > zIdentML/mz:SequenceCollection/mz:Peptide > > Best regards, > Fabrice Etanchaud > > -----Message d'origine----- > De : basex-talk-bounces at mailman.uni-konstanz.de > [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de > Witold E Wolski Envoyé : mercredi 1 mars 2017 10:18 À : > basex-talk at mailman.uni-konstanz.de > Objet : [basex-talk] querying xml with namespaces. > > Apologies if I am hard to understand but I am new to the XML querying. > I would like to query an XML with namespaces. > > As I did learn, you can do it in BaseX by including an *: in your > path, e.g., > > db:open("myrimatchSubset","20160312_17_B3_myrimatch_2_2_140.xml")/*:Mz > IdentML/*:SequenceCollection/*:Peptide > > > But I would like to be more specific than *. I did search the schema for the XML and all I found related to the search term namespace is not brief name, but: > targetNamespace="http://psidev.info/psi/pi/mzIdentML/1.1" > > I did also found the following entry on stack overflow: > http://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-x > path > > And If I interpret the answer there correctly somehow one can register his own acronym for a namespace? > Is this correct? So I am wondering if I could do the same somehow in BaseX? > > Alternatively, I am wondering if I could tell BaseX to disable namespace checking? > > Thank you a lot > > -- > Witold Eryk Wolski -- Witold Eryk Wolski
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery