473,395 Members | 1,578 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,395 software developers and data experts.

XPATH: Selecting child nodes wich are NOT equal to

Hello,

suppose i have a dom like this:

<a>
- <b>
- <b>
- <d>
- </b>
- <c>
- <e/>
- </c>
- <f/>
</a>
now to select al f child nodes of a, is : a[f]

but how do i select all child nodes of a that are not equeal to f??

a[!f] does not work.

How do i do that??!?!?!
Jul 20 '05 #1
9 16586
Tjerk Wolterink wrote:
Hello,

suppose i have a dom like this:

<a>
- <b>
- <b>
- <d>
- </b>
- <c>
- <e/>
- </c>
- <f/>
</a>
now to select al f child nodes of a, is : a[f]

but how do i select all child nodes of a that are not equeal to f??

a[!f] does not work.

How do i do that??!?!?!


is it this?

a[child:* != f]
Jul 20 '05 #2
Hi,
suppose i have a dom like this:

<a>
- <b>
- <b>
- <d>
- </b>
- <c>
- <e/>
- </c>
- <f/>
</a>
now to select al f child nodes of a, is : a[f]
That's not correct actually. It should be a/f
but how do i select all child nodes of a that are not equeal to f??

a[!f] does not work.

How do i do that??!?!?!


is it this?

a[child:* != f]

No, what you need is:

