[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|