> Just one more point. I had thought I would solved the first, more minor
> issue, by wrapping the XML in a document node. But that still does not
> work...
> 
> document { <?hi there?><Root><?hi there?></Root> }

Correct, because without that you were providing two independent expressions 
without a comma between them.  You need the document wrapper to make it a 
single expression.

I think there may be a bug in xdmp:zip-create() where only the root node is 
used.  I was able to fix it by making the document into a string first:

let $doc := document {
<?hi there?>,
<Root><?hi there?></Root>
}

let $parts := <parts xmlns="xdmp:zip"><part>MyDoc.xml</part></parts>
let $zip := xdmp:zip-create($parts, text { xdmp:quote($doc) })           (: 
quoted! :)
let $save := xdmp:save("/tmp/test.zip", $zip, 
   <options xmlns="xdmp:save"><encoding>utf8</encoding></options>)
return "fixed"

-jh-

> 
> 
> Neil.
> 
> 
> 
> on 30/7/14 9:51 AM, neil bradley <[email protected]> wrote:
> 
>> Hi,
>> 
>> I am having two problems with processing instructions.
>> 
>> First, in general it seems I cannot create one that is before the root
>> element.
>> 
>> I can type this into QC and run it and the result is as expected:
>> 
>> <?hi there?>
>> 
>> I can also have one embedded in an element and again it is preserved
>> in the output:
>> 
>> <Root><?hi there?></Root>
>> 
>> 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>
>> 
>> 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!
>> 
>> Here is sample code that saves a ZIP file that removes the leading PI
>> from the document:
>> 
>> let $Doc := doc("/MyDoc.xml")
>> let $Parts := <parts xmlns="xdmp:zip"><part>MyDoc.xml</part></parts>
>> let $ZIP := xdmp:zip-create($Parts, $Doc)
>> return
>> xdmp:save("c:/TEST/test.zip", $ZIP,  <options
>> xmlns="xdmp:save"><encoding>utf8</encoding></options>)
>> 
>> Does anyone have experience of this, and know any workaround. It is
>> really important that I preserve the PIs at the top of documents and
>> place them in a ZIP.
>> 
>> Neil.
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>> 
>> 
>> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to