Tuesday, April 16, 2013

XSL - Select Node by variable name

Case 1

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:dyn="http://exslt.org/dynamic" extension-element-prefixes="dyn"

>

The dyn:evaluate function evaluates a string as an XPath expression and returns the resulting value, which might be a boolean, number, string, node set, result tree fragment or external object. The sole argument is the string to be evaluated.

dyn:evaluate($xpath_expression)

http://www.exslt.org/dyn/functions/evaluate/index.html

Case 2

*[name() = $xpath_expression]

Case 3

XSLT 2.0
*[ends-with(name(), $xpath_expression)]

XSLT 1.0

*[substring(name(),string-length(name())-1) = $xpath_expression]


 
3:12 PMtech-mashup