This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: How to get a value from other node
- From: Aleksander Bracko <aleksander dot bracko at hermes dot si>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 31 Jan 2002 09:39:50 +0100
- Subject: RE: [xsl] How to get a value from other node
- Reply-to: xsl-list at lists dot mulberrytech dot com
Well i'm doing a test because i would a value from the tag <address> which
bellongs to the tag <city name="city2">. And if use the way you wrote it,
then i'll always get value from the first city/address node and i want a
value from the second or even third node.
The main problem here is that i am currently in the node <header> (there
would be no problem if i would be in the node <content>) and now i would
need to go one node back to get to the right one. The problem is with these
templates.
-----Original Message-----
From: stevenson [mailto:stevenson@epr.footman-walker.com]
Sent: Thursday, January 31, 2002 9:16 AM
To: xsl-list@lists.mulberrytech.com
Subject: RE: [xsl] How to get a value from other node
am not quite sure why you are doing a tes. Anyway i would do something like
this:
<xsl:value-of select="MyXml/content/city/address" />
-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Aleksander Bracko
Sent: 31 January 2002 10:56
To: 'XSL-List@lists.mulberrytech.com'
Subject: [xsl] How to get a value from other node
I have following XML:
<MyXml>
<header>
<location>
Home
</location>
</header>
<content>
<city name = "city1">
<address>
Address1
</address>
</city>
<city name = "city2">
<address>
Address2
</address>
</city>
</content>
</MyXml>
My XSL looks like this:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="header">
<MyHome>
<xsl:value-of select="location"/> <------ After this I
want to insert another value from other node (address)
</MyHome>
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
And now my problem is:
I would like to insert another value, but from other node. I thought that i
could use a line like this one, but it doesn't work
<xsl:if test="../content/city@name[.='city2']">
<xsl:value-of select="../content/city/address" />
</xsl:if>
If u could please help me out.
Thanx, Alex
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list