473,320 Members | 1,953 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.

XMLT and XPath

Hey everybody,

I have some problems with XPath expressions.

I try to find out, if a node that I have stored in a variable is a child
node of the current node from a lop.

I will show you my xml and xmlt file where I have tryed this:

---My xml-file-----------
<websites>

<categorie name="Startseite">
<website id= "a1" pagename="Startseite" erstellt="20.08.2002"
geaendert="24.08.2002" />

</categorie>

<categorie name="Über uns">

<website id= "b1" pagename="Startseite" erstellt="20.08.2002"
geaendert="24.08.2002" />

</categorie>

<categorie name="Leistungen">

<website id= "c1" pagename="Leistungen" erstellt="20.08.2002"
geaendert="24.08.2002" />

</categorie>

<categorie name="Referenzen">

<website id= "d1" pagename="Startseite" erstellt="20.08.2002"
geaendert="24.08.2002" />

</categorie>

</websites>

------------------------------------------

-----my xmlt template-----

<xsl:template name="MainNav">

<xsl:variable name="aktPage">

<xsl:value-of select="//website[2]" />

</xsl:variable>
<xsl:for-each select="//categorie">

<xsl:choose>

<xsl:when test="$aktPage=./child::node()">

<p><strong><xsl:value-of select="@name"/></strong></p>

</xsl:when>

<xsl:otherwise>

<p><xsl:value-of select="@name"/></p> </xsl:otherwise>

</xsl:choose>

</xsl:for-each>

</xsl:template>

--------------------------------

The aktPage variable shoud store the second website node of the xml-file.
The loop goes to every categorie and a want to test if the website node that
a stored in the aktPage variable is a child of the current loop entry

Mayby someone can help me

Thanks for any hint

Greetings from Germany

Heinz Willi Wiedow


Nov 11 '05 #1
2 3328
> <xsl:when test="$aktPage=./child::node()">

This does not compare the node contained in $aktPage with any of the
children nodes of the current node. What is compared is their string values.

To find if a node $nd belongs to a node-set $nset use the following:

count($nd | $nset) = count($nset)

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Heinz Willi Wiedow" <he**********@gmx.de> wrote in message
news:u4*************@TK2MSFTNGP11.phx.gbl...
Hey everybody,

I have some problems with XPath expressions.

I try to find out, if a node that I have stored in a variable is a child
node of the current node from a lop.

I will show you my xml and xmlt file where I have tryed this:

---My xml-file-----------
<websites>

<categorie name="Startseite">
<website id= "a1" pagename="Startseite" erstellt="20.08.2002"
geaendert="24.08.2002" />

</categorie>

<categorie name="Über uns">

<website id= "b1" pagename="Startseite" erstellt="20.08.2002"
geaendert="24.08.2002" />

</categorie>

<categorie name="Leistungen">

<website id= "c1" pagename="Leistungen" erstellt="20.08.2002"
geaendert="24.08.2002" />

</categorie>

<categorie name="Referenzen">

<website id= "d1" pagename="Startseite" erstellt="20.08.2002"
geaendert="24.08.2002" />

</categorie>

</websites>

------------------------------------------

-----my xmlt template-----

<xsl:template name="MainNav">

<xsl:variable name="aktPage">

<xsl:value-of select="//website[2]" />

</xsl:variable>
<xsl:for-each select="//categorie">

<xsl:choose>

<xsl:when test="$aktPage=./child::node()">

<p><strong><xsl:value-of select="@name"/></strong></p>

</xsl:when>

<xsl:otherwise>

<p><xsl:value-of select="@name"/></p> </xsl:otherwise>

</xsl:choose>

</xsl:for-each>

</xsl:template>

--------------------------------

The aktPage variable shoud store the second website node of the xml-file.
The loop goes to every categorie and a want to test if the website node that a stored in the aktPage variable is a child of the current loop entry

Mayby someone can help me

Thanks for any hint

Greetings from Germany

Heinz Willi Wiedow


Nov 11 '05 #2
Wow it works, thanks a lot.

--
Greetings from Germany

Heinz Willi Wiedow

"Dimitre Novatchev" <dn********@yahoo.com> schrieb im Newsbeitrag
news:bj************@ID-152440.news.uni-berlin.de...
<xsl:when test="$aktPage=./child::node()">
This does not compare the node contained in $aktPage with any of the
children nodes of the current node. What is compared is their string

values.
To find if a node $nd belongs to a node-set $nset use the following:

count($nd | $nset) = count($nset)

=====
Cheers,

Nov 11 '05 #3

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
2
by: Heinz Willi Wiedow | last post by:
Hey XML-Fans, I transform some XML-Files with XmlT to html. I want to have a DOCTYPE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
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: 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.