RE: [xsl] seclecting child nodes based on a variable

Subject: RE: [xsl] seclecting child nodes based on a variable
From: "Najmi, Jamal" <Jamal.Najmi@xxxxxxxxxxx>
Date: Fri, 26 Apr 2002 15:59:44 -0400
I have the solution:

Use 

/*[name()="$variable_name]/

Jamal

-----Original Message-----
From: Najmi, Jamal [mailto:Jamal.Najmi@xxxxxxxxxxx]
Sent: Friday, April 26, 2002 8:39 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: [xsl] seclecting child nodes based on a variable 


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

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


Current Thread