Reputation: 1388
For example
I am creating an element with dynamic data -
XQUERY
let $sttag:= concat('<', '/')
return concat ($sttag, "newTag")
above XQuery returns output as </newTag
instead of </newTag
.
it there any way to print "<" and ">" using xquery?
Upvotes: 3
Views: 2693
Reputation: 243449
Here is an illustration of the most dynamic way to construct an element -- the name isn't known at compile time and is generally different at every execution:
let $name := translate(concat('N', current-time()), ':','_')
return
element {$name} {}
produces:
<N21_26_40.708-07_00/>
Upvotes: 3
Reputation: 13618
I recommend using XQuery's element constructors. You can create elements dynamically using a computed element constructor:
element book {
attribute isbn {"isbn-0060229357" },
element title { "Harold and the Purple Crayon"},
element author {
element first { "Crockett" },
element last {"Johnson" }
}
}
results in
<book isbn="isbn-0060229357">
<title>Harold and the Purple Crayon</title>
<author>
<first>Crockett</first>
<last>Johnson</last>
</author>
</book>
(Example from the W3C XQuery specs)
In your case, you could use
element newTag { ... }
Upvotes: 2