Thanks Mary,

I have already received the same advice and I am still kicking myself that I
didnt think I needed a sequence there. I was too focused on trying to
produce a valid XML structure and not thinking about sequences at all.

I think there is general agreement that the main issue is a bug in the
xdmp:create-zip() code, and that the workaround is indeed to convert the XML
to text before putting it in the ZIP file.

I am running on ML version 7 and quite surprised that this bug has not been
seen or fixed long ago! I think this is a serious bug, as is any bug that
corrupts or loses data.

Im not sure, but I think that if I stil lstate that the file is ".xml" then
MarkLogic will treat it as XML? Anyway, that is not an issue for me as the
ZIP file that I create is actually an IDML file for InDesign to open - and
InDesign certainly treats it as XML.

Neil.



on 30/7/14 4:04 PM, Mary Holstege <[email protected]> wrote:

> 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

Reply via email to