HI.

To clarify:  MarkLogic does not preserve your indentention, nor does it
guarantee that the document is the exact same upon return.  Yes, the same
content, but normalized as in the return document is actually assembled for
you.  Your document is ripped to bits and stored internally ina  different
format.

As an example(query console):
Insert this:
​​
<doc>
     <line foo='bar' one="2">line 1</line>
<line>line2</line>
</doc>

The query it:
<doc>
<line foo="bar" one="2">line 1</line>
<line>line2</line>
</doc>

So, nice and pretty - but not actually 'preserved' from my input (notice
the indentation is more consistent and also note that the use of single
quotes was changed to double quotes).


The pretty return that you see is actually done in the query console code.

You can replicate this in your own code by setting the following:
declare option xdmp:output "indent=yes";
declare option xdmp:output "indent-untyped=yes";

More information about this can be found here:


http://developer.marklogic.com/blog/controlling-output-options



Kind Regards,
David Ennis


David Ennis
*Content Engineer*

[image: HintTech]  <http://www.hinttech.com/>
Mastering the value of content
creative | technology | content

Delftechpark 37i
2628 XJ Delft
The Netherlands
T: +31 88 268 25 00
M: +31 63 091 72 80

[image: http://www.hinttech.com] <http://www.hinttech.com>
<https://twitter.com/HintTech>  <http://www.facebook.com/HintTech>
<http://www.linkedin.com/company/HintTech>

On 14 October 2014 21:56, David Sewell <dsew...@virginia.edu> wrote:

> Let me restate the problem.
>
> If I use an editor to manually create this XML document and save it to
> MarkLogic
> via WebDav or other means:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <doc>
>    <line>line 1</line>
>    <line>line2</line>
> </doc>
>
> then when I subsequently open that document from the database via WebDav
> or a
> doc() call, it arrives with its indentation preserved. I want to know how
> to
> generate a new file via XQuery such that it will have indentation when
> subsquently opened via WebDav or a doc() call.
>
> (It's not mission-critical, but I'm auto-generating a 50MB data file that I
> would like to be able to open in oXygen via WebDav with its elements
> already
> indented, since thing go much faster that way.)
>
> DAvid
>
> On Tue, 14 Oct 2014, Mary Holstege wrote:
>
> > On Tue, 14 Oct 2014 12:28:52 -0700, David Sewell <dsew...@virginia.edu>
> > wrote:
> >
> >> Given this code:
> >>
> >> xquery version "1.0-ml";
> >> declare option xdmp:output "indent-untyped=yes";
> >> declare option xdmp:output "omit-xml-declaration=yes";
> >> xdmp:document-insert(
> >>    "/test.xml",
> >>    <doc>
> >>      <line>line 1</line>
> >>      <line>line2</line>
> >>    </doc>
> >> ) ;
> >>
> >> doc("/test.xml")
> >>
> >> The output I'm getting is
> >>
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <doc><line>line 1</line><line>line2</line></doc>
> >>
> >> which is disobeying both serialization optinons I specified. ML version
> >> 7.0-4.
> >> Are other people seeing this? Am I missing something?
> >>
> >> David
> >>
> >
> >
> > Two things:
> > (1) If you are running this in QConsole all bets are off, because the
> > serialization
> > options apply in the query that does the serialization and everything in
> > QConsole
> > is run in a separate eval.
> >
> > (2) The serialization options are before the semi-colon, that is, they
> > only apply to
> > the xdmp:document-insert part of this file. If you want them to apply to
> > the
> > serialization of doc("/test.xml") you need to put them into that query.
> >
> > //Mary
> > _______________________________________________
> > General mailing list
> > General@developer.marklogic.com
> > http://developer.marklogic.com/mailman/listinfo/general
> >
>
> --
> David Sewell, Editorial and Technical Manager
> ROTUNDA, The University of Virginia Press
> PO Box 400314, Charlottesville, VA 22904-4314 USA
> Email: dsew...@virginia.edu   Tel: +1 434 924 9973
> Web: http://rotunda.upress.virginia.edu/
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to