0

How do I select a specific element from a variable in XSLT 1.0? I can see all of the elements by using <xsl:copy-of select="$foo"/> but what if I would only want a value from one element within the variable?

user2475310
  • 733
  • 4
  • 13
  • 19
  • That depends exactly what your variable contains and how it is defined. Can you show the `` definition? Are you setting it with a `select="..."` or with nested children? – Ian Roberts Jan 25 '14 at 00:00

1 Answers1

0

Use XPath to address the element that you want.

For instance:

$foo/bar

A more complete answer could be provided if you posted sample XML, showed how you are assigning the $foo variable, and which element value you are trying to address.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • Here is the variable ` foo5 foo6 ` When I do this `` It does not work. – user2475310 Jan 25 '14 at 01:11
  • That's a limitation in xslt 1.0. It does work if you assign something from the source document to the variable Test (using the `select` attribute) but not if you assign it with xml from the .xslt file directly.Technically that's because the former is a node-set and the latter is a result-tree fragment. Check this question out if you want to know more: http://stackoverflow.com/questions/9837589/result-tree-fragment-to-node-set-generic-approach-for-all-xsl-engines – Erwin Bolwidt Jan 25 '14 at 03:35