Maybe some of the characters need to be escaped in c#? Make sure that the string:
http://www.aaa.com/namespace/aa/bb/ (or whatever is your namespace) is the string you are actually producing. If the string is not 100% correct, then the namespace will be wrong and the query will return empty. -Danny -----Original Message----- From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of Mailing Lists Mail Sent: Wednesday, September 12, 2012 3:32 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Help with namespace Declaration in Marklogic Hi Danny, thanks for responding.. Both the queries run fine and return correct results in the M/L query Console with correct results.. its only thr c# that Query2 produces valid results but Query1 brings out empty result. > On Wed, Sep 12, 2012 at 11:19 PM, Danny Sokolsky <danny.sokol...@marklogic.com> wrote: > A couple of point here: > > * I recommend you trying to run each of these in Query Console to help you > understand what is going on. > * The way you have written the queries they will need to put the whole db in > memory. Avoid the following idiom: > > for $x in doc().... > > unless you really have to. You can simplify the first query to something > like this: > > declare namespace bb="http://www.aaa.com/namespace/aa/bb/"; > //bb:title > > * To find out if your documents are in the bb namespace, look at the document > with something like: > > doc("/uri-of-doc.xml") > > The serialization should print out the namespaces. > > * Another possibility: is the string for your namespace being constructed > correctly in c#? > > -Danny > > -----Original Message----- > From: general-boun...@developer.marklogic.com > [mailto:general-boun...@developer.marklogic.com] On Behalf Of Mailing Lists > Mail > Sent: Wednesday, September 12, 2012 3:08 PM > To: MarkLogic Developer Discussion > Cc: i...@fgeorges.org > Subject: [MarkLogic Dev General] Help with namespace Declaration in Marklogic > > Dear All, > I had posted a mail regarding some xquery help running from C# program > to Marklogic DB. > I am using the SimpleQueryRunner.Cs from the Marklogic Sample files. > > I wrote 2 queries as follows > > String query1 = "declare namespace bb= > \"http://www.aaa.com/namespace/aa/bb/\"; for $doc in doc() let $title > := $doc//bb:title return $title"; > > String query2 = "for $doc in doc() let $title := $doc//title return $title"; > > > The query 1 runs on XMLs that have the namespace bb for the title. > The query 2 runs on XMLs that do not have any namespace for the title. > > Query2 produces valid results but Query1 brings out empty result. > > I am definitely sure it is the devils works of namespaces here that is > bothoring me because removing them from XML works fine. > > > I want to know if there is anything special we need to for the namespaces? > > I am using the SimpleQueryRunner.Cs as is without any changes to it. > > Your help will be highgly appreciated > > DakTapaal.. > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general