Re: [xsl] Evaluating a variable as part of XPath Query

Subject: Re: [xsl] Evaluating a variable as part of XPath Query
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Mon, 06 Jan 2003 22:22:02 +0100
Hello Alan,

Alan Flaherty wrote:
Hi List,

I'm trying to use xslt to generate a number of controls for a page on a
website but some of the controls will need "referenced" values which are
found in the source xml file itself, these referenced values will always
be found in the settings section of the xml definition file, how can I
generate an XPath expression like so:

propertyPage/settings/elementId/text()

when 'elementId' is passed as the reference required from the xml file
to the xslt file, see below marked !!!Problem area!!!


In the samples below the method is (trying to be) used to generate the
full src of an iframe, some of the values the iframe page requires are
in the xml definition file

Settings section of xml file:
<propertyPage title="" tabHeight="400" tabWidth="380">
	<settings>
		<elementType>product</elementType>
		<elementId>-1</elementId>
	</settings>

....

Definition for iframe control:
<control type="iframe" title="General" x="5" y="5" w="290" h="140">
	<attributes src="iframe/Image.aspx">
		<param type="val" name="ImageType" value="FabricColor"/>
		<param type="property" name="ElementId"
value="elementId"/>
	</attributes>
</control>


Xslt <xsl:variable name="src">
<xsl:value-of select="concat(attributes/@src,'?')" />
<xsl:for-each select="attributes/param">
<xsl:choose>
<xsl:when test="string(@type)='property'">
<xsl:value-of select="@name" />
=



!!!! Problem Area, Looks like I misunderstood the meaning of
msxsl:node-set !!!


<xsl:value-of select="//settings/msxsl:node-set(@value)/text()"/>

<xsl:value-of select="//settings/*[name() = current()/@value]/text()"/>


This is possible only for one level in an XPath expression. For multiple levels like

<xsl:variable name="part-of-expr" select="test/test"/>
<xsl:value-of select="//foo/$part-of-expr/bar"/>

is *not* possible. Some processors have an extension function evaluate() for such requirements.
Example usage: <xsl:value-of select="xx:evaluate('//foo/' + $part-of-expr + '/bar')"/>.


Regards,

Joerg

			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="@name"
/>=<xsl:value-of select="@value"/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="following-sibling::node()">
			<xsl:text><![CDATA[&]]></xsl:text>
		</xsl:if>
	</xsl:for-each>
</xsl:variable>



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