473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XPath Problem: Select all childnodes, that names are neither "name1" nor "name2"

Hi!
I wanna copy all childnodes of the current nodes except those with
basenames "name1" or "name2".
Something like
<xsl:copy-of select=" basename not equal ('name1' or 'name2') "/>

Can someone help please?
Thanks,
Andreas

Feb 26 '07 #1
7 5670
On Feb 26, 11:01 am, adu...@cs.tu-berlin.de wrote:
I wanna copy all childnodes of the current nodes except
those with basenames "name1" or "name2".
What do you mean by 'basename'? Element name, attribute,
child element? Please stick to standard terms if you want
others to understand you.
<xsl:copy-of
select=" basename not equal ('name1' or 'name2') "/>
You don't have any previous coding experience, do you?

Depending on what precisely you intend to do, the XPath
expression might look like:

*[not(self::name1) and not(self::name2)]

*[local-name()!='name1' and local-name()!='name2']

*[@basename!='name1' and @basename!='name2']

*[basename!='name1' and basename!='name2']

Note that it is elementary good design to implement
template-based copying instead of copy-of (untested):

<xsl:template match="foo">
<xsl:apply-templates mode="selective-copy"/>
</xsl:template>
<xsl:template match="name1|name2" mode="selective-copy"/>
<xsl:template
match=
"
*[not(self::name1) and not(self::name2)]
" mode="selective-copy">
<xsl:copy-of select="."/>
</xsl:template>

This way you can easily reuse selective-copy whenever
needed, and you would only need to change anything in one
place in case you needed alterations to the algorithm.

--
Pavel Lepin

Feb 26 '07 #2
Hi!
'baseName' is a standard term in VB, it returns the element name.
Does it matter if I have coding experience?
Yes, template is much better. But it wouldn´t have fit in one column,
would it? Everyone has understood me without reading several lines of
unformatted, unhighlighted code.
Thank you very much, your suggestion works fine.

Greetings,
Andreas

Feb 26 '07 #3
Please quote what you're replying to.

On Feb 26, 12:13 pm, adu...@cs.tu-berlin.de wrote:
'baseName' is a standard term in VB, it returns the
element name.
This is not a VB newsgroup, however. When asking
VB-specific questions in a VB newsgroup, by all means, go
ahead and use the terms accepted in the VB
community--that's the right thing to do anyway. On the
other hand, when asking questions in an XML newsgroup,
using VB-specific terms is quite counter-productive.
Does it matter if I have coding experience?
That's something you'll have to ask your employer, not me.
I just made an observation regarding the fact that:

basename not equal ('name1' or 'name2')

....is a somewhat surprising way to express what J. Random
Codegrinder would probably express as either:

basename not equal 'name1' and basename not equal 'name2'

....or:

basename not in ( 'name1' , 'name2' )
Yes, template is much better. But it wouldn´t have fit
in one column, would it?
It was just a random observation. Well, not entirely
random, there was my doubtlessly nefarious intention to
give you a pointer on good practices in case you haven't
realised that yourself yet.
Everyone has understood me without reading several lines
of unformatted, unhighlighted code.
In this case you're absolutely right. Note however, that
for harder questions it's a good practice to post what is
commonly called 'minimum complete example'; and in that
case you should take care of the formatting while my gvim
will take care of highlighting.

--
Pavel Lepin

Feb 26 '07 #4
In article <11**********************@8g2000cwh.googlegroups.c om>,
<p.*****@ctncorp.comwrote:
>That's something you'll have to ask your employer, not me.
I just made an observation regarding the fact that:

basename not equal ('name1' or 'name2')

...is a somewhat surprising way to express [...]
It's not *that* implausible. For example, in Python you can say:

basename in ('name1', 'name2')

and in XPath (!) you can test whether the foo attribute is equal to
either the bar or baz attribute by saying:

@foo = (@bar | @baz)

which is really very similar. (There is a trap for the unwary in
using != in this case.)

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Feb 26 '07 #5
On Feb 26, 2:02 pm, rich...@cogsci.ed.ac.uk (Richard Tobin)
wrote:
In article
<1172490171.081824.102...@8g2000cwh.googlegroups.c om>,
<p.le...@ctncorp.comwrote:
That's something you'll have to ask your employer, not
me. I just made an observation regarding the fact that:
basename not equal ('name1' or 'name2')
...is a somewhat surprising way to express what J.
Random Codegrinder would probably express as either:
basename not equal 'name1' and basename not equal
'name2'
...or:
basename not in ( 'name1' , 'name2' )

It's not *that* implausible. For example, in Python you
can say:

basename in ('name1', 'name2')
Well, I'm obviously aware of facilities like that in many
of the modern programming languages since I explicitly
mentioned it in the part of my previous post you snipped.
and in XPath (!) you can test whether the foo attribute
is equal to either the bar or baz attribute by saying:

@foo = (@bar | @baz)
Mind-boggling. Note however, that unless I'm much mistaken,
| is very different from or, and not in the way | is
different from || in C either. = is not precisely 'equal'
when working with nodesets, too.

--
Pavel Lepin

Feb 26 '07 #6
On 26 Feb., 14:17, p.le...@ctncorp.com wrote:
>
Well, I'm obviously aware of facilities like that in many
of the modern programming languages since I explicitly
mentioned it in the part of my previous post you snipped.
Yes, you are obviously a code-guru and I bow in awe of such
wisdom ;)).
Never mind I just find the emotions often coming along with such
unimportant matters quite funny.

Greets,
Andreas

Feb 26 '07 #7
In article <11*********************@q2g2000cwa.googlegroups.c om>,
<p.*****@ctncorp.comwrote:
>It's not *that* implausible. For example, in Python you
can say:

basename in ('name1', 'name2')
>Well, I'm obviously aware of facilities like that in many
of the modern programming languages since I explicitly
mentioned it in the part of my previous post you snipped.
Oh yes, so you did.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Feb 26 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Jochem | last post by:
Today I spent a couple of hours searching for a bug, until I finally found out that the problems was the following: Correct: $path_upload = "$path/$file"; Instead of: Wrong: $path_upload =...
12
by: Markus.Elfring | last post by:
I am interested to know if the pointer value for the memory address can be changed by a compiler if the constness of the corresponding type is cast away. inline char* deconstify1(char const * X)...
1
by: Bernd Hohmann | last post by:
I have a question about using "*" in (sub)queries. This example query counts the number of records for a certain customer starting with record "80172" and stops after 10 rows. SELECT...
34
by: arnuld | last post by:
what is the difference between these 2: char name = "hackers"; char* name = "hackers";
3
by: per9000 | last post by:
Hi, can I print some default text on the console when doing a ReadLine? A silly example below shows two small scenarios. In the first a user is told what he appears to be called, and asks for a...
2
by: tvnaidu | last post by:
I am getting this error for line 108, I kept C code also below, any idea?. main.c:108: underscore in number main.c:108: syntax error before numeric constant 104: #define...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.