Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives

From: "PlutoPlanet" <info@------.-->
To: NULL
Date: 11/8/2006 12:31:00 AM

Hello world,

My problem: I need to create a xsl template for a <SELECT>.
The template should be re-usable, therefore I tried to pass the
attribute's name as param.
See the code below.

How should I create an xsl template which I can use to populate with
both attributes (myValue or myOtherValue).

// content of xml file
<root>
	<preselected>
		<id>1</id>
		<value>one</value>
	</preselected>

	<something>
		<myexample myId="1" myValue="one" myOtherValue="uno" />
		<myexample myId="2" myValue="two" myOtherValue="due" />
	</something>
</root>


// xsl file

<xsl:call-template name="TSelect">
	<xsl:with-param name="OptionSelected" select="root/preselected/id" />
	<xsl:with-param name="Options" select="root/something/myexample" />
	<xsl:with-param name="Value" select="'myValue'" />
</xsl:call-template>

<xsl:call-template name="TSelect">
	<xsl:with-param name="OptionSelected" select="root/preselected/id" />
	<xsl:with-param name="Options" select="root/something/myexample" />
	<xsl:with-param name="Value" select="'myOtherValue'" />
</xsl:call-template>


<xsl:template name="TSelect">
	<xsl:param name="OptionSelected" />
	<xsl:param name="Options" />
	<xsl:param name="Value" />
	<select>
		<xsl:call-template name="TOption">
			<xsl:with-param name="OptionSelected" select="$OptionSelected" />
			<xsl:with-param name="Options" select="$Options" />
			<xsl:with-param name="Value" select="$Value" />
		</xsl:call-template>
	</select>
</xsl:template>

<xsl:template name="TOption">
	<xsl:param name="OptionSelected" />
	<xsl:param name="Options" />
	<xsl:param name="Value" />

	<xsl:for-each select="$Options">
		<option value="'whatever'">
<!-- THIS WORKS -->
			<xsl:value-of select="@myValue" />
<!-- THIS WORKS NOT -->
<!-- HOW CAN I MAKE THIS DYNAMICALLY? -->
			<xsl:value-of select="$@Value" />
		</option>
	</xsl:for-each>
</xsl:template>


yours,

Herwig


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent