xml element beginning and end space loss

Saturday, 27 January 2018 · 5 messages · last reply 1 Feb 2018
IL
Imsieke, Gerrit, le-texin reply to Stefania Axo, 27 Jan 2018, 01:5327 Jan 2018 01:06 #
Hi Stefania, You can avoid it if you create the DB with chopping switched off in the first place. Or you can supply the chopping option as you go:
db:replace('MyDB', 'doc.xml', '<a> stefy </a>', map {'chop':false()})
Whitespace chooping by default is maybe the most-detested design decision in BaseX, at least among users of mixed content. Luckily you can switch it off. Gerrit
Quoted text · Stefania Axo · 21 lines
On 27/01/2018 00:53, Stefania Axo wrote: > Hi all! > > is there a way to preserve the beginning and ending spaces in the > Database xml elements? > > > In other words If I execute this xQuery > > db:replace("MyDB", "doc.xml", "<a> stefy </a>") > > > the resulted document will be > > <a>stefy</a> > > As you can see I lost my beginner and ending spaces. > > > thanks > Stefania
-- Gerrit Imsieke Geschäftsführer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke at le-tex.de, http://www.le-tex.de Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930 Geschäftsführer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt
SA
Stefania Axo27 Jan 2018 01:53 #
Hi all! is there a way to preserve the beginning and ending spaces in the Database xml elements? In other words If I execute this xQuery
               db:replace("MyDB", "doc.xml", "<a>  stefy  </a>")
the resulted document will be
              <a>stefy</a>
As you can see I lost my beginner and ending spaces. thanks Stefania
MS
Michael Seiferlein reply to Imsieke, Gerrit, le-tex, 27 Jan 2018, 01:0629 Jan 2018 17:22 #
Hi & thanks Gerrit, Hi Stefania, You may even decide to chop-or-not on a per-element basis:
Quoted text · Imsieke, Gerrit, le-tex · 7 lines
> db:create('test', > "<doc> > <a> stefy </a> > <a xml:space='preserve'> stefy </a> > </doc>", > "doc.xml" > )
Will preserve whitespace in the second <a />-Element while chopping in the first one. => http://docs.basex.org/wiki/Options#CHOP <http://docs.basex.org/wiki/Options#CHOP> Best from Konstanz :-] Michael
Quoted text · Imsieke, Gerrit, le-tex · 3 lines
> Am 27.01.2018 um 01:06 schrieb Imsieke, Gerrit, le-tex <gerrit.imsieke at le-tex.de>: > > Luckily you can switch it off.
SA
Stefania Axo31 Jan 2018 00:36 #
thanks Michael I run your suggestion and it seems to affect all the elements on my BaseX. I also verified that the 'chop' property was still true after the execution of the xquery (> open test Database 'test' was opened in 7.29 ms.
Quoted text · Michael Seiferle · 1 line
> get chop
CHOP: true)
db:create('test',
"<doc>
  <a>  stefy  </a>
  <a xml:space='preserve'>  stefy  </a>
  <b>  stefy  </b>
</doc>",
"doc.xml"
)
========>>>>>
<doc> <a>  stefy </a> <a xml:space="preserve">  stefy  </a>
  <b>  stefy </b>
</doc>

