Hello,
I've been trying different ways to remove all the Paths elements from
the settings file of doublecmd : doublecmd.xml
(i use it in linux : https://sourceforge.net/p/doublecmd/wiki/Download/)
a reason to want to do this is that when backing up to move around
i don't want to carry non-pertinent data
So i've used except in :
$ xidel doublecmd.xml -e '* except Paths'
and several variations prepending paths like // and * with <paths> never gone</paths>
I also applied : -e '*[not(self::Paths)]'
with similar results, even by tweaking the expression
what am i doing wrong?
thanks in advance for yoour kind attention
zui
201908062
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
these two commands leaves all <e> in place
$ xidel b.xml --xml -e '[not(self::e)]'
$ xidel b.xml --xml -e ' except e'</e>
again, thank you for your help,
zui
201908062
Hello,
I've been trying different ways to remove all the Paths elements from
the settings file of doublecmd : doublecmd.xml
(i use it in linux : https://sourceforge.net/p/doublecmd/wiki/Download/)
a reason to want to do this is that when backing up to move around
i don't want to carry non-pertinent data
So i've used except in :
$ xidel doublecmd.xml -e '* except Paths'
and several variations prepending paths like // and * with <paths> never gone</paths>
I also applied : -e '*[not(self::Paths)]'
with similar results, even by tweaking the expression
what am i doing wrong?
thanks in advance for yoour kind attention
zui
201908062
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My shell's code page is CP437. At the moment I don't know how I can have it put out encoding="utf-8"?. Benito would have to answer that.
Last edit: Reino 2019-08-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2019-08-07
Exactly what i wanted to avoid and you've proven me wrong...Arghhhh, it hurts my little pr'I'de.
I also scratched the surface of xslt and the templates, just to turn my head, kind of scared by what was hiding in there. Some more work and courage could have made me dig out some thing like your solution.
But again, why is it still so complex? what is wrong with the "except" and the "not"|"!=" solutions which, for my understanding are semanticaly equivalent (though the "transform" way offers much more possibilities).
actually i am still unconfortable with the abundance of xml or json or even databases when simple plain (human) text could do... and, in doublecmd and other apps, a more classical file à la .ini . i think simplification the way you went from xml everywhere to json, and html to md.
Bah, i'm already grateful the authors compose so nice apps, just wondering if life would be easier for them and their users?
so here's my application of it :
$ cat b.xml
<a><b><d></d></b><c><d><e></e></d></c><b></b><d></d><b></b><b></b><c><e></e></c><b><d></d></b></a>
$ xidel --version
Xidel 0.9.8
(20180421.6162.1f357eaaf5f3)
http://www.videlibri.de/xidel.html
by Benito van der Zander <benito@benibela.de>
$ xidel -s b.xml --xml -e 'transform(/,function($x){$x/(if (
name()="e") then () else .)})'
<?xml version="1.0" encoding="UTF-8"?><a><b><d></d></b><c><d></d></c><b></b><d></d><b></b><b></b><c></c><b><d></d></b></a>
and it works...
though, as you can see, the removed content lives a blank line (tried quotes instead of () with no improvement).
on the encoding, you noticed the "utf-8" automatically added as you guessed (ran it in xterm -u8 so...)
now i can sleep in peace since guies like you Reino, keep protecting us all
Thnak you so much
zui
201908073
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
why is it still so complex? what is wrong with the "except" and the "not"|"!=" solutions which, for my understanding are semanticaly equivalent (though the "transform" way offers much more possibilities).
when you select an element with a normal xpath query, you get the entire element - with all its descendants.
* except e can distinguish between <a>..</a> and <e>..</e>, it never looks at the decendants. <a><e>..</e></a> is an a-element, so you get all of it. * except //e does the same.
though, as you can see, the removed content lives a blank line (tried quotes instead of () with no improvement).
The blanks are before the <e>. When $x is e, it cannot change the blanks, they have are already been copied to the output.
You could check if $x is a blank text that has an e as following sibling. Or some condition at the parent node if it only has one e element. Or do a second transform pass to change elements that only contain whitespace.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I've been trying different ways to remove all the Paths elements from
the settings file of doublecmd : doublecmd.xml
(i use it in linux : https://sourceforge.net/p/doublecmd/wiki/Download/)
a reason to want to do this is that when backing up to move around
i don't want to carry non-pertinent data
So i've used except in :
$ xidel doublecmd.xml -e '* except Paths'
and several variations prepending paths like // and * with <paths> never gone</paths>
I also applied : -e '*[not(self::Paths)]'
with similar results, even by tweaking the expression
what am i doing wrong?
thanks in advance for yoour kind attention
zui
201908062
just in case you needed more concrete case, i made this :
OK i build an example of an xml content of which i want to remove all the eleent with certain carateristics...
say, all the <e> elements :</e>
<d></d>
<c>
<d>
<e>
</e>
</d>
</c>
<d></d>
<c>
<e></e>
</c>
<d></d>
these two commands leaves all <e> in place
$ xidel b.xml --xml -e '[not(self::e)]'
$ xidel b.xml --xml -e ' except e'</e>
again, thank you for your help,
zui
201908062
See http://videlibri.sourceforge.net/xidel.html#examples #13.
I believe this query should work:
My shell's code page is CP437. At the moment I don't know how I can have it put out
encoding="utf-8"?
. Benito would have to answer that.Last edit: Reino 2019-08-07
Exactly what i wanted to avoid and you've proven me wrong...Arghhhh, it hurts my little pr'I'de.
I also scratched the surface of xslt and the templates, just to turn my head, kind of scared by what was hiding in there. Some more work and courage could have made me dig out some thing like your solution.
But again, why is it still so complex? what is wrong with the "except" and the "not"|"!=" solutions which, for my understanding are semanticaly equivalent (though the "transform" way offers much more possibilities).
actually i am still unconfortable with the abundance of xml or json or even databases when simple plain (human) text could do... and, in doublecmd and other apps, a more classical file à la .ini . i think simplification the way you went from xml everywhere to json, and html to md.
Bah, i'm already grateful the authors compose so nice apps, just wondering if life would be easier for them and their users?
so here's my application of it :
and it works...
though, as you can see, the removed content lives a blank line (tried quotes instead of () with no improvement).
on the encoding, you noticed the "utf-8" automatically added as you guessed (ran it in xterm -u8 so...)
now i can sleep in peace since guies like you Reino, keep protecting us all
Thnak you so much
zui
201908073
when you select an element with a normal xpath query, you get the entire element - with all its descendants.
* except e
can distinguish between<a>..</a>
and<e>..</e>
, it never looks at the decendants.<a><e>..</e></a>
is ana
-element, so you get all of it.* except //e
does the same.The blanks are before the
<e>
. When$x
ise
, it cannot change the blanks, they have are already been copied to the output.You could check if $x is a blank text that has an
e
as following sibling. Or some condition at the parent node if it only has one e element. Or do a second transform pass to change elements that only contain whitespace.