I'm a bit confused by what you're trying to accomplish here. 

Why can't you just use $tokens, which is a sequence of strings?

-fs

________________________________________
From: [email protected] 
[[email protected]] On Behalf Of Lee, David 
[[email protected]]
Sent: Thursday, May 27, 2010 4:10 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to convert a comma delimited   
stringinto a string array?

declare variable $ID as xs:string as external;
let $tokens := fn:tokenize($ID, ",")
let $count := fn:count($tokens)
for $token at $index in $tokens
let $args := fn:concat('"',$token,'"', if ($index eq $count) then ""
else ",")
return
$args



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Pragya
Kapoor
Sent: Thursday, May 27, 2010 12:44 AM
To: [email protected]
Subject: Re: [MarkLogic Dev General] How to convert a comma delimited
stringinto a string array?

Hi,

My exact requirement is such that I need t pass multiple ID's from
XCC.Net API
ID values are comma separated like 123,456,789,1234,2345
Now if I pass this from XCC to xqyery module as string it would be like
"123,456,789,1234,2345"

My module code:

declare variable $ID as xs:string? as external;
let $tokens := fn:tokenize($ID, ",")
let $count := fn:count("$tokens")
for $token at $index in $tokens
let $args := fn:concat('"',$token,'"',",")
return
$args

I get my results as:
"123",
"456",
"789",
"1234",
"2345",

Now I have two questions:
1. How to remove the last comma?
2. Is $args is of type string array? If not then how to convert $args to
an string array.
        Like this $args as xs:string* :=
("123","456","789","1234","2345").

I need to use $args in the below query.

for $x in cts:search(doc("/temp.xml")//list/body,
    cts:element-attribute-word-query(
      xs:QName("title "), xs:QName("id"),$args),"score-simple", 1.0)


Thanks,
Pragya

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Thursday, May 27, 2010 2:22 AM
To: [email protected]
Subject: General Digest, Vol 71, Issue 64

Send General mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://developer.marklogic.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of General digest..."


Today's Topics:

   1. Re: How to pass String Array to   Marklogic       using XCC.Net
API?
      (Bramhall, Dena)
   2. Get string value of declared namespace (cOre dUmPeR)
   3. Re: Get string value of declared namespace (Markus Pilman)


----------------------------------------------------------------------

Message: 1
Date: Wed, 26 May 2010 19:58:48 +0000
From: "Bramhall, Dena" <[email protected]>
Subject: Re: [MarkLogic Dev General] How to pass String Array to
        Marklogic       using XCC.Net API?
To: General Mark Logic Developer Discussion
        <[email protected]>
Message-ID:

<2755229d63692f478a1c52aebb9d7c3b01c...@mars.headquarters.quantum-intl.c
om>

Content-Type: text/plain; charset="us-ascii"

That is actually what worked for us. We had to also allow for spaces in
all ingested files by concatenating an underscore to any file with a
space or weird character.

From: [email protected]
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Wednesday, May 26, 2010 1:56 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to pass String Array to
Marklogic using XCC.Net API?

This will work well if the values are simplistic. But if the values are
arbitrary strings (which might contain commas, quotes etc) tokenize  is
problematic.
Another option is to create an XML file "As a string" then send it as an
xs:string and use xdmp:unquote()  to turn it into XML .


From: [email protected]
[mailto:[email protected]] On Behalf Of Mark
Helmstetter
Sent: Wednesday, May 26, 2010 8:57 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to pass String Array to
Marklogic using XCC.Net API?

My suggestion is that you pass the sequence as a delimited string and
then split that into a sequence inside the module using fn:tokenize:

declare variable $collections-string as xs:string? external;
declare variable $collections as xs:string* :=
tokenize($collections-string, ',')[. ne ''];

From: [email protected]
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Wednesday, May 26, 2010 8:09 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to pass String Array to
Marklogic usingXCC.Net API?

The short answer is "no".
You cant pass sequences, elements, documents or anything but atomic
single value to XCC as external variables.
I consider this a major "bug" but it is what it is.

The long answer.
1) Wrap the sequence into a document, store the document in a temporary
directory on the ML server,
then do an ad-hoc query to parse the document, generate the sequence and
call your module.
Pseudo-code

Client:
                create doc  <doc><elem>a</elem><elem>b</elem> ....
                store doc in /temp/values.xml                  --- MAKE
SURE THIS IS UNIQUELY NAMED (not always easy)
                call Ad-hoc query
                                let $seq := doc("/temp/values.xml")
                                return myprefix:myfun(  for $e in
$seq//elem return $e/string()  )


2) Dynamically create an ad-hoc query in xquery with the sequence as
part of the code

Client C# (ish)
                String query = "declare variable $args :-= (" ;
                for( value in values ...)
                                query = query + "\"" + value + "\"," ;
                query = query + "())"; // hack to avoid figuring out
what the last item was ... I'm lazy

                query = query  + "myprefix:myfunc( $args) ";
                Call Ad-hoc query   $query



Feature Request to MarkLogic
PLEASE add support for sequences and nodes to XCC variables !!!!




From: [email protected]
[mailto:[email protected]] On Behalf Of Pragya
Kapoor
Sent: Wednesday, May 26, 2010 7:39 AM
To: [email protected]
Subject: [MarkLogic Dev General] How to pass String Array to Marklogic
usingXCC.Net API?

Hi,

How to pass String Array to Marklogic using XCC.Net API.
Marklogic is expecting data in the form of string Array in a query, I
want to pass the data in
A string array as {"a","b","c","d"} .
I am not able to find the way to pass it to ML using C#.

Is there any way to do it?

Thanks,
Pragya

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://developer.marklogic.com/pipermail/general/attachments/20100526/bd
933f58/attachment-0001.html

------------------------------

Message: 2
Date: Wed, 26 May 2010 13:48:12 -0700 (PDT)
From: cOre dUmPeR <[email protected]>
Subject: [MarkLogic Dev General] Get string value of declared
        namespace
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Probably an easy question but, is there a way to get the string value of
a declared namespace?

For example:

??? declare namespace foo = "http://www.foo.com";
??? <namespace_str>{ foo }</namespace_str>

I suppose I could always declare a variable with its value set as
"http://www.foo.com"; ...but I'd rather not since then there would be 2
places where to keep track of the same value

thanks,
/marv




-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://developer.marklogic.com/pipermail/general/attachments/20100526/10
0d9e21/attachment-0001.html

------------------------------

Message: 3
Date: Wed, 26 May 2010 22:51:36 +0200
From: Markus Pilman <[email protected]>
Subject: Re: [MarkLogic Dev General] Get string value of declared
        namespace
To: General Mark Logic Developer Discussion
        <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Hi,

The following should work:

declare namespace foo = "http://www.foo.com";;

<namespace>{fn:namespace-uri(<foo:bar/>)}</namespace>

Best Markus
Am 26.05.2010 um 22:48 schrieb cOre dUmPeR:

> Probably an easy question but, is there a way to get the string value
of a declared namespace?
>
> For example:
>
>     declare namespace foo = "http://www.foo.com";
>     <namespace_str>{ foo }</namespace_str>
>
> I suppose I could always declare a variable with its value set as
"http://www.foo.com"; ...but I'd rather not since then there would be 2
places where to keep track of the same value
>
> thanks,
> /marv
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://developer.marklogic.com/pipermail/general/attachments/20100526/43
491133/attachment.html

------------------------------

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general


End of General Digest, Vol 71, Issue 64
***************************************
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to