This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]