David,
It's good to include error messages when a query isn't working. In this
case the error message is:
[1.0-ml] XDMP-ARGTYPE: (err:XPTY0004) xdmp:save("filename.xml", ("<?xml
version="1.0" encoding="UTF-8" ?>",
<something>...</something>)) -- arg2 is not of type node()
That makes sense: we tried to pass two nodes as arg2: node()+, but arg2
must be node(). We can arrange for arg2 to be a single node, by wrapping
$h and $s in a computed document node constructor. Have you noticed that
I like computed constructors?
let $h := '<?xml version="1.0" encoding="UTF-8" ?>'
let $s := element something { "..." }
return xdmp:save("/tmp/filename.xml", document { $h, $s } )
$ cat /tmp/filename.xml
<?xml version="1.0" encoding="UTF-8" ?><something>...</something>
Note that xdmp:document-get() will *not* show you the xml declaration,
because the parser does not round-trip that declaration. If you want to
see the unparsed text in a query, you can:
xdmp:document-get(
'/tmp/filename.xml',
<options xmlns="xdmp:document-get">
<format>text</format>
</options>
)
-- Mike
David Steiner wrote:
I want to save a document to a file that looks like this...
<?xml version="1.0" encoding="UTF-8" ?>
<something>...</something>
How do I add the xml encoding to the doc as I save it out?
I have tried quite a few combinations including what's below, but must be
missing something simple (it usually is).
let $h := '<?xml version="1.0" encoding="UTF-8" ?>'
let $s := element something { "..." }
return xdmp:save("filename.xml", ($h,$s) )
Thanks in advance!
NOTICE: This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not the
intended recipient, please contact the sender by reply email and destroy all
copies of the original message.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general