a/*[not(self::f)]
or
a/*[local-name()!='f']

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #3
wait ii'm saying it al wrong,

suppose i have the folowwing xml:

<a>
<d>ereR</d>
Hey <b>i <c><d>a</d>m<c></b>
</q>Henk<q>
<d>erer</d>
</a>
Now i with xsl:

<xsl:template match="a">
<xsl:value-of select="[XPATH]"/>
</xsl:template>

Where [XPATH] should select the text of a without the <d></d> elements
of the contents of the a element
So it should select:
Hey <b>i <c>m<c></b>
</q>Henk<q>

because that is all in a without <d> elements

How do i do that?

Jul 20 '05 #4
> <a>
<d>ereR</d>
Hey <b>i <c><d>a</d>m</c></b>
<q>Henk</q>
<d>erer</d>
</a>
Now i with xsl:

<xsl:template match="a">
<xsl:value-of select="[XPATH]"/>
</xsl:template>

Where [XPATH] should select the text of a without the <d></d> elements
of the contents of the a element
So it should select:
Hey <b>i <c>m</c></b>
<q>Henk</q>
How do i do that?

Hi,

I don't think it can be put in one Xpath expression. (I could be mistaking).

To get the sample output you gave, you'd have to do something like this:

<xsl:template match="a">
<xsl:apply-templates select="node()[not(self::d)]" mode="ignore-d"/>
</xsl:template>

<xsl:template match="*" mode="ignore-d">
<xsl:copy>
<xsl:apply-templates select="node()[not(self::d)]" mode="ignore-d"/>
</xsl:copy>
</xsl:template>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #5
that did not help,
let me give an example:

<page:link page="pages/medewerker.page.xml">
<page:var>
<page:name>id</page:name <page:value>value</page:value>
</page:var>
<page:var>
<page:name>id2</page:name <page:value>value2</page:value>
</page:var>
Bla <center>Bla <b>Bla</b></center>
</page:link>
This should be transformed to:

<a href="/index.php?page=pages/medewerker.page.xml&id=value&id2=value2">
Bla <center>Bla <b>Bla</b></center>
</a>

Well i dont know how to do that,
now i have the following xsl-template:

<!--
! Matches a link to another page.xml file
!-->
<xsl:template match="page:link">
<a>
<xsl:attribute name="href">
/index.php?page=<xsl:value-of select="@page"/>
<xsl:for-each select="page:var">
&amp;<xsl:value-of select="page:name"/>=<xsl:value-of
select="page:value"/>
</xsl:for-each>
</xsl:attribute>
<xsl:value-of select="./text()./*[not(self::page:var)]"/> -->
</a>
</xsl:template>

How should i do it?
Jul 20 '05 #6
> that did not help,
let me give an example:

<page:link page="pages/medewerker.page.xml">
<page:var>
<page:name>id</page:name <page:value>value</page:value>
</page:var>
<page:var>
<page:name>id2</page:name <page:value>value2</page:value>
</page:var>
Bla <center>Bla <b>Bla</b></center>
</page:link>
This should be transformed to:

<a href="/index.php?page=pages/medewerker.page.xml&id=value&id2=value2">
Bla <center>Bla <b>Bla</b></center>
</a>


It works for me with these templates:

###########################################
<xsl:template match="page:link">
<a>
<xsl:attribute name="href">
/index.php?page=<xsl:value-of select="@page"/>
<xsl:for-each select="page:var">
&amp;<xsl:value-of select="page:name"/>=<xsl:value-of select="page:value"/>
</xsl:for-each>
</xsl:attribute>
<xsl:apply-templates select="node()[not(self::page:var)]" mode="ignore"/>
</a>
</xsl:template>

<xsl:template match="*" mode="ignore">
<xsl:copy>
<xsl:apply-templates select="node()[not(self::page:var)]" mode="ignore"/>
</xsl:copy>
</xsl:template>

###########################################
But if the xml structure really is a simple as in this example (no deeper nested elements that should be ignored), than this would suffice:

<xsl:template match="page:link">
<a>
<xsl:attribute name="href">
/index.php?page=<xsl:value-of select="@page"/>
<xsl:for-each select="page:var">
&amp;<xsl:value-of select="page:name"/>=<xsl:value-of select="page:value"/>
</xsl:for-each>
</xsl:attribute>
<xsl:copy-of select="node()[not(self::page:var)]"/>
</a>
</xsl:template>

################################

Does this help, or am I still not understanding your question?

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #7
Joris Gillis wrote:
that did not help,
let me give an example:

<page:link page="pages/medewerker.page.xml">
<page:var>
<page:name>id</page:name
<page:value>value</page:value>
</page:var>
<page:var>
<page:name>id2</page:name
<page:value>value2</page:value>
</page:var>
Bla <center>Bla <b>Bla</b></center>
</page:link>
This should be transformed to:

<a href="/index.php?page=pages/medewerker.page.xml&id=value&id2=value2">
Bla <center>Bla <b>Bla</b></center>
</a>

It works for me with these templates:

###########################################
<xsl:template match="page:link">
<a>
<xsl:attribute name="href">
/index.php?page=<xsl:value-of select="@page"/>
<xsl:for-each select="page:var">
&amp;<xsl:value-of select="page:name"/>=<xsl:value-of
select="page:value"/>
</xsl:for-each>
</xsl:attribute>
<xsl:apply-templates select="node()[not(self::page:var)]" mode="ignore"/>
</a>
</xsl:template>

<xsl:template match="*" mode="ignore">
<xsl:copy>
<xsl:apply-templates select="node()[not(self::page:var)]" mode="ignore"/>
</xsl:copy>
</xsl:template>

###########################################
But if the xml structure really is a simple as in this example (no
deeper nested elements that should be ignored), than this would suffice:

<xsl:template match="page:link">
<a>
<xsl:attribute name="href">
/index.php?page=<xsl:value-of select="@page"/>
<xsl:for-each select="page:var">
&amp;<xsl:value-of select="page:name"/>=<xsl:value-of
select="page:value"/>
</xsl:for-each>
</xsl:attribute>
<xsl:copy-of select="node()[not(self::page:var)]"/>
</a>
</xsl:template>

################################

Does this help, or am I still not understanding your question?

regards,


Thanks for your help,

i think i fout a solution.
Jul 20 '05 #8
On Sat, 30 Oct 2004 15:33:01 +0200, Tjerk Wolterink <tj***@wolterinkwebdesign.com> wrote:
Joris Gillis wrote:

<snip>
################################

Does this help, or am I still not understanding your question?

regards,


Thanks for your help,

i think i fout a solution.

which was...?

Jul 20 '05 #9
Hi,
suppose i have a dom like this:
<a>
- <b>
- <b>
- <d>
- </b>
- <c>
- <e/>
- </c>
- <f/>
</a>
now to select al f child nodes of a, is : a[f]
That's not correct actually. It should be a/f
but how do i select all child nodes of a that are not equeal to f??
a[!f] does not work.
How do i do that??!?!?!


is it this?

a[child:* != f]


What you need is:

a/*[not(self::f)]
or
a/*[local-name()!='f']

regards,

--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 20 '05 #10

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

Similar topics

1
by: Vijay | last post by:
Hi Can anybody explain what self::* means in Xpath. I understand that "self" means the context node itself and * means any node type. So I thought self::* meant all the child nodes of context,...
2
by: nkunapa | last post by:
Hi: Is there a way in XPATH to find the nearest node of the node in context with a certain attribute value. Here is my problem. I have the following XML and I am trying to add all the nodes with...
7
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
1
by: Dave | last post by:
Is it possible to get <codes><code id="4"><name>abc</name></code></codes from the XML below in single SelectSingleNode/xPath expression step OR is going to have to be a multi=step process of...
2
by: nick_tucker | last post by:
Hi, I am very new to XML and XPATH. I have made a sample XML fileto ask my question. <?xml version="1.0" encoding="utf-8"?> <Test> <A> <B> <C> <D>
4
by: eric.goforth | last post by:
In an xsl stylesheet, I have <xsl:when test="string-length(//mystuff) &gt; 0"> <xsl:attribute name="someattribute">blahblahblah</xsl:attribute> </xsl:when> In the xml that mystuff is several...
3
by: SD | last post by:
Hi, How can i get all the nodes with attribute Name = "Publisher" or Name="Administrator" using XPath query and C# for this xml doc? <GetRoleCollectionFromUser...
3
by: jmagaram | last post by:
I have a DataSet I want to work with as Xml using XmlDataDocument. I can't figure out how to query the resultant Xml using XPath. From the following XML below, what XPath query will return the list...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.