0

I'm trying to do something like :

<xsl:variable name="typetest" 
              select="substring-before(
                         (substring-after(base-uri(),'Test_')),
                         '_'
                      )"/>          
<xsl:variable name="minAdd"+"$typetest" 
              select="teststep[@name='add"$typetest"Etalon']/@min"/>

I can't find the right way to use my var $typetest in both the name and the select of the other var. I'dont know if it is possible, i am using XSLT 2.0

3
  • 4
    You can't do exactly that, but maybe if you explain what you're trying to achieve there might be a different way to accomplish the same thing. Commented Feb 22, 2011 at 16:40
  • Showing us code that doesn't work isn't a good way of explaining your requirement. But you seem to be under the impression that XSLT variables work by textual substitution, which is not the case. A variable reference $x is an expression that evaluates to a value (not a fragment of program text), and you can only use it where a value is expected. Commented Feb 22, 2011 at 21:53
  • First of all, this is not even proper XML... Second, why you want a dynamic name for variables? Why you would want that for any language other than XSLT? If you want some kind of a key map structure, why don't you use an intermediate XML result? Commented Feb 23, 2011 at 18:36

1 Answer 1

1

A variable name must be a valid qname. It cannot be the result of an expression. Source:

<!-- Category: declaration -->
<!-- Category: instruction -->
<xsl:variable
  name = qname
  select? = expression
  as? = sequence-type>
  <!-- Content: sequence-constructor -->
</xsl:variable>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.