XSLT Sorting, XSLT Tutorial, Global Guideline

Bookmark Bookmark: XSLT Sorting, XSLT Tutorial
Forum | Blog


      Home                    

Basic XSLT Tutorial.     
 XSLT Introduction.          
 XSLT Templates.            
 XSLT Attributes.              
 XSLT Transformation.     
 XSLT Variables.              
 XSLT Formatting.            
 XSLT Loops.                   
 XSLT Sorting.
 XSLT Conditions.             
 XSLT Multi Selection.     
 XSLT Functions.              
 XSLT Copying.                
 XSLT Combining.           
 XSLT Summary.              

XSLT Tutorial >> XSLT Sorting.


     Back             Next     



XSLT' sorting are instruction lets you sort a group of similar elements.  Identified as <xsl:sort> and attributes for this element let you to add details about how you want the sort done, e.g. you can sort using alphabetic or numeric ordering, sort on multiple keys, and reverse the sort order with use of  <xsl:sort>.

Now this XSLT Tutorial secetion of XSLT Sorting will guide how you should know quite a lot about XSLT to transform XML files HTML documents for rendering in Internet Explorer 5. This XSLT Tutorial section will guide you to use the HTML table model. We are going to show you how to sort XML data elements before showing them on browser.

Example of XSLT Sorting

XML Code for XSLT Sorting Example [XSLT_Sorting_Example.xml]

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="xslt_Sorting_Example.xsl"?>
  <globalGuideLine>
     <employee employee_id="ggl101">
       <FirstName>Jamima</FirstName>
       <LastName>Elisibith</LastName>
       <gender>Female</gender>
     </employee>
     <employee employee_id="ggl121">
       <FirstName>Alfa</FirstName>
       <LastName>Cute</LastName>
       <gender>Male</gender>
     </employee>
     <employee employee_id="ggl130">
       <FirstName>Kethrin</FirstName>
       <LastName>Bruster</LastName>
       <gender>Female</gender>
     </employee>
  </globalGuideLine>

XSLT for XSLT Sorting Example [xslt_Sorting_Example.xsl]

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

<xsl:output method="text"/>

<xsl:template match="globalGuideLine">
  <xsl:apply-templates>
    <xsl:sort select="FirstName"/>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="employee">
  Employee ID:  <xsl:apply-templates select="@employee_id"/>
  First Name:   <xsl:apply-templates select="FirstName"/>
  Last Name:    <xsl:apply-templates select="LastName"/>
  Gender:       <xsl:apply-templates select="gender"/>
  <xsl:text>
  </xsl:text>
</xsl:template>

</xsl:stylesheet>


Complete Example of XSLT Sorting

XSLT Tutorial sources and outputs of XSLT sorting view it by simply clicking on file name of XSLT, XML and Out Put of XSLT Sorting Example

     Back             Next     
 

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2018 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 243 visitors are online now