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?
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/>
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 { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With