select="following-sibling::notification[count(preceding-sibling::employeeName[1] | current()) = 1]" : following sibling « XSLT stylesheet « XML

XML
1. CSS Style
2. SVG
3. XML Schema
4. XQuery
5. XSLT stylesheet
Java
XML Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
XML » XSLT stylesheet » following sibling 
select="following-sibling::notification[count(preceding-sibling::employeeName[1] | current()) = 1]"


File: Data.xml

<?xml version="1.0"?>
<group>
  <employeeName>Samson</employeeName>
  <notification>0001</notification>
  <notification>name 1</notification>
  <notification>0003</notification>

  <employeeName>Delihla</employeeName>
  <notification>0004</notification>
  <notification>0005</notification>
  <notification>0006</notification>
</group>

File: Transform.xslt
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="html" indent="yes" />
  <xsl:template match="/">
    <xsl:apply-templates select="group" />
  </xsl:template>
  <xsl:template match="group">
    <xsl:for-each select="employeeName">
      <tr>
        <td>
          <xsl:value-of select="." />
        </td>
        <xsl:for-each
          select="following-sibling::notification[count(preceding-sibling::employeeName[1] | current()) = 1]">
          <td>
            <xsl:value-of select="." />
          </td>
        </xsl:for-each>
      </tr>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

Output:

<tr>
   <td>Samson</td>
   <td>0001</td>
   <td>name 1</td>
   <td>0003</td>
</tr>
<tr>
   <td>Delihla</td>
   <td>0004</td>
   <td>0005</td>
   <td>0006</td>
</tr>

 
Related examples in the same category
1. following-sibling demo
2. following-sibling
3. select="following-sibling::*[1]/contact/name/firstName"
4. following-sibling::node()[1][not(self::NL)]
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.