Wednesday, April 10, 2013

XSL - Getting next node/previous node from the current node

XML Data

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum>
        <x>ABCDE</x>
        <y>30</y>
    </datum>
    <datum>
        <x>BCDEF</x>
        <y>20</y>
    </datum>
    <datum>
        <x>CDEFG</x>
        <y>-57</y>
    </datum>

</data>

XSL


<xsl:for-each select="data/datum">
      <xsl:value-of select="current()/preceding-sibling::*[1]/y"/>

      <xsl:value-of select="current()/y"/>
      <xsl:value-of select="current()/following-sibling::*[1]/y"/>
</xsl:for-each> 


Result

30 20 -57

3:08 PMtech-mashup

Related Posts:

  • 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 - 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
  • 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
  • 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
  • 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