473,396 Members | 2,111 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,396 software developers and data experts.

Simple parent value xsl question



I have the following XML
<root>
<Companies>
<Name>Labs</Name>
<display>Labs </display>
<val>1</val>
<Products>
<val>1</val>
<display>Maxa</display>
<CompanyKey>1</CompanyKey>
<Topics>
<val>3</val>
<display>Psychological</display>
<CompanyKey>1</CompanyKey>
<product>1</product>
</Topics>
<Topics>
<val>5</val>
<display>Finance</display>
<CompanyKey>1</CompanyKey>
<product>1</product>
</Topics>

And the following XSL

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="listboxname" />
<xsl:param name="mainTable" />
<xsl:param name="subTable" />

<xsl:template match="/">
<xsl:call-template name="main" >
<xsl:with-param name="nodes" select="child::node()"/>
</xsl:call-template>

</xsl:template>

<xsl:template name="main">
<xsl:param name="nodes"/>
<xsl:for-each select="$nodes">
<xsl:value-of select="parent::val"/>
<xsl:if test="val">
<xsl:value-of select="concat(val,'-')" />
</xsl:if>
<xsl:if test="display">
<xsl:value-of select="concat(display,'*')" />
</xsl:if>
<xsl:call-template name="main">
<xsl:with-param name="nodes" select="child::node()"/>
</xsl:call-template>
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

The output is:

1-Labs *11-Maxa*13-Psychological*35-Finance*56-Managed Care (MSMs
Representative Only)*62-Namenda*22-Alzheimer's
Disease*23C8B03C9-44A0-4C9B-82E1-B2CD95FDC13A-Long-Term
Care*3C8B03C9-44A0-4C9B-82E1-B2CD95FDC13A652089A7-E8BC-42AB-BC75-833280A
B65AF-Managed
Care*652089A7-E8BC-42AB-BC75-833280AB65AF

For <xsl:value-of select="parent::val"/>
Why does it not print the val of the parent.
For e.g. for Finance it should print 1 (val of Products) why is is
printing 3, which is the val of Psychological
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
1 7498
> For <xsl:value-of select="parent::val"/>
Why does it not print the val of the parent.
For e.g. for Finance it should print 1 (val of Products) why is is
printing 3, which is the val of Psychological

Hi,

Because the Xpath expression 'parent::val' selects a parent that is called 'val', it does not select the 'val' child of the parent or anything like that.
Either use:
<xsl:value-of select="parent::*/child::val"/>
or <xsl:value-of select="../val"/>

Btw, are those named-templates and with-params really neccesary?

regards,

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #2

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

Similar topics

0
by: readytohelp | last post by:
I have the following XML <root> <Companies> <Name>Labs</Name> <display>Labs </display> <val>1</val> <Products> <val>1</val> <display>Maxa</display> <CompanyKey>1</CompanyKey>
1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
13
by: LRW | last post by:
Having a problem getting a onSubmit function to work, to where it popsup a confirmation depending on which radiobutton is selected. Here's what I have: function checkdel() { if...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
6
by: paul | last post by:
HI! How do we send a variable from an Iframe page back to its parent? I have a script that calculates the iframe's window size but I need to know how to send that value back to its parent so I...
2
by: Fendi Baba | last post by:
I created a person table with various fields such as Suffix, Salutation, etc, Some of these fields may not be mandatory for example suffix. In the actual table itself, I only have a field for...
1
by: Eric_Dexter | last post by:
I am just trying to acess a function in wordgrid (savefile) to a button that is defined in TestFrame. I can't seem to make it work I either get an error that my variable isn't global or it makes...
0
bartonc
by: bartonc | last post by:
#Boa:Dialog:DBConnectDialog import wx ##"""Given a set if login specs, create a dbServer instance and ## ensure that there is a valid, open connection to the database. ## If not, set the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.