<?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>Simone Carletti&#039;s Blog &#187; xinclude</title>
	<atom:link href="http://www.simonecarletti.com/blog/tags/xinclude/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simonecarletti.com/blog</link>
	<description>Simone Carletti&#039;s personal ramblings on programming, syndication, search engines &#38; marketing.</description>
	<lastBuildDate>Tue, 07 Feb 2012 08:48:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using XInclude to include example code in a DocBook file</title>
		<link>http://www.simonecarletti.com/blog/2009/01/using-xinclude-to-include-example-code-in-a-docbook-file/</link>
		<comments>http://www.simonecarletti.com/blog/2009/01/using-xinclude-to-include-example-code-in-a-docbook-file/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 07:31:34 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[docbook]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[xinclude]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=125</guid>
		<description><![CDATA[How to include an example code in a DocBook article with XInclude.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-126" title="DocBook thumb" src="http://www.simonecarletti.com/blog/wp-content/uploads/2009/01/docbook-thumb.gif" alt="DocBook thumb" width="96" height="120" />I love <a href="http://www.docbook.org/">DocBook</a>! Any article, guide and resource I write for <a href="http://www.html.it/">HTML.it</a> or any other publisher is first created as a DocBook file and stored in a Version Control System, usually <a href="http://subversion.tigris.org/">Subversion</a> or <a href="http://git-scm.com/">GIT</a>.</p>
<p>Yesterday I was writing a technical article about <a href="http://as.rubyonrails.com/">ActiveSupport</a>. Easy to understand, the article was <strong>full of Ruby examples</strong> and it was somehow the first time I had to include so many working examples in a single article. I started to collect them in a single folder organized by sections. The scripts needs to be executed and tested before being included into the article and TextMate is definitely more confortable than Oxygen for writing a Ruby script!</p>
<p>After a couple of minutes I realized that probably there was a better solution to include those files directly in the main article and I started looking at it. I just felt an idiot when I realized I could use <strong>XInclude</strong> in the same way I usually include different chapters in a DocBook book.</p>
<p><span id="more-125"></span>Here&#8217;s the solution. To <strong>include an example code in your article</strong> first <strong>import the XInclude module</strong> in your DocBook file declaration, if you didn&#8217;t before.</p>
<div class="codecolorer-container text default brush: xml;" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;article<br />
&nbsp; xmlns=&quot;http://docbook.org/ns/docbook&quot;<br />
&nbsp; xmlns:xi=&quot;http://www.w3.org/2001/XInclude&quot;<br />
&nbsp; version=&quot;5.0&quot;&gt;</div></td></tr></tbody></table></div>
<p>Then include the code as plain text with the <code>&lt;xi:include&gt;</code> tag. The following example includes the Ruby script stored in <code>example.rb</code>.</p>
<div class="codecolorer-container text default brush: xml;" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;programlisting language=&quot;ruby&quot;&gt;&lt;xi:include href=&quot;example.rb&quot; parse=&quot;text&quot; /&gt;&lt;/programlisting&gt;</div></td></tr></tbody></table></div>
<p>I usually wrap the script in a <a href="http://docbook.org/tdg/en/html/programlisting.html"><code>&lt;programlisting&gt;</code></a> tag. For more complex examples you might want to use an <a href="http://docbook.org/tdg/en/html/example.html"><code>&lt;example&gt;</code></a> tag. Be sure to set the attribute parse to text or the processor will try to parse the content as an XML file.</p>
<p>For more details about the XInclude I suggest the <a href="http://www.xml.com/pub/a/2002/07/31/xinclude.html">Using XInclude</a> article published by O&#8217;Reilly.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/09/capistrano-file-transfer-actions/' rel='bookmark' title='Capistrano: File Transfer actions'>Capistrano: File Transfer actions</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/09/inside-ruby-on-rails-reading-source-code/' rel='bookmark' title='Understanding Ruby and Rails: Reading Source Code'>Understanding Ruby and Rails: Reading Source Code</a></li>
<li><a href='http://www.simonecarletti.com/blog/2010/06/public-suffix-list-library-for-ruby/' rel='bookmark' title='Introducing the Public Suffix List library for Ruby'>Introducing the Public Suffix List library for Ruby</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2009/01/using-xinclude-to-include-example-code-in-a-docbook-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

