XSLT Conditions, XSLT Tutorial, Global Guideline

Bookmark Bookmark: XSLT Conditions, XSLT Tutorial
Forum | Directory | 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.              


Submit your link

XSLT Tutorial >> XSLT Conditions.


     Back             Next     



XSLT Conditions provide us to control our work flow.  Suppose in an organization number of employees are working and every one knows each other by face or name either employee is he or she.  It mean to say that somebody we have to call as Mr. or Miss in case of gender. Every programming language have functionality to control flow with if else statement;  So here in XSLT we also have a structure to follow for the defining the Conditions in XSLT.

Here we can get into with real example.

Example of XSLT Conditions

XML Code for XSLT Conditions Example [XSLT_Conditions_Example.xml]

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="xslt_Sorting_Example.xsl"?>
  <globalGuideLine>
     <employee>
       <FirstName>Jamima</FirstName>
       <LastName>Elisibith</LastName>
       <gender>f</gender>
     </employee>
     <employee>
       <FirstName>Alfa</FirstName>
       <LastName>Cute</LastName>
       <gender>m</gender>
     </employee>
     <employee>
       <FirstName>Kethrin</FirstName>
       <LastName>Bruster</LastName>
       <gender>f</gender>
     </employee>
  </globalGuideLine>

XSLT for XSLT Conditions Example [xslt_Conditions_Example.xsl]

<?xml version="1.0" encoding="ISO-8859-1"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns="http://www.w3.org/1999/xhtml">
  <body style="font-family:Arial,helvetica,sans-serif;font-size:12pt;
        background-color:#EEEEEE">
    <xsl:for-each select="globalGuideLine/employee">
    <xsl:sort select="FirstName"/>
      <div style="background-color: #cccccc;color:000000;padding:0px">
        <span style="font-weight:bold;color:#000000">
        <xsl:value-of select="FirstName"/> <xsl:value-of select="LastName"/></span>
      </div>

      <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
        <span style="font-style:none">
	   <xsl:if test="gender='m'">
		<font color="red"><b>Mr. </b></font> 
                <xsl:value-of select="FirstName"/> 
                is working at Global Guide Line
	   </xsl:if>
	   <xsl:if test="gender='f'">
		<font color="red"><b>Miss </b></font>
                <xsl:value-of select="FirstName"/> 
                is working at Global Guide Line		
	   </xsl:if>
        </span>
      </div>
    </xsl:for-each>
  </body>

</html>

Complete Example of XSLT Conditions

XSLT Tutorial sources of XSLT Condition, view it by simply clicking on file name of XSLT, XML and Out Put of XSLT Conditions Example

     Back             Next     
 

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

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