XSLT Combining, 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 Combining.

     Back             Next     

XSLT Combining is use to combine any other external XSLT document.  The <xsl:include> and <xsl:import> instructions give us ways to incorporate XSLT style sheets programmatically. There are two situations where this is useful.

Large and complex style sheets, like large complex other programs such as C++, are easier to maintain when you break them into multiple documents with specific roles to play. In XSLT combining, the <xsl:include> and <xsl:import> instructions let you assemble the pieces in one master XSLT document. This modular advance approach also makes it possible to share parts of a style sheet with other style sheets that only want certain features and not the whole thing; they can just include or import the parts they needed.

Customizing an existing style sheet without actually editing that style sheet is easy, because we incorporate it, and then separately override any template rules that don't do exactly what we want.

XSLT Tutorial section of <xsl:include> instruction is similar to the <xsl:include> instructions available in several programming languages like Java. The XSLT processor replaces it with the contents of the style sheet named in the href attribute. For example, the following XSLT_Combining.xsl style sheet names the XSLT_Combining_with_XSL_Include.xsl style sheet to incorporate that style sheet:

Example of XSLT Combining

XML for XSLT Combining Example with <xsl:include> [XSLT_Combining.xml]

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="XSLT_Combining.xsl"?>
    <employee username="Emp1">
    <employee username="Emp2">

XSLT for XSLT Combining Example [XSLT_Combining.xsl]

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="https://www.w3.org/1999/XSL/Transform"

<xsl:template match="employees">
<html xmlns="https://www.w3.org/1999/xhtml">
<head> <title>XSLT Combining Example in XSLT Tutorial</title> </head>
    <a href="https://www.globalguideline.com/xslt/"><font color="0066CC">
    Example of XSLT Combining at Global Guide Line XSLT Tutorial
  <h2>Employees at Global Guide Line</h2>
    <xsl:apply-templates select="employee">
      <xsl:sort select="employee_name" />
<xsl:include href="XSLT_Combining_with_XSL_Include.xsl"/>

XSLT Combining with <xsl:include> [XSLT_Combining_with_XSL_Include.xsl]

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

<xsl:template match="employee">
    <b><xsl:value-of select="employee_id"/></b>, 
    <i><xsl:value-of select="employee_name"/></i>  
    working at Global Guide Line.


Complete Example of XSLT Combining

View complete sources and outputs by simply clicking on file name of XSLT, XML and Out Put of XSLT Combining Example.

Caution:  Result may differ; in Microsoft internet explorer Netscape navigator or Firefox may display with a little bit of difference.

     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) 447 visitors are online now