replacing text nodes
Wednesday, 9 January 2019 · 3 messages
CG
Hi Graydon,
$c/descendant::text()[normalize-space]Maybe it should be as follows?
$c/descendant::text()[normalize-space()]Cheers,
Christian
Am Mi., 9. Jan. 2019, 18:35 hat Graydon Saunders <graydonish at gmail.com> geschrieben:
Quoted text · Graydon Saunders · 37 lines
> Hello! > > I'm using BaseX 9.1.1 on Linux. > > So I need to go through a whole bunch of documents and emit them in an > obfusticated form so the folks doing publication development can have them > without the client's security people becoming upset. I don't want to > obfusticate the db contents; I just want to be able to write out an > obfusticated version. > > Minimal example: > > declare function local:gib($in as text()) as text() { > text { 'ABCD' } > }; > > declare function local:obfusc($in as document-node()) as document-node() { > copy $c := $in > modify ( > for $x in $c/descendant::text()[normalize-space] > return replace node $x with local:gib($x) > ) > return $c > }; > > for $doc in db:open('out')[contains(document-uri(),'/scr_')][1] > let $blurred := local:obfusc($doc) > return $blurred > > If I run this, I get $doc back unaltered. If I look at the optimized > query, it looks like it ought to be changing things. > > What am I doing wrong? > > Thanks! > Graydon >
GS
Graydon Saunders9 Jan 2019 19:35 #
Hello!
I'm using BaseX 9.1.1 on Linux.
So I need to go through a whole bunch of documents and emit them in an obfusticated form so the folks doing publication development can have them without the client's security people becoming upset. I don't want to obfusticate the db contents; I just want to be able to write out an obfusticated version.
Minimal example:
declare function local:gib($in as text()) as text() {
text { 'ABCD' }
};
declare function local:obfusc($in as document-node()) as document-node() {
copy $c := $in
modify (
for $x in $c/descendant::text()[normalize-space]
return replace node $x with local:gib($x)
)
return $c
};
for $doc in db:open('out')[contains(document-uri(),'/scr_')][1]
let $blurred := local:obfusc($doc)
return $blurredIf I run this, I get $doc back unaltered. If I look at the optimized query, it looks like it ought to be changing things.
What am I doing wrong?
Thanks!
Graydon
GS
All die, and O! the embarrassment!
It should indeed!
Thank you, Christian.
Quoted text · Christian Grün · 57 lines
On Wed, Jan 9, 2019 at 12:42 PM Christian Grün <christian.gruen at gmail.com> wrote: > Hi Graydon, > > $c/descendant::text()[normalize-space] > > Maybe it should be as follows? > > $c/descendant::text()[normalize-space()] > > Cheers, > Christian > > > > > Am Mi., 9. Jan. 2019, 18:35 hat Graydon Saunders <graydonish at gmail.com> > geschrieben: > >> Hello! >> >> I'm using BaseX 9.1.1 on Linux. >> >> So I need to go through a whole bunch of documents and emit them in an >> obfusticated form so the folks doing publication development can have them >> without the client's security people becoming upset. I don't want to >> obfusticate the db contents; I just want to be able to write out an >> obfusticated version. >> >> Minimal example: >> >> declare function local:gib($in as text()) as text() { >> text { 'ABCD' } >> }; >> >> declare function local:obfusc($in as document-node()) as document-node() { >> copy $c := $in >> modify ( >> for $x in $c/descendant::text()[normalize-space] >> return replace node $x with local:gib($x) >> ) >> return $c >> }; >> >> for $doc in db:open('out')[contains(document-uri(),'/scr_')][1] >> let $blurred := local:obfusc($doc) >> return $blurred >> >> If I run this, I get $doc back unaltered. If I look at the optimized >> query, it looks like it ought to be changing things. >> >> What am I doing wrong? >> >> Thanks! >> Graydon >> >
Written for BaseX 9.1. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery