bug in vb.net sample code for new query
Monday, 30 August 2010 · 6 messages
JB
Jörg Beisiegel30 Aug 2010 13:48 #
Hi,
I have recently discovered baseX. First of all: This is an amazing project. Thank you very much. I have tested the UI and it works great with an incredible performance. Now I want to automize xqueries against a lager list in vb.net. I have downloaded (the most recent files) from "basex - Revision 2441: /trunk/api/etc/vb" The execute function works fine but the query function throws an error during New Query creation.
There appears to be a session object parameter missing:
in code:
Dim query As Query = session.Query(input)
'...calling the Query function.... no problem
Public Function Query(ByVal q As String) As Query
Return New Query(Me, q)
End Function
' ...then the Query function calls the Query class
' ... and here "s As Session" is required but missing.
Class Query
Private session As Session
Private id As String
Private nextItem As String
' see readme.txt
Public Sub New(s As Session, query As String)
session = s
session.stream.WriteByte(0)
session.Send(query)
id = session.Receive()
If Not session.Ok() Then
Throw New IOException(session.Receive())
End If
End Sub
The query results in the following error message in the console window:
" instead of 1 commands received.
8814 ms."
and in the VB.net direct window I get the message "Eine Ausnahme (erste Chance) des Typs "System.IO.IOException" ist in BaseX.exe aufgetreten."
Could you please help?
________________________________
[http://www.translatissimo.de/files/translatissimo_logo.png]<http://www.translatissimo.de/> Jörg Beisiegel Geschäftsführer / Managing Director
Localization Consulting
Desk phone: +49 7275 98933-22
mailto:joerg.beisiegel at translatissimo.de
translatissimo Übersetzung und Lokalisierung GbR
Bismarckstr. 19 * D-76870 Kandel * Germany
http://www.translatissimo.de<http://www.translatissimo.de/>
*** HINWEIS *** NOTE ***
Falls die Mail Anhänge enthält, bitte Empfang bestätigen.
If this mail contains attachments please confirm receipt.
AW
Andreas Weiler30 Aug 2010 14:02 #
Hi Jörg,
i guess you are using the BaseX61.jar from the website.
The vb.net binding is optimized for the latext minor release of BaseX. So you should use the newest version to run the BaseXServer.
Quoted text · Jörg Beisiegel · 1 line
> http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex/6.2.6/basex-6.2.6.jar
I hope this works,
otherwise let me know...
Kind regards,
Andreas
Quoted text · Jörg Beisiegel · 95 lines
Jörg Beisiegel schrieb: > Hi, > I have recently discovered baseX. First of all: This is an amazing > project. Thank you very much. I have tested the UI and it works great > with an incredible performance. > Now I want to automize xqueries against a lager list in vb.net. > I have downloaded (the most recent files) from "basex - Revision 2441: > /trunk/api/etc/vb" > The execute function works fine but the query function throws an error > during New Query creation. > > There appears to be a session object parameter missing: > > in code: > > Dim query As Query = session.Query(input) > > '...calling the Query function.... no problem > > Public Function Query(ByVal q As String) As Query > > Return New Query(Me, q) > > End Function > > ' ...then the Query function calls the Query class > > ' ... and here "s As Session" is required but missing. > > Class Query > > Private session As Session > > Private id As String > > Private nextItem As String > > ' see readme.txt > > Public Sub New(s As Session, query As String) > > session = s > > session.stream.WriteByte(0) > > session.Send(query) > > id = session.Receive() > > If Not session.Ok() Then > > Throw New IOException(session.Receive()) > > End If > > End Sub > > > > The query results in the following error message in the console window: > > " instead of 1 commands received. > > 8814 ms." > > and in the VB.net direct window I get the message "Eine Ausnahme > (erste Chance) des Typs "System.IO.IOException" ist in BaseX.exe > aufgetreten." > > > > Could you please help? > > > ------------------------------------------------------------------------ > <http://www.translatissimo.de/> Jörg Beisiegel > Geschäftsführer / Managing Director > Localization Consulting > Desk phone: +49 7275 98933-22 > mailto:joerg.beisiegel at translatissimo.de > translatissimo Übersetzung und Lokalisierung GbR > Bismarckstr. 19 * D-76870 Kandel * Germany > http://www.translatissimo.de <http://www.translatissimo.de/> > *** HINWEIS *** NOTE *** > Falls die Mail Anhänge enthält, bitte Empfang bestätigen. > If this mail contains attachments please confirm receipt. > > > > ------------------------------------------------------------------------ > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
JB
Jörg Beisiegel30 Aug 2010 14:31 #
Hi Andreas,
thank you for your fast help.
basex-6.2.6.jar does the magic. The test xquery runs perfectly ... Issue resolved with the new version
May I bother you with another issue I have come over?
It's about the GU tool.
I am performing fulltext xqueries on large mtf files. Thank you for the extensive xquery support. The query functionallity is really impressive. The tool is extremly performant. Now I have come over an xliff file that contains namespaces. At file import into the db I activated the internal parser, parsing of entities and DTDs, chopping of whitespaces, text index, attribute index, path summary and all full text options except TF/IDF scoring and Stopword list.
The root element looks like:
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:anotherNamespace="http://www.anotherNameSpace.com/some/element" version="1.2">
I can perform a full text search on all attributes such as //@id or count(//@id) returning over 6000 hits. Performing a query for an element i.e. //note/ does not find any hits although there are note elements containing text in the file.
Do you have any suggestions?
Thanks again for you help.
Regards,
Jörg
________________________________
Jörg Beisiegel
Geschäftsführer / Managing Director
Localization Consulting
Desk phone: +49 7275 98933-22
mailto:joerg.beisiegel at translatissimo.de
translatissimo Übersetzung und Lokalisierung GbR
Bismarckstr. 19 * D-76870 Kandel * Germany
http://www.translatissimo.de
*** HINWEIS *** NOTE ***
Falls die Mail Anhänge enthält, bitte Empfang bestätigen.
If this mail contains attachments please confirm receipt.
Quoted text · Andreas Weiler · 112 lines
-----Ursprüngliche Nachricht----- Von: Andreas Weiler [mailto:andreas.weiler at uni-konstanz.de] Gesendet: Montag, 30. August 2010 14:03 An: Jörg Beisiegel Cc: basex-talk at mailman.uni-konstanz.de Betreff: Re: [basex-talk] bug in vb.net sample code for new query Hi Jörg, i guess you are using the BaseX61.jar from the website. The vb.net binding is optimized for the latext minor release of BaseX. So you should use the newest version to run the BaseXServer. > http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex/6.2.6/ > basex-6.2.6.jar I hope this works, otherwise let me know... Kind regards, Andreas Jörg Beisiegel schrieb: > Hi, > I have recently discovered baseX. First of all: This is an amazing > project. Thank you very much. I have tested the UI and it works great > with an incredible performance. > Now I want to automize xqueries against a lager list in vb.net. > I have downloaded (the most recent files) from "basex - Revision 2441: > /trunk/api/etc/vb" > The execute function works fine but the query function throws an error > during New Query creation. > > There appears to be a session object parameter missing: > > in code: > > Dim query As Query = session.Query(input) > > '...calling the Query function.... no problem > > Public Function Query(ByVal q As String) As Query > > Return New Query(Me, q) > > End Function > > ' ...then the Query function calls the Query class > > ' ... and here "s As Session" is required but missing. > > Class Query > > Private session As Session > > Private id As String > > Private nextItem As String > > ' see readme.txt > > Public Sub New(s As Session, query As String) > > session = s > > session.stream.WriteByte(0) > > session.Send(query) > > id = session.Receive() > > If Not session.Ok() Then > > Throw New IOException(session.Receive()) > > End If > > End Sub > > > > The query results in the following error message in the console window: > > " instead of 1 commands received. > > 8814 ms." > > and in the VB.net direct window I get the message "Eine Ausnahme > (erste Chance) des Typs "System.IO.IOException" ist in BaseX.exe > aufgetreten." > > > > Could you please help? > > > ------------------------------------------------------------------------ > <http://www.translatissimo.de/> Jörg Beisiegel > Geschäftsführer / Managing Director > Localization Consulting > Desk phone: +49 7275 98933-22 > mailto:joerg.beisiegel at translatissimo.de > translatissimo Übersetzung und Lokalisierung GbR Bismarckstr. 19 * > D-76870 Kandel * Germany http://www.translatissimo.de > <http://www.translatissimo.de/> > *** HINWEIS *** NOTE *** > Falls die Mail Anhänge enthält, bitte Empfang bestätigen. > If this mail contains attachments please confirm receipt. > > > > ---------------------------------------------------------------------- > -- > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
AW
Andreas Weiler30 Aug 2010 14:36 #
Hi Jörg,
Quoted text · Jörg Beisiegel · 1 line
> Performing a query for an element i.e. //note/ does not find any hits although there are note elements containing text in the file.
probably using //note/text() will return your results.
In the top text input line there is a suggestions feature included which could help u in such cases.
Kind regards,
Andreas
Quoted text · Jörg Beisiegel · 166 lines
Jörg Beisiegel schrieb: > Hi Andreas, > thank you for your fast help. > basex-6.2.6.jar does the magic. The test xquery runs perfectly ... Issue resolved with the new version > > May I bother you with another issue I have come over? > > It's about the GU tool. > > I am performing fulltext xqueries on large mtf files. Thank you for the extensive xquery support. The query functionallity is really impressive. The tool is extremly performant. Now I have come over an xliff file that contains namespaces. At file import into the db I activated the internal parser, parsing of entities and DTDs, chopping of whitespaces, text index, attribute index, path summary and all full text options except TF/IDF scoring and Stopword list. > > The root element looks like: > <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:anotherNamespace="http://www.anotherNameSpace.com/some/element" version="1.2"> > > I can perform a full text search on all attributes such as //@id or count(//@id) returning over 6000 hits. > Performing a query for an element i.e. //note/ does not find any hits although there are note elements containing text in the file. > > Do you have any suggestions? > > > Thanks again for you help. > > Regards, > Jörg > > > > ________________________________ > > Jörg Beisiegel > Geschäftsführer / Managing Director > Localization Consulting > Desk phone: +49 7275 98933-22 > mailto:joerg.beisiegel at translatissimo.de > translatissimo Übersetzung und Lokalisierung GbR > Bismarckstr. 19 * D-76870 Kandel * Germany > http://www.translatissimo.de > > *** HINWEIS *** NOTE *** > Falls die Mail Anhänge enthält, bitte Empfang bestätigen. > If this mail contains attachments please confirm receipt. > > -----Ursprüngliche Nachricht----- > Von: Andreas Weiler [mailto:andreas.weiler at uni-konstanz.de] > Gesendet: Montag, 30. August 2010 14:03 > An: Jörg Beisiegel > Cc: basex-talk at mailman.uni-konstanz.de > Betreff: Re: [basex-talk] bug in vb.net sample code for new query > > > Hi Jörg, > > i guess you are using the BaseX61.jar from the website. > The vb.net binding is optimized for the latext minor release of BaseX. > So you should use the newest version to run the BaseXServer. > >> http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex/6.2.6/ >> basex-6.2.6.jar >> > I hope this works, > otherwise let me know... > > Kind regards, > Andreas > > > Jörg Beisiegel schrieb: > >> Hi, >> I have recently discovered baseX. First of all: This is an amazing >> project. Thank you very much. I have tested the UI and it works great >> with an incredible performance. >> Now I want to automize xqueries against a lager list in vb.net. >> I have downloaded (the most recent files) from "basex - Revision 2441: >> /trunk/api/etc/vb" >> The execute function works fine but the query function throws an error >> during New Query creation. >> >> There appears to be a session object parameter missing: >> >> in code: >> >> Dim query As Query = session.Query(input) >> >> '...calling the Query function.... no problem >> >> Public Function Query(ByVal q As String) As Query >> >> Return New Query(Me, q) >> >> End Function >> >> ' ...then the Query function calls the Query class >> >> ' ... and here "s As Session" is required but missing. >> >> Class Query >> >> Private session As Session >> >> Private id As String >> >> Private nextItem As String >> >> ' see readme.txt >> >> Public Sub New(s As Session, query As String) >> >> session = s >> >> session.stream.WriteByte(0) >> >> session.Send(query) >> >> id = session.Receive() >> >> If Not session.Ok() Then >> >> Throw New IOException(session.Receive()) >> >> End If >> >> End Sub >> >> >> >> The query results in the following error message in the console window: >> >> " instead of 1 commands received. >> >> 8814 ms." >> >> and in the VB.net direct window I get the message "Eine Ausnahme >> (erste Chance) des Typs "System.IO.IOException" ist in BaseX.exe >> aufgetreten." >> >> >> >> Could you please help? >> >> >> ------------------------------------------------------------------------ >> <http://www.translatissimo.de/> Jörg Beisiegel >> Geschäftsführer / Managing Director >> Localization Consulting >> Desk phone: +49 7275 98933-22 >> mailto:joerg.beisiegel at translatissimo.de >> translatissimo Übersetzung und Lokalisierung GbR Bismarckstr. 19 * >> D-76870 Kandel * Germany http://www.translatissimo.de >> <http://www.translatissimo.de/> >> *** HINWEIS *** NOTE *** >> Falls die Mail Anhänge enthält, bitte Empfang bestätigen. >> If this mail contains attachments please confirm receipt. >> >> >> >> ---------------------------------------------------------------------- >> -- >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > >
LW
Hi Jörg,
Quoted text · Jörg Beisiegel · 6 lines
Am 30.08.2010 14:31, schrieb Jörg Beisiegel: > The root element looks like: > <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:anotherNamespace="http://www.anotherNameSpace.com/some/element" version="1.2"> > > I can perform a full text search on all attributes such as //@id or count(//@id) returning over 6000 hits. > Performing a query for an element i.e. //note/ does not find any hits although there are note elements containing text in the file.
that's a common misconception of people new to namespaces in XQuery. The namespace without prefix, e.g.
Quoted text · Jörg Beisiegel · 1 line
> xmlns="urn:oasis:names:tc:xliff:document:1.2"
is the default namespace of all the elements below it. As the <node/>-elements thus have a non-empty namespace, they aren't found by the query //node (implying am empty NS).
There are two solutions:
1. As this is the default element namespace, you could simply declare it in your query:
Quoted text · Jörg Beisiegel · 3 lines
> declare default element namespace > "urn:oasis:names:tc:xliff:document:1.2"; > //note
2. Generally you can also bind it to a prefix and use that in your query:
Quoted text · Jörg Beisiegel · 2 lines
> declare namespace xliff = "urn:oasis:names:tc:xliff:document:1.2"; > //xliff:note
I hope this helps,
Cheers Leo
JB
Jörg Beisiegel30 Aug 2010 15:21 #
Hi Leonard,
This makes my query work. I was experimenting with namespace declarations bevor posting the query but I made a syntax mistake trying to assign a name to the standard namespace as suggested by the xquery standard (i.e. Declare namespace xliff = "....". This did not work.
Thank you very much!
________________________________
Jörg Beisiegel
Geschäftsführer / Managing Director
Localization Consulting
Desk phone: +49 7275 98933-22
mailto:joerg.beisiegel at translatissimo.de
translatissimo Übersetzung und Lokalisierung GbR
Bismarckstr. 19 * D-76870 Kandel * Germany
http://www.translatissimo.de
*** HINWEIS *** NOTE ***
Falls die Mail Anhänge enthält, bitte Empfang bestätigen.
If this mail contains attachments please confirm receipt.
Quoted text · Leonard Wörteler · 28 lines
-----Ursprüngliche Nachricht----- Von: Leonard Wörteler [mailto:leo at woerteler.de] Gesendet: Montag, 30. August 2010 15:11 An: basex-talk at mailman.uni-konstanz.de Cc: Jörg Beisiegel Betreff: Re: [basex-talk] bug in vb.net sample code for new query Hi Jörg, Am 30.08.2010 14:31, schrieb Jörg Beisiegel: > The root element looks like: > <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" > xmlns:anotherNamespace="http://www.anotherNameSpace.com/some/element" > version="1.2"> > > I can perform a full text search on all attributes such as //@id or count(//@id) returning over 6000 hits. > Performing a query for an element i.e. //note/ does not find any hits although there are note elements containing text in the file. that's a common misconception of people new to namespaces in XQuery. The namespace without prefix, e.g. > xmlns="urn:oasis:names:tc:xliff:document:1.2" is the default namespace of all the elements below it. As the <node/>-elements thus have a non-empty namespace, they aren't found by the query //node (implying am empty NS). There are two solutions: 1. As this is the default element namespace, you could simply declare it in your query: > declare default element namespace > "urn:oasis:names:tc:xliff:document:1.2"; > //note 2. Generally you can also bind it to a prefix and use that in your query: > declare namespace xliff = "urn:oasis:names:tc:xliff:document:1.2"; > //xliff:note I hope this helps, Cheers Leo
Written for BaseX 6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery