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

<channel>
	<title>Coding Obsession</title>
	<atom:link href="http://techblog.julianhidalgo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.julianhidalgo.com</link>
	<description></description>
	<pubDate>Sat, 18 Oct 2008 03:21:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Gallio and MbUnit v3.04</title>
		<link>http://techblog.julianhidalgo.com/2008/10/17/gallio-and-mbunit-v304/</link>
		<comments>http://techblog.julianhidalgo.com/2008/10/17/gallio-and-mbunit-v304/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 09:20:55 +0000</pubDate>
		<dc:creator>Julián Hidalgo</dc:creator>
		
		<category><![CDATA[Gallio]]></category>

		<category><![CDATA[Gallio Book]]></category>

		<category><![CDATA[MbUnit]]></category>

		<guid isPermaLink="false">http://techblog.julianhidalgo.com/2008/10/17/gallio-and-mbunit-v304/</guid>
		<description><![CDATA[Today Jeff Brown announced the release of Gallio and MbUnit v3.04. Many thanks and congratulations to him and all the people that contributed to this release: Vadim Kreynin, Yann Trévin, Graham Hay, and Francois Retief.
I was really impressed by the amount and quality of the new features. Some of the most noteworthy ones in my [...]]]></description>
			<content:encoded><![CDATA[<p>Today <a title="Jeff Brown - Announcing Gallio and MbUnit v3.0.4" href="http://blog.bits-in-motion.com/2008/10/announcing-gallio-and-mbunit-v304.html">Jeff Brown announced the release of Gallio and MbUnit v3.04</a>. Many thanks and congratulations to him and all the people that contributed to this release: <a href="http://vkreynin.wordpress.com/">Vadim Kreynin</a>, <a href="http://www.interfacingreality.blogspot.com/">Yann Trévin</a>, Graham Hay, and Francois Retief.</p>
<p>I was really impressed by the amount and quality of the new features. Some of the most noteworthy ones in my opinion are the AssertEx.That syntax, the Gallio.Ambience object store, and the highlighting of differences in assertions.</p>
<p>I&#8217;ve been away from Gallio and MbUnit the last couple of months for a number of personal reasons, but I&#8217;m quite glad to see that we&#8217;ve got new people contributing with their time and skills, and once more I&#8217;m amazed by Jeff&#8217;s energy to keep working so hard on all this stuff.</p>
<p>Oh, and before I forget it, <a href="http://www.gallio.org/Docs.aspx">the Gallio Book is now online</a>. I wrote the <a href="http://www.gallio.org/book/XHtml/ch03.html">getting started chapter</a> (right now the code listings don&#8217;t look good, but I hope we can fix that soon) and <a href="http://techblog.julianhidalgo.com/category/gallio-book/">helped a little more</a>, but it was Jeff who got the publishing done at the end. There&#8217;s not too much content so far, so people are really welcome to contribute.</p>
<p><a href="http://www.gallio.org/Downloads.aspx">Download Gallio/MbUnit 3.04</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.julianhidalgo.com/2008/10/17/gallio-and-mbunit-v304/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Silverlight 2 Released!</title>
		<link>http://techblog.julianhidalgo.com/2008/10/14/silverlight-2-released/</link>
		<comments>http://techblog.julianhidalgo.com/2008/10/14/silverlight-2-released/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 12:51:28 +0000</pubDate>
		<dc:creator>Julián Hidalgo</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://techblog.julianhidalgo.com/2008/10/14/silverlight-2-released/</guid>
		<description><![CDATA[I don&#8217;t like blog posts that just link to other posts, but I really needed to start blogging again (I&#8217;ve only being maintaining my personal non-tech blog in the last couple of months), and today I have a really good excuse to do it: Silverlight 2 was released! Tim Heuer wrote a very detailed post [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t like blog posts that just link to other posts, but I really needed to start blogging again (I&#8217;ve only being maintaining my personal non-tech blog in the last couple of months), and today I have a really good excuse to do it: Silverlight 2 was released! Tim Heuer wrote <a title="Tim Heuer - Silverlight 2 Released: New controls, tools, announcements!" href="http://timheuer.com/blog/archive/2008/10/14/silverlight-2-released-officially.aspx">a very detailed post with <strong><em>all</em></strong> the details about this release</a> (a must read), and of course ScottGu <a title="ScottGu - Silverlight 2 Released" href="http://weblogs.asp.net/scottgu/archive/2008/10/14/silverlight-2-released.aspx">also blogged about it</a>.</p>
<p>During the week I&#8217;ll try to update a little application (a log viewer) I wrote with the beta 2 and see how it works. I&#8217;m particularly interested in seeing the new controls and the improvements on the old ones. But anyway, I have to get back to work now!</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.julianhidalgo.com/2008/10/14/silverlight-2-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Gallio Book Screenshot</title>
		<link>http://techblog.julianhidalgo.com/2008/05/27/new-gallio-book-screenshot/</link>
		<comments>http://techblog.julianhidalgo.com/2008/05/27/new-gallio-book-screenshot/#comments</comments>
		<pubDate>Tue, 27 May 2008 10:50:20 +0000</pubDate>
		<dc:creator>Julián Hidalgo</dc:creator>
		
		<category><![CDATA[Gallio]]></category>

		<category><![CDATA[Gallio Book]]></category>

		<guid isPermaLink="false">http://techblog.julianhidalgo.com/2008/05/27/new-gallio-book-screenshot/</guid>
		<description><![CDATA[The output is now valid XHTML markup. I also improved the design and added a little more content. Actually I borrowed most of the design elements from the Django Book, which we are using as an example and source of inspiration.

I wrote a &#8220;Why This Book?&#8221; section, and to my surprise it was a lot [...]]]></description>
			<content:encoded><![CDATA[<p>The output is now <em>valid</em> XHTML markup. I also improved the design and added a little more content. Actually I borrowed most of the design elements from <a href="http://www.djangobook.com/en/1.0/">the Django Book</a>, which we are using as an example and source of inspiration.</p>
<p><a href="http://techblog.julianhidalgo.com/wp-content/uploads/2008/05/galliobook.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://techblog.julianhidalgo.com/wp-content/uploads/2008/05/galliobook-thumb.png" border="0" alt="GallioBook" width="240" height="173" /></a></p>
<p>I wrote a &#8220;Why This Book?&#8221; section, and to my surprise it was a lot harder than the technical content. I&#8217;m still not glad with it, but for now I&#8217;ll focus on the things that people really read and care about :)</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.julianhidalgo.com/2008/05/27/new-gallio-book-screenshot/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Gallio Book in HTML format</title>
		<link>http://techblog.julianhidalgo.com/2008/05/25/the-gallio-book-in-html-format/</link>
		<comments>http://techblog.julianhidalgo.com/2008/05/25/the-gallio-book-in-html-format/#comments</comments>
		<pubDate>Sun, 25 May 2008 10:11:48 +0000</pubDate>
		<dc:creator>Julián Hidalgo</dc:creator>
		
		<category><![CDATA[Gallio]]></category>

		<category><![CDATA[Gallio Book]]></category>

		<guid isPermaLink="false">http://techblog.julianhidalgo.com/2008/05/25/the-gallio-book-in-html-format/</guid>
		<description><![CDATA[Tonight I finally got the HTML publishing for the Gallio book working with (basic for now) syntax highlighting and using the same layout of the web site. Here&#8217;s a screenshot:

I hope to put it on the web site during this week and to start working on other kind of output formats too. It&#8217;s quite satisfying [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight I finally got the HTML publishing for the Gallio book working with (basic for now) syntax highlighting and using the same layout of the web site. Here&#8217;s a screenshot:</p>
<p><a href="http://techblog.julianhidalgo.com/wp-content/uploads/2008/05/book.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://techblog.julianhidalgo.com/wp-content/uploads/2008/05/book-thumb.png" border="0" alt="Book" width="240" height="188" /></a></p>
<p>I hope to put it on the web site during this week and to start working on other kind of output formats too. It&#8217;s quite satisfying to see this project becoming a reality :)</p>
<p>In <a href="http://techblog.julianhidalgo.com/2008/05/17/transforming-docbook-to-html-in-net/">my previous post</a> I said I was going to transform the source XML files using .NET, but it was getting too time consuming, so at the end I used the Java flavor of the <a href="http://saxon.sourceforge.net/">Saxon XSLT processor</a>. As usual, it was harder than I thought at first because of all the little details that must be taken care of, so I will blog about the process soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.julianhidalgo.com/2008/05/25/the-gallio-book-in-html-format/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Transforming DocBook to HTML in .NET</title>
		<link>http://techblog.julianhidalgo.com/2008/05/17/transforming-docbook-to-html-in-net/</link>
		<comments>http://techblog.julianhidalgo.com/2008/05/17/transforming-docbook-to-html-in-net/#comments</comments>
		<pubDate>Sat, 17 May 2008 09:49:22 +0000</pubDate>
		<dc:creator>Julián Hidalgo</dc:creator>
		
		<category><![CDATA[DocBook]]></category>

		<category><![CDATA[Gallio]]></category>

		<guid isPermaLink="false">http://techblog.julianhidalgo.com/?p=10</guid>
		<description><![CDATA[One of the things I&#8217;m currently involved in is writing a book about Gallio. We chose DocBook as the format, even though XML sucks, because it&#8217;s a mature technology with lots of documentation and strong tool support, and because we need to render the book in multiple output forms (HTML, PDF and so on).
This week [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things I&#8217;m currently involved in is writing a book about Gallio. We chose DocBook as the format, even though <a href="http://xmlsucks.org/but_you_have_to_use_it_anyway/does-xml-suck.html">XML sucks</a>, because it&#8217;s a mature technology with lots of documentation and strong tool support, and because we need to render the book in multiple output forms (HTML, PDF and so on).</p>
<p>This week I started to research how to convert what we have so far to HTML, so we can upload it to the web site. Since DocBook is XML-based it&#8217;s not surprising that the simplest way to do it is by using XSL stylesheets.<em> </em>A free set of them is available at the project&#8217;s web site and there is even a <a href="http://www.sagehill.net/docbookxsl/">full book devoted to them</a>.</p>
<p>To make things as smooth as possible I decided I&#8217;d do the processing in .NET, but it was not as easy as I was thought it would be, so I decided to blog about it in case anyone else needs a quick start.</p>
<p>Let me start by showing you the sample book we&#8217;ll be transforming:</p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<p style="margin: 0px"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml</span><span style="color: blue"> </span><span style="color: red">version</span><span style="color: blue">=</span>&#8220;<span style="color: blue">1.0</span>&#8220;<span style="color: blue"> </span><span style="color: red">encoding</span><span style="color: blue">=</span>&#8220;<span style="color: blue">UTF-8</span>&#8220;<span style="color: blue">?&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">book</span><span style="color: blue"> </span><span style="color: red">version</span><span style="color: blue">=</span>&#8220;<span style="color: blue">5.0</span>&#8220;</p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: red">xmlns</span><span style="color: blue">=</span>&#8220;<span style="color: blue">http://docbook.org/ns/docbook</span>&#8220;</p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: red">xmlns:xi</span><span style="color: blue">=</span>&#8220;<span style="color: blue">http://www.w3.org/2001/XInclude</span>&#8220;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&nbsp; &lt;</span><span style="color: #a31515">title</span><span style="color: blue">&gt;</span>My Book<span style="color: blue">&lt;/</span><span style="color: #a31515">title</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&nbsp; &lt;</span><span style="color: #a31515">xi:include</span><span style="color: blue"> </span><span style="color: red">href</span><span style="color: blue">=</span>&#8220;<span style="color: blue">Chapter1.xml</span>&#8220;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&nbsp; &lt;</span><span style="color: #a31515">xi:include</span><span style="color: blue"> </span><span style="color: red">href</span><span style="color: blue">=</span>&#8220;<span style="color: blue">Chapter2.xml</span>&#8220;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">book</span><span style="color: blue">&gt;</span></p>
</div>
</div>
</div>
<p>It&#8217;s pretty basic, we only have a title and two chapters. Notice that I&#8217;m using XInclude instead of entities to include the chapters. In case you are interested, the book &#8220;<a href="http://www.docbook.org/">DocBook: The Definitive Guide</a>&#8221; includes a list of the tradeoffs involved in choosing either approach. To be honest I don&#8217;t find any compelling reason to prefer XInclude (it was <a href="http://blog.bits-in-motion.com/">Jeff</a> who persuaded me!), but I&#8217;ll leave that discussion for another post. Here&#8217;s the XML markup for Chapter 1:</p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<p style="margin: 0px"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml</span><span style="color: blue"> </span><span style="color: red">version</span><span style="color: blue">=</span>&#8220;<span style="color: blue">1.0</span>&#8220;<span style="color: blue"> </span><span style="color: red">encoding</span><span style="color: blue">=</span>&#8220;<span style="color: blue">UTF-8</span>&#8220;<span style="color: blue">?&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">chapter</span><span style="color: blue"> </span><span style="color: red">version</span><span style="color: blue">=</span>&#8220;<span style="color: blue">5.0</span>&#8220;<span style="color: blue"> </span><span style="color: red">xmlns</span><span style="color: blue">=</span>&#8220;<span style="color: blue">http://docbook.org/ns/docbook</span>&#8220;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&nbsp; &lt;</span><span style="color: #a31515">title</span><span style="color: blue">&gt;</span>Chapter 1&#8217;s Title<span style="color: blue">&lt;/</span><span style="color: #a31515">title</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&nbsp; &lt;</span><span style="color: #a31515">section</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">title</span><span style="color: blue">&gt;</span>A section<span style="color: blue">&lt;/</span><span style="color: #a31515">title</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">para</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lorem ipsum dolor sit amet consectetuer adipiscing.</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [More random text]</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Suspendisse potenti. Etiam hendrerit cursus eros.</p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">para</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&nbsp; &lt;/</span><span style="color: #a31515">section</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">chapter</span><span style="color: blue">&gt;</span></p>
</div>
<p>Chapter 2 is the same thing. In the real Gallio book we also have things like code listings and images. I still don&#8217;t know how to format the code listings (that will be the subject of a future post), but images just work without doing anything special. </p>
<p>Before I show any code you&#8217;ll want to download the DocBook XSL stylesheets from the <a href="http://sourceforge.net/project/showfiles.php?group_id=21935#files">SourceForge project</a>. Make sure you pick the DocBook XSL-NS stylesheets (the docbook-xsl-ns-xxx package) or you&#8217;ll get a warning when using them (&#8221;WARNING: cannot add @xml:base to node set root element. Relative paths may not work&#8221;). They are the <a href="http://www.docbook.org/docs/howto/#dbxsl-ns">recommended DocBook V.50 stylesheets</a> anyway. When you decompress the package you&#8217;ll see a bunch of folders and files - don&#8217;t panic, we only need to mess with one of them.</p>
<p>Now we are ready to start. We&#8217;ll use the <strong>XslCompiledTransform</strong> class (which is .NET&#8217;s XSLT processor) to load and transform our DocBook file. There are two steps involved: loading the stylesheet and applying it to the XML file.</p>
<h5>1. Loading the Style Sheet</h5>
<p>We want the book in HTML format, so we have to use the &#8216;docbook.xsl&#8217; stylesheet (located in the html folder), which generates a single HTML output file. There&#8217;s also another potentially useful one called &#8216;chunk.xsl&#8217; that generates multiple linked files, which is best suited for a book, but when I tried it I got an error that seemed to be the stylesheet&#8217;s fault (something like <em>&#8220;an &#8216;xsl:apply-imports&#8217; element can only appear within a &#8216;xsl:template&#8217; element&#8221;),</em> so we&#8217;ll stick to the single output file for now :)</p>
<p>This is the code to load the stylesheet:</p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 1</span>&nbsp;<span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">void</span> LoadXsl(<span style="color: #2b91af">XslCompiledTransform</span> transform)</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 2</span> {</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 3</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">XmlReaderSettings</span> settings = <span style="color: blue">new</span> <span style="color: #2b91af">XmlReaderSettings</span>();</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 4</span>&nbsp;&nbsp;&nbsp;&nbsp; settings.ProhibitDtd = <span style="color: blue">false</span>;&nbsp;&nbsp;&nbsp; </p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 5</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> (<span style="color: #2b91af">XmlReader</span> reader = <span style="color: #2b91af">XmlReader</span>.Create(</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 6</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #a31515">@&#8221;docbook-xsl-ns-1.73.2\html\docbook.xsl&#8221;</span>,</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 7</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; settings))</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 8</span>&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 9</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">XsltSettings</span> xsltSettings = <span style="color: blue">new</span> <span style="color: #2b91af">XsltSettings</span>();</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp; 10</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xsltSettings.EnableDocumentFunction = <span style="color: blue">true</span>;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp; 11</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transform.Load(reader, xsltSettings, <span style="color: blue">new</span> <span style="color: #2b91af">XmlUrlResolver</span>());</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp; 12</span>&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp; 13</span> }</p>
</div>
<p style="margin: 0px">
</div>
<p>We are basically creating a <strong>XmlReader</strong> object pointed to the stylesheet we want to use and passing it to the Load method of a <strong>XslCompiledTransform</strong> instance. This is pretty straightforward, but we need to set a couple of options to make it work:</p>
<ul>
<li>By default DTD processing is prohibited, so we&#8217;ll get an <strong>XmlException</strong> when loading the stylesheet. To fix this we set the ProhibitDtd property to false in line 4.
<li>The document() function is disabled by default. This is used by the stylesheets, so we need to enable it or we&#8217;ll get yet another exception. This is done in lines 9-10 where we create a new <strong>XsltSettings</strong> object and set its EnableDocumentFunction property to true. </li>
</ul>
<h5>2. Applying the Transform</h5>
<p>This is the code required to apply the stylesheet:</p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 1</span>&nbsp;<span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">void</span> Transform(<span style="color: #2b91af">XslCompiledTransform</span> transform)</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 2</span> {&nbsp;&nbsp; </p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 3</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">XmlWriterSettings</span> writerSettings = <span style="color: blue">new</span> <span style="color: #2b91af">XmlWriterSettings</span>();</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 4</span>&nbsp;&nbsp;&nbsp;&nbsp; writerSettings.ConformanceLevel = <span style="color: #2b91af">ConformanceLevel</span>.Auto;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 5</span>&nbsp;</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 6</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> (<span style="color: #2b91af">XmlWriter</span> writer = <span style="color: #2b91af">XmlWriter</span>.Create(<span style="color: #a31515">@&#8221;book.html&#8221;</span>, writerSettings))</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 7</span>&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 8</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">XsltArgumentList</span> arguments = <span style="color: blue">new</span> <span style="color: #2b91af">XsltArgumentList</span>();</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp;&nbsp; 9</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arguments.AddParam(<span style="color: #a31515">&#8220;html.stylesheet&#8221;</span>, <span style="color: #2b91af">String</span>.Empty, <span style="color: #a31515">&#8220;styles.css&#8221;</span>);</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp; 10</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transform.Transform(CreateReader2(), arguments, writer);</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp; 11</span>&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px"><span style="color: #2b91af">&nbsp;&nbsp; 12</span> }</p>
</div>
<p style="margin: 0px">
</div>
<p>Again, a couple of points to notice:</p>
<ul>
<li>In line 4 we set the conformance level to ConformanceLevel.Auto through a <strong>XmlWriterSettings</strong> instance. For some reason if you don&#8217;t do this an <strong>InvalidOperationException</strong> is thrown complaining about the validity of the output file, even though the HTML file looks fine.
<li>We can give parameters to the stylesheet. In this case, in line 9 I&#8217;m defining the name of the CSS stylesheet to use (this will generate a link tag in the output file).</li>
</ul>
<p>In case you are wondering, the CreateReader method looks like this:</p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<p style="margin: 0px"><span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: #2b91af">XmlReader</span> CreateReader()</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">XmlReaderSettings</span> readerSettings = <span style="color: blue">new</span> <span style="color: #2b91af">XmlReaderSettings</span>();</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; readerSettings.ProhibitDtd = <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">return</span> <span style="color: #2b91af">XmlReader</span>.Create(bookPath, readerSettings);</p>
<p style="margin: 0px">}</p>
</div>
<p>We are just creating a <strong>XmlReader</strong> pointed to the book file and with the ProhibitDtd set to false as we did for the stylesheet.</p>
<p>We run the code and see the following output (after manually opening the resulting file of course):</p>
<p><a href="http://techblog.julianhidalgo.com/wp-content/uploads/2008/05/rendered-book-1st-try.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="186" alt="rendered-book-1st-try" src="http://techblog.julianhidalgo.com/wp-content/uploads/2008/05/rendered-book-1st-try-thumb.jpg" width="244" border="0"></a> </p>
<p>As you see the title is OK, but the chapters are not included. The following warning give us a clue:</p>
<blockquote><p><strong>Element include in namespace &#8216;</strong><a href="http://www.w3.org/2001/XInclude'"><strong>http://www.w3.org/2001/XInclude&#8217;</strong></a><strong> encountered in book, but no template matches.</strong></p>
</blockquote>
<p>It turns out <strong>XslCompiledTransform</strong> doesn&#8217;t support XInclude. Luckily there&#8217;s a project called <a href="http://www.codeplex.com/MVPXML/">Mvp.Xml</a> that provides this functionality through a class called <strong>XIncludingReader</strong>. If you read <a href="http://www.codeplex.com/MVPXML/Wiki/View.aspx?title=XInclude.NET&amp;referringTitle=Home">the documentation in their wiki</a> it looks as it&#8217;s only a matter of returning a <strong>XIncludingReader</strong> instance from the CreateReader method to make everything work, but it&#8217;s not. For some reason, a <strong>XmlException</strong> is thrown complaining about the DTD processing prohibition again (don&#8217;t you start to hate that little feature?). The solution is to subclass <strong>XIncludingReader</strong> and override its Settings property, making sure the returned object has the ProhibitDtd property set to false. None of the constructors in the <strong>XIncludingReader</strong> class accepts a <strong>XmlReaderSettings</strong> object, so it&#8217;s the only way.</p>
<p>This is the new class:</p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<p style="margin: 0px"><span style="color: blue">class</span> <span style="color: #2b91af">XIncludeEnabledReader</span> : <span style="color: #2b91af">XIncludingReader</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">XmlReaderSettings</span> settings = <span style="color: blue">new</span> <span style="color: #2b91af">XmlReaderSettings</span>();</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> XIncludeEnabledReader(<span style="color: blue">string</span> path)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <span style="color: blue">base</span>(path)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; settings.ProhibitDtd = <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: #2b91af">XmlReaderSettings</span> Settings</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">get</span> { <span style="color: blue">return</span> settings; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">}</p>
</div>
<p>With the new code everything works as expected:</p>
<p><a href="http://techblog.julianhidalgo.com/wp-content/uploads/2008/05/rendered-book-2nd-try.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="rendered-book-2nd-try" src="http://techblog.julianhidalgo.com/wp-content/uploads/2008/05/rendered-book-2nd-try-thumb.jpg" width="165" border="0"></a> </p>
<p>It took me a while to figure the subclassing thing out, because internally the <strong>XIncludingReader</strong> class uses a normal XmlReader where the DTD prohibition is disabled. I don&#8217;t know how the <strong>XslCompiledTransform</strong> class interacts with the reader it receives, but it (or some other class) must be looking at this property at some point because otherwise the exception wouldn&#8217;t be thrown. I was about to start debugging into the Framework&#8217;s source to see what was going on when I thought of subclassing. The clue was discovering that XIncludingReader.Settings was always null. Seeing now all the effort it took, I wish I&#8217;d used entities from the beginning, but anyway.</p>
<p>So, that&#8217;s all. I&#8217;ve uploaded <a href="http://julianhidalgo.com/files/DocBookSample.zip">a zip file with the sample code</a>. Please make sure you fix the path in line 48 of Program.cs before running it.</p>
<p>Hope it helps :)</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.julianhidalgo.com/2008/05/17/transforming-docbook-to-html-in-net/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gallio Archimedes</title>
		<link>http://techblog.julianhidalgo.com/2008/05/03/gallio-archimedes/</link>
		<comments>http://techblog.julianhidalgo.com/2008/05/03/gallio-archimedes/#comments</comments>
		<pubDate>Sat, 03 May 2008 17:11:00 +0000</pubDate>
		<dc:creator>Julián Hidalgo</dc:creator>
		
		<category><![CDATA[Archimedes]]></category>

		<category><![CDATA[Gallio]]></category>

		<guid isPermaLink="false">http://techblog.julianhidalgo.com/?p=5</guid>
		<description><![CDATA[I&#8217;ve been part of the Gallio project since my friend Jeff Brown started it last year. In case you don&#8217;t know it, Gallio is an open source Automation Platform that emerged from the MbUnit test framework. I encourage you to go ahead and find out more about it.
One of the cool things about Gallio is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been part of the Gallio project since my friend Jeff Brown started it last year. In case you don&#8217;t know it, Gallio is an open source Automation Platform that emerged from the MbUnit test framework. I encourage you to go ahead and find out more about it.</p>
<p>One of the cool things about Gallio is that it opens the door for creating some powerful tools on top of it (hint: even commercial tools ;)). A few weeks ago Jeff blogged about one of such potential tools, an integration test management platform called &#8220;Archimedes&#8221; and composed in principle by the following components:</p>
<ul>
<li>A distributed test runner.</li>
<li>A web-based management console.</li>
<li>A repository for historical test data.</li>
<li>A deployment engine.</li>
<li>A scheduler.</li>
<li>A notification service.</li>
<li>A reporting, trending and statistics module.</li>
<li>A data feed and web service for mash ups.</li>
<li>Documentation.</li>
</ul>
<p>Since Jeff is pretty busy right now he asked me to start and lead the project, and I accepted immediately (although I must admit I was a little afraid to). I think this is an exciting opportunity, but also a big responsibility. In my opinion, one of the biggest challenges in software development today is to make testing <strong>easy</strong> and <strong>cheap</strong>, there&#8217;s lot of room for improvement and we are not near to have a tools ecosystem as rich as we have for coding for example. I think the reason is that testing is a <strong>hard</strong> problem.</p>
<p>You can see in the component list that this is not going to be a trivial effort, but fortunately so far it looks I will get help from some smart people. My intention is to divide the project in small achievable milestones - better to have a few completed features than a lot of unfinished ones. We will see how it goes.</p>
<p>If this sounds interesting I invite you to come and join. For now the best place to show up is the Gallio dev list, but we will probably have a dedicated list soon.</p>
<p>Happy testing!</p>
<hr />Links for this post:</p>
<ul>
<li><a href="http://www.gallio.org/">The Gallio Project</a></li>
<li><a href="http://groups.google.com/group/gallio-dev?lnk=li">The Gallio dev list</a></li>
<li><a href="http://blog.bits-in-motion.com/">Jeff Brown&#8217;s blog</a> (recommended reading!)</li>
<li><a href="http://blog.bits-in-motion.com/2008/04/gallio-archimedes.html">Jeff Brown&#8217;s post about Archimedes</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://techblog.julianhidalgo.com/2008/05/03/gallio-archimedes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reborn from the ashes</title>
		<link>http://techblog.julianhidalgo.com/2008/05/03/reborn-from-the-ashes/</link>
		<comments>http://techblog.julianhidalgo.com/2008/05/03/reborn-from-the-ashes/#comments</comments>
		<pubDate>Sat, 03 May 2008 09:01:00 +0000</pubDate>
		<dc:creator>Julián Hidalgo</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://techblog.julianhidalgo.com/?p=4</guid>
		<description><![CDATA[Hello Everybody
I used to have a tech blog at http://www.hpoffice.cl/julian/, but unfortunately the server died and I could not recover the backup. It&#8217;s a pity because I had a bunch of posts already, but anyway, I guess I have to think of this as an opportunity for doing things better. I don&#8217;t like to do [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Everybody</p>
<p>I used to have a tech blog at <a title="http://www.hpoffice.cl/julian/" href="http://www.hpoffice.cl/julian/">http://www.hpoffice.cl/julian/</a>, but unfortunately the server died and I could not recover the backup. It&#8217;s a pity because I had a bunch of posts already, but anyway, I guess I have to think of this as an opportunity for doing things better. I don&#8217;t like to do things twice, so it took me a while deciding to start blogging again.</p>
<p>In case you are interested, my name is Juli&#225;n Hidalgo and I&#8217;m from Chile, South America (that&#8217;s why my English is so bad). I&#8217;m a .NET developer and I&#8217;m part of the MbUnit and Gallio projects, so I&#8217;ll be blogging mostly about .NET, general software development and those projects.</p>
<p>I&#8217;m planning to be posting new content at least every two weeks, so stay tuned.</p>
<p>I guess that is. Thanks for reading and see you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.julianhidalgo.com/2008/05/03/reborn-from-the-ashes/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
