Small request on xquery ( how to put xml content in a attribute element )

Thursday, 2 June 2011 · 3 messages
AP
augras philippe2 Jun 2011 19:06 #
Hello, I'm using basex to manage numerous collection of xml structure , in the context of a migration program, i will transfer these structure to an external system , so i need to send them within an embedded attribut value ( of a xml ) : ex: BaseX current content is : <NodeX></NodeX> Remote DataBase ( not xml ) requieres : <Value title="FNX" value="&lt;NodeX&gt;&lt;/NodeX&gt;"> The XML source is translated to a litteral string ....but what is the function ( Cast ? ) responsible to operate the translation ? By the way , what is the reversed operation that read attribut to XML structure . Best Regards
CG
Christian Grün2 Jun 2011 19:29 #
Quoted text · augras philippe · 4 lines
> BaseX current content is : <NodeX></NodeX> > > Remote DataBase ( not xml ) requieres : <Value title="FNX" > value="&lt;NodeX&gt;&lt;/NodeX&gt;">
This can be done with the fn:serialize() function:
(: start :)
<Value title="FNX">{
  serialize(<NodeX></NodeX>)
}</Value>
(: end :)
Note that you'll have to prefix your query with a "xhtml" output method declaration if you want to explicitly see the opening and closing tag:
(: start :)
declare option output:method "xhtml";

<Value title="FNX">{
  serialize(<NodeX></NodeX>)
}</Value>
(: end :)
Best, Christian
LW
Leo Wörtelerin reply to augras philippe, 2 Jun 2011, 19:062 Jun 2011 21:52 #
Hi,
Quoted text · augras philippe · 2 lines
Am 02.06.2011 19:06, schrieb augras philippe: > The XML source is translated to a litteral string ....
[...]
Quoted text · augras philippe · 2 lines
> By the way , what is the reversed operation that read attribut to XML > structure .
That can be done with the function fn:parse-xml(...):
Quoted text · augras philippe · 1 line
> parse-xml('<NodeX></NodeX>')
==> <NodeX/> Cheers, Leo

⚡Generated with XQuery