XSLT Conditions, XSLT Tutorial, Global Guideline

Forum | Blog


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 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"?>

XSLT for XSLT Conditions Example [xslt_Conditions_Example.xsl]

<?xml version="1.0" encoding="ISO-8859-1"?>
<html xsl:version="1.0" xmlns:xsl="https://www.w3.org/1999/XSL/Transform" 
  <body style="font-family:Arial,helvetica,sans-serif;font-size:12pt;
    <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 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 test="gender='f'">
		<font color="red"><b>Miss </b></font>
                <xsl:value-of select="FirstName"/> 
                is working at Global Guide Line		


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 -  2021 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 474 visitors are online now