Reputation: 19
i have the following xml properties file as input,
<Service>
<Provider>
<TEST1>http://example1.com</TEST1>
<TEST2>http://example2.com</TEST2>
<TEST3>http://example3.com</TEST3>
</Provider>
</Service>
in my xslt, based on the incoming request host name (example: https://test2service.example.com) ; using contains function i am saving environment value to a variable.
<xsl:variable name="Environment">
<xsl:choose>
<xsl:when test="contains($ConsumerHost, 'test1')">
<xsl:text>TEST1</xsl:text>
</xsl:when>
<xsl:when test="contains($ConsumerHost, 'test2')">
<xsl:text>TEST2</xsl:text>
</xsl:when> ..........
Now based on the environment variable value, i have to choose the backend server. below code is not working. Please suggest.
<xsl:variable name="HOST" select="//Provider/($Environment)/text()" />
Any other solutions are welcome! Thanks.
Upvotes: 1
Views: 2653
Reputation: 70648
Try this expression instead...
<xsl:variable name="HOST" select="//Provider/*[local-name() = $Environment]/text()" />
Upvotes: 3