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

Related Posts:

  • 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"  &nbs… Read More
  • XSLT - Tips to make you a better XSLT programmerThe combination of XML and XSLT is growing in popularity with webmasters of medium-sized and large Web sites. Prior to XSLT, changing the presentation of a Web site was a major undertaking: one had to revisit and to change ev… Read More
  • XSL - Select Node Name LocaleName <xsl:value-of select="local-name()" />   Name <xsl:value-of select="name()" /> Select Parent node as node <xsl:value-of select="*[name(parent::*)]" /> … Read More
  • XSLT - Resize External GraphicResize External Graphic <fo:external-graphic  src="s\image.png"   content-height="scale-to-fit"  height="2.00in"   content-width="2.00in"  scaling="non-uniform"/> Or <xsl:attribute-set na… Read More
  • XSL - xsl:call-template or xsl:function XSL version 1.0 There is no xsl:function in XSL version 1.0 <xsl:template name="helloWorld"> <xsl:text>Hello World!</xsl:text> </xsl:template> (...) <xsl:template match… Read More