I am not saying that the ZIP solution does not work - I expect that it does.
I am saying that the solution to construct an XML document in memory does
not work.
This does not work...
document { <?hi there?><Root><?hi there?></Root> }
Neil.
on 30/7/14 10:32 AM, Jason Hunter <[email protected]> wrote:
> I ran the exact code I sent you just now on my laptop and it worked fine.
> The file was saved and on unzipping the file and viewing it in a text
editor
> I see the PI before the root node as well as inside it.
>
> You're saying it "does not work". I'll need you to be specific on what's
> happening because I'm seeing it work. And definitely to make a valid
> expression where there's a PI before the root you need the document node
> wrapper to make it one expression not two.
>
> -jh-
>
> On Jul 30, 2014, at 5:26 PM, neil bradley <[email protected]> wrote:
>
>> Jason,
>>
>> Thanks for your answers, and I expect that your solution
>> to the ZIP problem will help me.
>>
>> But I dont think you noticed that I was saying that the document node
does
>> NOT WORK:
>>
>> document { <?hi there?><Root><?hi there?></Root> }
>>
>> Now that is totally valid XML so I cant see why it fails.
>>
>> Neil.
>>
>>
>>
>> on 30/7/14 10:17 AM, Jason Hunter <[email protected]> wrote:
>>
>>>> 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