Topic
1 reply Latest Post - ‏2012-10-12T10:37:04Z by SystemAdmin
SystemAdmin
SystemAdmin
746 Posts
ACCEPTED ANSWER

Pinned topic How to write special characters to XML file?

‏2012-10-12T04:36:47Z |
Hi all,

I am trying to use XQuery to translate XML to RDF/XML, so I just started by writing a script that reads the XML nodes and simply translates them to RDF/XML, as follows: <namespace:node-name rdf:parseType="Resource"></namespace:node-name>

My script follows:

(please disregard the white spaces, I wrote them just in case the sequences will show up as < and > )

let $lt := " & l t ;"
let $gt := " & g t ;"
for $node in doc( "doc.xml" )//*
return concat($lt, "namespace", ":", node-name($node) , $gt)

Unfortunately it did not do the trick, they'll still show up at & l t ; without the white spaces..
I tried using ascii codes as well, as in "& # Code ;"

Please help
Updated on 2012-10-12T10:37:04Z at 2012-10-12T10:37:04Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    746 Posts
    ACCEPTED ANSWER

    Re: How to write special characters to XML file?

    ‏2012-10-12T10:37:04Z  in response to SystemAdmin
    You should write the query to construct a tree of nodes, not to construct lexical XML. The way to write an element node to the tree is to use an element constructor, such as

    
    <e x=
    "1" y=
    "{$var}"/>
    


    or if it needs to be dynamic

    
    element 
    {$name
    } 
    {$content
    }