Sini,

*Inside* marklogic it's better to think of XML documents as trees, rather than 
strings. When you ask for the XML, MarkLogic will serialize the tree to a 
string that represents the tree, but internally it is a hierarchical data 
structure, which is why it is so powerful.

Try:

let $phone := <phone>T</phone>
return
  <document>
    mixed in text, which is unusual in structured content, but common in HTML
    { $phone }
    <notes> another structured field, which you could also put in using braces. 
braces "escape" out to regular XQuery from inside direct XML constructs like 
this one</notes>
  </document>

This is actually a set of nested expressions. The outermost expression is a 
FLWOR. The return clause in the FLWOR is a single XML construction expression 
using a direct element constructor (see: 
http://blog.davidcassel.net/2011/10/element-constructors-computed-and-direct/), 
and the {} enclose normal XQuery. XQuery has two syntactic modes - one for 
inside direct XML element expression and one everywhere else, and the {} 
toggles into the normal mode.

In any case, remember that these expressions are using XML strings as syntax 
but are building tree data structures.

Yours,
Damon

--
Damon Feldman
Sr. Principal Consultant, MarkLogic


From: [email protected] 
[mailto:[email protected]] On Behalf Of sini narayanan
Sent: Thursday, May 16, 2013 4:09 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] string-join output not as expected

Yes!!! this is exactly what I want. But I need to perform string join to this 
symbol. Is there a way to do that?
Because, I have a lot many variables to be inserted to the root node value 
after concatenation.

Thanks,
Sini


On Thu, May 16, 2013 at 12:03 PM, Geert Josten 
<[email protected]<mailto:[email protected]>> wrote:
Hi Sini,

I think you are looking for something like this:

let $phonesymbol := <SYMB>T</SYMB>
let $tel := "03 22 24 08 49"
return
      <root>France - {$phonesymbol}  {$tel} - 14h-18h - closed.</root>

Your phonesymbol really isn't a string, so don't use string-join or concat, but 
insert it into the parent tree as a node.

Kind regards,
Geert

Van: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 Namens sini narayanan
Verzonden: donderdag 16 mei 2013 7:34
Aan: MarkLogic Developer Discussion
Onderwerp: Re: [MarkLogic Dev General] string-join output not as expected

I need this to be inserted as a value of a node.

for example:
<root>France - <SYMB> T </ SYMB>  03 22 24 08 49 - 14h-18h - closed.</root>

Thanks,
Sini

On Thu, May 16, 2013 at 10:56 AM, Tim <[email protected]<mailto:[email protected]>> 
wrote:
Are you trying to insert the phone symbol as a node or as a string in a 
document where the content is mixed?

Can you provide a better example of the xml file and how you want this to fit 
in it?

From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of sini narayanan
Sent: Thursday, May 16, 2013 1:19 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] string-join output not as expected

Hi Tim,

I get the output as &lt;SYMB&gt;T&lt;/SYMB&gt; test

Is it not possible to get it as <SYMB>T</SYMB> test ?

I'm inserting this values in an xml file.

Thanks,
Sini

On Thu, May 16, 2013 at 10:21 AM, Tim <[email protected]<mailto:[email protected]>> 
wrote:
First of all your symbol needs to be a string and not a node.  Secondly you 
need to use the correct syntax for string-join:

let $phonesymbol := "<SYMB>T</SYMB>"
return fn:string-join(($phonesymbol, "test"), " ")
Tim  Meagher

From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of sini narayanan
Sent: Thursday, May 16, 2013 12:43 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] string-join output not as expected

Hi,

I have the following code

let $phonesymbol       := <SYMB>T</SYMB>
return
$phonesymbol

output : <SYMB>T</SYMB>

let $phonesymbol       := <SYMB>T</SYMB>
return
fn:string-join($phonesymbol || " " || "test")

output : T test

How do I modify this to get the output as "<SYMB>T</SYMB> text"

Thanks,
Sini

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


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


_______________________________________________
General mailing list
[email protected]<mailto:[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