template mode="index" : template match « 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 » template match 
template mode="index"



File: Data.xml

<?xml version="1.0"?>
<cv>
  <para>
    <performance>
      <publication>H</publication>
      G
      <venue>F</venue>
      E
      <group>D</group>
      C
      <date>1998</date>
      B
      <quote>
        A
      </quote>
    </performance>
  </para>
</cv>



File: Transform.xslt

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates />
        <table bgcolor="#cccccc" border="1" cellpadding="5">
          <tr>
            <td>
              <b>Date</b>
            </td>
            <td>
              <b>Venue</b>
            </td>
            <td>
              <b>Composer</b>
            </td>
            <td>
              <b>Work</b>
            </td>
            <td>
              <b>Role</b>
            </td>
          </tr>
          <xsl:apply-templates mode="index" />
        </table>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="performance" mode="index">
    <tr>
      <td>
        <xsl:value-of select="date" />
        &#xa0;
      </td>
      <td>
        <xsl:value-of select="venue" />
        &#xa0;
      </td>
      <td>
        <xsl:value-of select="composer" />
        &#xa0;
      </td>
      <td>
        <xsl:value-of select="work" />
        &#xa0;
      </td>
      <td>
        <xsl:value-of select="role" />
        &#xa0;
      </td>
    </tr>
  </xsl:template>


</xsl:stylesheet>

Output:

<html>
   <body>
        
          
            H
            G
            F
            E
            D
            C
            1998
            B
            
              A
            
          
        
      
      <table bgcolor="#cccccc" border="1" cellpadding="5">
         <tr>
            <td><b>Date</b></td>
            <td><b>Venue</b></td>
            <td><b>Composer</b></td>
            <td><b>Work</b></td>
            <td><b>Role</b></td>
         </tr>
           
             
         <tr>
            <td>1998
                       &nbsp;
                     
            </td>
            <td>F
                       &nbsp;
                     
            </td>
            <td>
                       &nbsp;
                     
            </td>
            <td>
                       &nbsp;
                     
            </td>
            <td>
                       &nbsp;
                     
            </td>
         </tr>
           
         
      </table>
   </body>
</html>

 
Related examples in the same category
1. Define and use template
2. Locate parent tags and get value from children tags
3. Select value from an element with value-of
4. Get two values in one template
5. match an element
6. output in template
7. set match mode to fulltext
8. match and get value operations with namespace
9. Call a template with parameter
10. template with parameters
11. output a table without loop
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.