If you pass some XML in to your query as text (because that is the only thing you can have inside an attribute) you have to do a parse-xml (or parse-xml-fragment if its more like a sequence) and insert that.
Am 21.04.2020 um 12:33 schrieb Ramzi Hammouda:
Hello,
First, thanks for the effort you’re putting it to help BaseX users.
I'm Using POST method to update BaseX database, I want to insert an xml node to an existing document calastone.xml in calastone database , if the node contains '<', it returns an error *" Line 6): The value of attribute "value" associated with an element type "variable" must not contain the '<' character."*
code:
<query>
<text>
let $message := '<Id>CTN53</Id>'
return insert nodes $message as last into doc("calastone/calastone.xml")
</text>
<variable name='message' value='<Id>CTN53</ID>'/>
</query>
the same code without '<' adds the text correctly.
how to solve this problem?
Note that this is a question I posted on Stackoverflow, Link https://stackoverflow.com/questions/60456387/passing-in-xquery-with-basex-post-method/60456826?noredirect=1#comment106958333_60456826.
Christian Grun suggested using |<| and |> for attributes and CDATA for text nodes. After applying that solution, the xml stored is in this form <Id>CTN53</Id>|||
|This is not what I’m looking for. Is there any other more convenient solutions to store XML messages with Rest APIs? I know PUT method works fine but it overwrites the content of the document.|
|Thank you.|
P/Respectons ensemble l'environnement. N'imprimez ce message que si nécessaire. //Let's respect the environment together. Only print this message if necessary./