Hi,
I am newbie to Basex. I am trying to connect to BaseXJAXRX server from
python and trying to add a document along with its xml declaration to
a collection. The XML declaration is not getting stored. Here is the
code snippet:
----
xml = '<?xml version="1.0" encoding="UTF-8"
?><Message><Product><Reference>2233</Reference><Product></Message>'
session = BaseXClient.Session(settings.BASEX_SERVER_IP,
settings.BASEX_SERVER_PORT,
settings.BASEX_SERVER_USER,settings.BASEX_SERVER_USER)
session.execute('SET DBPATH '+ settings.XMLDB_FOLDER)
session.execute('OPEN ' + settings.XMLDB_NAME)
session.add("2233.xml", "", etree.tostring(xml, encoding="utf-8",
xml_declaration=True))
input = "declare option output:omit-xml-declaration 'no';
collection('" + settings.XMLDB_NAME +
"')//Message[//Reference='2233']"
query = session.query(input)
query.init()
while query.more():
product = query.next()
print product
session.close()
----
'print product' results in the following:
<Message><Product><Reference>2233</Reference><Product></Message>
How do I ensure that the XML declaration is also stored? Is
omit-xml-declaration the answer? How do I set it while running "add"
on BasexClient.Session?
Thanks
Murthy Raju