db:replace("test", "doc1.xml",
"<doc>
  <a>  stefy  </a>
  <b>  stefy  </b>
</doc>")
========>>>>>
<doc> <a>  stefy </a>
  <b>  stefy </b>
</doc>
Am i missing something? thanks Stefania
Quoted text · Michael Seiferle · 23 lines
From: Michael Seiferle <ms at basex.org> To: Gerrit Imsieke <gerrit.imsieke at le-tex.de>, stefy at us.ibm.com Cc: BaseX <basex-talk at mailman.uni-konstanz.de> Date: 01/29/2018 11:22 AM Subject: Re: [basex-talk] xml element beginning and end space loss Hi & thanks Gerrit, Hi Stefania, You may even decide to chop-or-not on a per-element basis: db:create('test', "<doc> <a> stefy </a> <a xml:space='preserve'> stefy </a> </doc>", "doc.xml" ) Will preserve whitespace in the second <a />-Element while chopping in the first one. => http://docs.basex.org/wiki/Options#CHOP Best from Konstanz :-] Michael Am 27.01.2018 um 01:06 schrieb Imsieke, Gerrit, le-tex < gerrit.imsieke at le-tex.de>: Luckily you can switch it off.
MS
Michael Seiferle1 Feb 2018 16:15 #
Hi Stefania, Sorry for the delay. If I run you example, I **think** it behaves as intended, all <a/>-Elements but the one marked with xml:space are chopped. This is what it looks like here:
Quoted text · Stefania Axo · 17 lines
> https://asciinema.org/a/4v1FtkeE1QsEByHe1S2BAZP9W > michael@mbp:~/tmp/ml|⇒ cat example.xq > db:create('test', > "<doc> > <a> stefy </a> > <a xml:space='preserve'> stefy </a> > <b> stefy </b> > </doc>", > "doc.xml" > ) > michael@mbp:~/tmp/ml|⇒ basex example.xq > michael@mbp:~/tmp/ml|⇒ basex "db:open('test')" > <doc> > <a>stefy</a> > <a xml:space="preserve"> stefy </a> > <b>stefy</b> > </doc>%
…if I add CHOP=false, the whitespace will be kept on all elements: https://asciinema.org/a/IqUHE2hrhk0afjbPDi3jMgNVq <https://asciinema.org/a/IqUHE2hrhk0afjbPDi3jMgNVq> I am sure we will eventually be able to solve this mystery :-) Best Michael
Quoted text · Stefania Axo · 76 lines
> Am 30.01.2018 um 23:36 schrieb Stefania Axo <stefy at us.ibm.com>: > > thanks Michael > > I run your suggestion and it seems to affect all the elements on my BaseX. > I also verified that the 'chop' property was still true after the execution of the xquery > (> open test > Database 'test' was opened in 7.29 ms. > > get chop > CHOP: true) > > db:create('test', > "<doc> > <a> stefy </a> > <a xml:space='preserve'> stefy </a> > <b> stefy </b> > </doc>", > "doc.xml" > ) > ========>>>>> > <doc> <a> stefy </a> <a xml:space="preserve"> stefy </a> > <b> stefy </b> > </doc> > > > > db:replace("test", "doc1.xml", > "<doc> > <a> stefy </a> > <b> stefy </b> > </doc>") > ========>>>>> > <doc> <a> stefy </a> > <b> stefy </b> > </doc> > > Am i missing something? > thanks > Stefania > > > > From: Michael Seiferle <ms at basex.org> > To: Gerrit Imsieke <gerrit.imsieke at le-tex.de>, stefy at us.ibm.com > Cc: BaseX <basex-talk at mailman.uni-konstanz.de> > Date: 01/29/2018 11:22 AM > Subject: Re: [basex-talk] xml element beginning and end space loss > > > > Hi & thanks Gerrit, > Hi Stefania, > > You may even decide to chop-or-not on a per-element basis: > db:create('test', > "<doc> > <a> stefy </a> > <a xml:space='preserve'> stefy </a> > </doc>", > "doc.xml" > ) > > Will preserve whitespace in the second <a />-Element while chopping in the first one. > => http://docs.basex.org/wiki/Options#CHOP <https://urldefense.proofpoint.com/v2/url?u=http-3A__docs.basex.org_wiki_Options-23CHOP&d=DwMFAg&c=jf_iaSHvJObTbx-siA1ZOg&r=oRDtJNjvHAlLIcU_p2eWUQ&m=AIHTeBAo5MBiXhmnxUdQi_GxNJ60DZKWMN9ThNZO0J4&s=LdABq3glFtOe8YafyHOrMcDLENoIHMUkyZuepDsyamQ&e=> > > > Best from Konstanz :-] > > Michael > > Am 27.01.2018 um 01:06 schrieb Imsieke, Gerrit, le-tex <gerrit.imsieke at le-tex.de <mailto:gerrit.imsieke at le-tex.de>>: > > Luckily you can switch it off. > > >

⚡Generated with XQuery