<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Expressing IT &#187; XSL Includes</title>
	<atom:link href="http://developer.expressionz.in/blogs/tag/xsl-includes/feed/" rel="self" type="application/rss+xml" />
	<link>http://developer.expressionz.in/blogs</link>
	<description>User Interface : just another, but a serious developers weblog</description>
	<lastBuildDate>Thu, 20 May 2010 18:05:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Include XSL inside XSL</title>
		<link>http://developer.expressionz.in/blogs/2008/05/04/include-xsl-inside-xsl/</link>
		<comments>http://developer.expressionz.in/blogs/2008/05/04/include-xsl-inside-xsl/#comments</comments>
		<pubDate>Sun, 04 May 2008 09:48:51 +0000</pubDate>
		<dc:creator>Nikhil</dc:creator>
				<category><![CDATA[XSL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSL Includes]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://developer.expressionz.in/blogs/?p=16</guid>
		<description><![CDATA[Imagine you are creating a website (and using XML, XSL transfroms ofcourse) and most of the pages would have a <strong>Comments Module </strong>. Well! then either you copy or paste this code into every page template or even better you create an INCLUDE file can call it where ever you want it in your main page template...<strong>So HOW DO WE INCLUDE a XSL file inside another XSL file</strong>? Here is how...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeveloper.expressionz.in%2Fblogs%2F2008%2F05%2F04%2Finclude-xsl-inside-xsl%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeveloper.expressionz.in%2Fblogs%2F2008%2F05%2F04%2Finclude-xsl-inside-xsl%2F&amp;source=nikhild&amp;style=normal&amp;hashtags=Tutorials,XML,XSL,XSL+Includes,XSLT" height="61" width="50" /><br />
			</a>
		</div>
<p>If XML/XSL Transforms is your domian, then there are times when we want a peice of Dynamic code to be used library item(to be made re-usable). What I mean , probably could be made more clear with this example scenario.</p>
<p>Imagine you are creating a website (and using XML, XSL transfroms ofcourse) and most of the pages would have a <strong>Comments Module </strong>. Well! then either you copy or paste this code into every page template (which I dont have say, but make maintenance and rework a nightmare) or even better, you create an INCLUDE file which could be pulled in where ever you want it in your page(s)&#8230;<br />
<strong>So HOW DO WE CREATE a XSL INCLUDE file and include it inside another XSL file</strong>? Here is how&#8230;</p>
<p>Just to make things clear &#8230; here is quick list of files that you would create &#8230; here , we will be including info about fruits and vegetables into a parent page called food.</p>
<p>1. food.xml &#8211; xml data file on which the transformation will be applied<br />
2. food.xsl  -  main XSL file, which will transform our food.xml<br />
3. inc_fruits.xsl &#8211; XSL include file that will render fruits data<br />
4. inc_vegtables.xsl &#8211; XSL include file that will render vetetables data</p>
<p>I dont think I have explain much , the codes for above elements , will be self explanatory&#8230;</p>
<p><strong>FOOD.XML</strong></p>
<blockquote>
<div><code><br />
&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;<br />
&lt;?xml-stylesheet type="text/xsl" href="food.xsl"?&gt;<br />
&lt;food&gt;<br />
&lt;date&gt;July 2008&lt;/date&gt;<br />
&lt;description&gt;All about things we eat everyday&lt;/description&gt;<br />
&lt;fruits type="tropical"&gt;<br />
&lt;item name="mango" moreinfo="http://www.mango.com"&gt;Mango is the king of fruits&lt;/item&gt;<br />
&lt;item name="banana" moreinfo="http://www.banana.com"&gt;Banana once a day , keeps the doctor away&lt;/item&gt;<br />
&lt;item name="orange" moreinfo="http://www.orange.com"&gt;Orange is the color and rich in vitamin C&lt;/item&gt;<br />
&lt;item name="Papaya" moreinfo="http://www.papaya.com"&gt;Papaya - Hot when raw, cold when ripe&lt;/item&gt;<br />
&lt;/fruits&gt; </code></div>
<p><code>&lt;vegetables&gt;<br />
&lt;item name="spinach" moreinfo="http://www.spinach.com"&gt;Spinach is full of iron&lt;/item&gt;<br />
&lt;item name="asparagus" moreinfo="http://www.asparagus.com"&gt;Asparagus contains loads of vitamin D &lt;/item&gt;<br />
&lt;item name="fenugreek" moreinfo="http://www.fenugreek.com"&gt;Fenugreek is rich in vitamin C&lt;/item&gt;<br />
&lt;/vegetables&gt;<br />
&lt;/food&gt;</p>
<p></code></p></blockquote>
<hr />
<strong>FOOD.XSL</strong></p>
<blockquote>
<div><code><br />
&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;<br />
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;<br />
&lt;xsl:include href="inc_fruits.xsl" /&gt;<br />
&lt;xsl:include href="inc_vegetables.xsl" /&gt;<br />
&lt;xsl:template match="/"&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Title&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;h3&gt;&lt;xsl:value-of select="/food/description" /&gt;&lt;/h3&gt;<br />
Modification Date : &lt;xsl:value-of select="/food/date" /&gt;<br />
&lt;hr/&gt;<br />
&lt;h5&gt; About Fruits&lt;/h5&gt;<br />
&lt;xsl:call-template name="about_fruits"/&gt;</code></div>
<p><code>&lt;hr/&gt;<br />
&lt;h5&gt; About Vegetables&lt;/h5&gt;<br />
&lt;xsl:call-template name="about_vegetables"/&gt;</p>
<p>&lt;hr/&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
&lt;/xsl:template&gt;<br />
&lt;/xsl:stylesheet&gt;</p>
<p> </p>
<p></code></p></blockquote>
<hr />
<strong>INC_FRUITS.XSL</strong></p>
<blockquote><p><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;<br />
&lt;xsl:output method="html" encoding="iso-8859-1" /&gt;<br />
&lt;xsl:template name="about_fruits"&gt;<br />
&lt;xsl:for-each select="/food/fruits/item/@*"&gt;<br />
attribute name : &lt;xsl:value-of select="name()"/&gt; <br />
attribute value : &lt;xsl:value-of select="."/&gt; &lt;br /&gt;<br />
&lt;/xsl:for-each&gt;<br />
&lt;/xsl:template&gt;<br />
&lt;/xsl:stylesheet&gt;</code></p></blockquote>
<hr />
<strong>INC_VEGETABLES.XSL</strong></p>
<blockquote><p><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;<br />
&lt;xsl:output method="html" encoding="iso-8859-1" /&gt;<br />
&lt;xsl:template name="about_vegetables"&gt;<br />
&lt;xsl:for-each select="/food/vegetables/item/@*"&gt;<br />
attribute name : &lt;xsl:value-of select="name()"/&gt; <br />
attribute value : &lt;xsl:value-of select="."/&gt; &lt;br/&gt;<br />
&lt;/xsl:for-each&gt;<br />
&lt;/xsl:template&gt;<br />
&lt;/xsl:stylesheet&gt;</code></p></blockquote>
<p><strong><a title="download" href="http://developer.expressionz.in/blogs/wp-content/plugins/download-monitor/download.php?id=5" target="_blank">Download all the above files here (88 downloads)</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://developer.expressionz.in/blogs/2008/05/04/include-xsl-inside-xsl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
