0

I'm trying to create an xml output of some items, which works perfect, though when i try to add a blabla tag in front of it fails.

I think it's rather easy, but I'm not able to find a solution.

the code i'm using:

let $data := content:sortContent(content:retrieveLastFM() union content:retrieveYoutube() union content:retrieveImgur() union content:retrieveFlickr() union content:retrieveNYTimes() union content:retrieveDiggTechnology() union content:retrieveDiggAmusement()),

$doc := <description>Blablabla</description> <items> {$data} </items>

return $doc

The following does work:

$doc := <items>{$data}</items> 

Though I want a description in front of my list of items..

I hope you understand what I'm trying to reach here ;) Thanks in advance for any help!

2 Answers 2

2

You try to assign a sequence of nodes to $doc, this has to be done explicitly via ,:

let $data := ...,
    $doc  := (<description>Blablabla</description>, <items> {$data} </items>)
return $doc

Another possibility is to wrap both nodes inside another element or a document node (as the variable name suggests anyway):

    $doc  := <doc><description>Blablabla</description><items> {$data} </items></doc>

or

    $doc  := document { <description>Blablabla</description>, <items> {$data} </items> }
Sign up to request clarification or add additional context in comments.

Comments

0

Your query would not output valid XML. Depending on what you want to get, there are two possibilities:

Wrap the element in some container element to return valid XML:

$doc := <container><description>Blablabla</description> <items> {$data} </items></container>

Which returns

<container>
  <description>Blablabla</description>
  <items>somedata</items>
</container>

Or you could return a sequence of XML nodes:

$doc := (<description>Blablabla</description>, <items> {$data} </items>)

Which returns

<description>Blablabla</description>
<items>1</items>
<description>Blablabla</description>
<items>2</items>
<description>Blablabla</description>
<items>3</items>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.