subsequence() function : subsequence « 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 » subsequence 
subsequence() function


File: Data.xml

<?xml version="1.0" encoding="utf-8"?>
<favorite-books>
  <booklist>
    <book isbn="1111111111" 
      favorite="f1">XSLT</book>
  </booklist>
</favorite-books>

File: Transform.xslt


<?xml version="1.0"?>
<xsl:stylesheet version="2.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:output method="text"/>
 
  <xsl:variable name="Dougs-favorites" as="node()*">
    <xsl:sequence 
      select="/favorite-books/booklist
              /book[contains(@favorite, 'Doug')]"/>
  </xsl:variable>

  <xsl:template match="/">
    <xsl:text>A test of the node-after (>>operator:</xsl:text>
    <xsl:text>&#xA;&#xA;  Comparing nodes from </xsl:text>
    <xsl:text>the sequence:&#xA;</xsl:text>

    <xsl:value-of 
      select="if (subsequence($Dougs-favorites, 1, 1) >>
                  subsequence($Dougs-favorites, 2, 1))
              then '    node1 >> node2 = true&#xA;'
              else '    node1 >> node2 = false&#xA;'"/>
    <xsl:value-of 
      select="if (subsequence($Dougs-favorites, 2, 1) >>
                  subsequence($Dougs-favorites, 1, 1))
              then '    node2 >> node1 = true&#xA;'
              else '    node2 >> node1 = false&#xA;'"/>
    <xsl:value-of 
      select="if (subsequence($Dougs-favorites, 1, 1) >>
                  subsequence($Dougs-favorites, 1, 1))
              then '    node1 >> node1 = true&#xA;'
              else '    node1 >> node1 = false&#xA;'"/>
  </xsl:template>

</xsl:stylesheet>

Output:

A test of the node-after (>>operator:

  Comparing nodes from the sequence:
    node1 >> node2 = false
    node2 >> node1 = false
    node1 >> node1 = false

 
Related examples in the same category
1. Define sequence
2. A list of sequence
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.