[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

seclecting child nodes based on a variable

Subject: seclecting child nodes based on a variable
From: "Najmi, Jamal" <Jamal.Najmi@xxxxxxxxxxx>
Date: Fri, 26 Apr 2002 15:39:01 -0400
value of child nodes
Hi, 

This is a very basic question: 

I need to identify an element and then get the text value of that element.
The only problem is that certain information of the XPath that leads to that
element are stored in variables.

Here is the code I have:
----------
<xsl:variable name="sectionShortName">
			<xsl:value-of select="../../../@name"/>
		</xsl:variable>
		<xsl:variable name="fieldShortName">
			<xsl:value-of select="./@name"/>
		</xsl:variable>
		
		<xsl:variable name="fieldValue">
			<xsl:value-of
select="$contentXml/SchemaTemplateExample/$sectionShortName/$fieldShortName"
/>  (This is here as an example, transformer complains on this line)
		</xsl:variable>

-------

Here is the XML file:

<?xml version="1.0" encoding="UTF-8"?>
<SchemaTemplateExample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="E:\Discovery\TEST\Cats.xsd">
	<wild_cats>
		<synopsis>wild cats synopsis data</synopsis>
		<detail>wild cats detail</detail>
	</wild_cats>
	<domestic_cats>
		<synopsis>domestic cats synopsis</synopsis>
		<detail>domestic cats detail</detail>
	</domestic_cats>
</SchemaTemplateExample>

-------

What I want to do is get to the data of the <synopsis> elements, for
example.  But information about the ancestor nodes of the text element i.e.
synopsis and wild_cats is contained in variables.  So what I want to do is a
conditional decent.  

I think what I need to do is get children of the 'SchemaTemplateExample'
node and then choose that child node whose name is similar to the value of
the $sectionShoteName variable .  But I do not know what it will take to
write such expression.

I will really appreciate any help I can get.

Thanks

Jamal

           

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.