On Wed, 30 Jul 2014 01:51:12 -0700, neil bradley <[email protected]>
wrote:
>
> But it seems I cannot have a PI before a root element. This does not
> work when I enter it into QC, and I get “unexpected token syntax
> error”:
>
> <?hi there?>
> <Root><?hi there?></Root>
The thing to know is that this may look like regular XML, but
it is actual XQuery expressions that create XML nodes.
So what you have there is an expression that creates a PI,
followed immediately by an expression that creates an element.
It is like typing:
1+1
4
What you need is to turn this into a valid XQuery expression.
by wrapping it in a sequence:
(<?hi there?>, <Root><?hi there?></Root>)
Personally, I'd wrap it in a document node too:
document { <?hi there?>, <Root><?hi there?></Root> }
> However, that is a side issue to my main concern…
>
> I can import an XML document that has a leading PI, store it in ML,
> and it is still there when I query the document. I can even save it
> using xdmp:save() and the PI is still there, as I would expect. But
> when I store the XML file in a ZIP instead, it is removed!
I see that too, and that looks like a bug to me. What version are
you running? The only workaround I can see is to save it into the
zip as a text file instead of an XML file:
xdmp:save("/tmp/my.zip",
xdmp:zip-create(<parts xmlns="xdmp:zip"><part>my.txt</part></parts>,
document { xdmp:quote(doc("my.xml")) } ))
In MarkLogic if you want this to be treated as XML on the way out,
you'll need to ask specifically:
xdmp:zip-get(xdmp:document-get("/tmp/my.zip"), "my.txt",
<options xmlns="xdmp:zip-get">
<format>xml</format>
</options>)
A regular unzipper won't care, although all kinds of other tools
will see the .txt and make assumptions, no doubt.
//Mary
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general