Insert xquery node from external xs: string variable (basex)

I am trying to insert new elements into an XML document using BaseX.

declare variable $part external; 
insert nodes $part as first into db:open("PARTDB")/assembly[@name="ZB09010"]

I use the BaseX GUI for my testing and have defined the $ part variable (by clicking the $ icon).

If I use a "local" variable using, for example,

let $up := <Employee Name="Joe">
    <Personal>
      <SSN>666-66-1234</SSN>
    </Personal>
    <StaffInfo>
      <Position>Doctor</Position>
      <AccountableTo>Jeff</AccountableTo>
    </StaffInfo>
  </Employee>
  return
insert node $up as last into doc('office')/Staff

then the insertion works correctly, however, with an external variable, every character that is a reserved xml character is converted to a sequence of xml escape characters, for example. example: <becomes <

I managed to get it to work by wrapping the variable with the xquery: eval ($ part) function, but that seems hacked to me.

, xs: string, ? - , , . xml CDATA, xml escape-.

+4
1

, , $part, node, , XML. XML node , , node (). , fn: parse-xml.

+3

Source: https://habr.com/ru/post/1619283/


All Articles