To add to these examples, I think another way to add a document with whitespace preserved is:
declare option db:chop 'false';
db:add("DB", doc("http://example.com/doc.xml"), "doc.xml")
Is this equivalent to db:add("DB", "http://example.com/doc.xml", "doc.xml", map { "chop": false() }) ?
Vincent
From: basex-talk-bounces@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de]
On Behalf Of C. M. Sperberg-McQueen
Sent: Friday, June 24, 2016 1:12 PM
To: Christian Grün <christian.gruen@gmail.com>
Cc: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>; BaseX <basex-talk@mailman.uni-konstanz.de>
Subject: Re: [basex-talk] unexpected whitespace-handling behavior in BaseX 8.3.1
On Jun 21, 2016, at 12:43 AM, Christian Grün wrote:
>> Yes. What puzzles me is that calling db:replace with a fourth
>> argument of map { "chop" : false() } appears not to have any
>> effect in the database in question.
>
> This is probably because the input you are specifying are nodes, for
> which whitespaces have already been chopped in a previous step I tried
> to explain this better now in our documentation [1].
[Headslap] D'oh! Thank you very much.
I have created two simple examples to try to teach myself what
is going on here. Is the characterization correct?
db:add("DB", "http://example.com/doc.xml",
"doc.xml", map { "chop" false() }) -- parses the file at the URI
http://example.com/doc.xml with the CHOP option turned
off (so whitespace is preserved), and adds it to database DB.
db:add("DB", doc("http://example.com/doc.xml"),
"doc.xml", map { "chop" false() }) -- parses the file at the URI
http://example.com/doc.xml with the default parser
settings and adds it to database DB. Note that the CHOP setting
in the fourth argument has no effect, since the document
is parsed by the doc() function, not the db:add function.
If you think it helpful, feel free to add these to the documentation
for db:add() or db:replace; it might help even readers like me
to understand what is going on.
best,
Michael
--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
*
http://www.blackmesatech.com
* http://cmsmcq.com/mib
*
http://balisage.net
****************************************************************