<?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>out &#62;&#62; m_Conscientia;</title>
	<atom:link href="http://blog.hypercomplex.co.uk/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hypercomplex.co.uk</link>
	<description>a multidimensional braindump</description>
	<lastBuildDate>Mon, 02 Aug 2010 22:30:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Touchable Holograms</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/07/touchable-holograms/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/07/touchable-holograms/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 22:22:20 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hologram]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=1181</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object width="450" height="370"><param name="movie" value="http://www.liveleak.com/e/8c8_1279519465"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.liveleak.com/e/8c8_1279519465" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="450" height="370"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/07/touchable-holograms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Administrative Shares in Windows 7</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/06/administrative-shares-in-windows-7/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/06/administrative-shares-in-windows-7/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 21:18:23 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[administrative share]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=946</guid>
		<description><![CDATA[Perhaps this is old news for seasoned Win7 users, but today I was totally baffled when trying to copy some files via an administrative share. In Windows 7, by default, you will get an access denied message. First disable Homegroup. Apart from anything else, the passkey it generates doesn&#8217;t look very secure to me. Perhaps [...]]]></description>
			<content:encoded><![CDATA[<p>Perhaps this is old news for seasoned Win7 users, but today I was totally baffled when trying to copy some files via an administrative share. In Windows 7, by default, you will get an access denied message.</p>
<p>First disable <a href="http://windows.microsoft.com/en-us/windows7/products/features/homegroup">Homegroup</a>. Apart from anything else, the passkey it generates doesn&#8217;t look very secure to me. Perhaps it&#8217;s useful if you have no idea how to set up file sharing. If you have no idea, you probably don&#8217;t want to use administrative shares.</p>
<p>Second, enable File and Printer Sharing. Aside: I previously wasted literally minutes of my life when I found Vista doesn&#8217;t respond to ping when this is disabled.</p>
<ul>
<li>Open <strong>Network and Sharing Center</strong>, click on <strong>Change advanced sharing settings</strong>.</li>
<li>Open your current profile (e.g Home or Work)</li>
<li>Under <strong>File and Printer sharing</strong>, ensure <strong>Turn on file and printer sharing</strong> is selected.</li>
</ul>
<p>Third, edit the registry. This is largely for my own reference: I know for a fact that I would never be able to remember the required registry key.</p>
<ul>
<li>Navigate to <strong>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System</strong></li>
<li>Add a new DWORD key called <strong>LocalAccountTokenFilterPolicy</strong></li>
<li>Set the new key to a value of 1</li>
</ul>
<p>This registry key is effective immediately, no need to restart.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/06/administrative-shares-in-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSD Compiler Benchmark</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/06/ssd-compiler-benchmark/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/06/ssd-compiler-benchmark/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 16:49:55 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[OCZ Vertex 2]]></category>
		<category><![CDATA[Raptor]]></category>
		<category><![CDATA[SSD]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=916</guid>
		<description><![CDATA[Anandtech has some good articles illustrating the type of performance gains you might expect using an SSD disk for everyday tasks. Using Visual Studio, and in particular, compilation, are not considered. I did a cursory inspection of the rest of the Internet, and found no decent benchmarks investigating the impact of SSDs on compile time. [...]]]></description>
			<content:encoded><![CDATA[<p>Anandtech has some good <a href="http://www.anandtech.com/show/2738">articles</a> illustrating the type of performance gains you might expect using an SSD disk for everyday tasks. Using Visual Studio, and in particular, compilation, are not considered. I did a cursory inspection of the rest of the Internet, and found no decent benchmarks investigating the impact of SSDs on compile time. So, I decided to perform my own. It&#8217;s well known that a lot of the operations performed by Visual Studio are <a href="http://weblogs.asp.net/scottgu/archive/2007/11/01/tip-trick-hard-drive-speed-and-visual-studio-performance.aspx">disk bound</a>, so it seems like there is some potential.</p>
<p>I discussed this with colleagues at work, and someone suggested that compiling managed code is more CPU intensive than native. This would suggest that it might be CPU bound, rather than disk bound. I therefore decided to test both native and managed code compilation, using both a conventional hard disk drive and a solid state drive.</p>
<p><strong>Test Setup</strong></p>
<p>I used my <a href="http://valid.canardpc.com/show_oc.php?id=1086991">ageing PC</a> running Windows 7 x64 Ultimate and Visual Studio 2010 Ultimate. For each disk I did a clean install and didn&#8217;t apply any updates.</p>
<p>I ran my tests on the following:</p>
<ul>
<li>A <a href="http://en.wikipedia.org/wiki/Western_Digital_Raptor">Western Digital Raptor</a> 150gb (WD1500ADFD), a 10k RPM conventional hard disk</li>
<li>An <a href="http://www.anandtech.com/show/3681/oczs-vertex-2-special-sauce-sf1200-reviewed">OCZ Vertex 2 100gb</a> SSD</li>
</ul>
<p>I selected the following test code to compile, based on it being relatively fast and self contained (I didn&#8217;t want to spend hours doing this!), and be fairly representative of a small system (compiling multiple dependent binaries):</p>
<ul>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=bcb166f7-dd16-448b-a152-9845760d9b4c&#038;displaylang=en">Microsoft Enterprise Library 5.0</a> &#8211; a small set of managed components written by the Microsoft Patterns &#038; Practices team.</li>
<li><a href="http://lame.sourceforge.net/">LAME</a>, the open source MP3 encoding library. I used version 3.98.4, and did a little hacking to get it to build against a recent GTK+.</li>
</ul>
<p><strong>Results</strong></p>
<p>I compiled each test program three times and took the average result. I turned on build timing in Visual Studio by going to Tools->Options->Projects and Solutions->Build and Run->MSBuild project build output verbosity=Detailed. VS2010 now uses MSBuild for native code.</p>
<div id="attachment_931" class="wp-caption aligncenter" style="width: 500px"><a href="http://blog.hypercomplex.co.uk/wp-content/uploads/2010/06/compile-time.png"><img src="http://blog.hypercomplex.co.uk/wp-content/uploads/2010/06/compile-time.png" alt="" title="compile time" width="490" height="294" class="size-full wp-image-931" /></a><p class="wp-caption-text">Compile time in seconds. Lower is better.</p></div>
<p>So, using an SSD we get around a 21% gain in speed on native code, and a 16% gain compiling managed. Not bad. Although my Raptor isn&#8217;t the most recent model, it is representative of the fastest conventional SATA hard disk available. On this basis, I would expect a RAID setup based on 10k RPM disks to outperform the SSD.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/06/ssd-compiler-benchmark/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>P/Invoke Interop Assistant</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/05/pinvoke-interop-assistant/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/05/pinvoke-interop-assistant/#comments</comments>
		<pubDate>Sat, 08 May 2010 23:45:28 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[interop]]></category>
		<category><![CDATA[p/invoke]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=900</guid>
		<description><![CDATA[After messing about for literally hours trying to p/invoke GetTokenInformation only for it to return what appeared to be sinographs, I came accross the P/Invoke interop assistant on CodePlex. Although this didn&#8217;t solve the my problem (which was correctly marshalling a fixed size char array), it would doubtlessly have saved me time writing the boiler [...]]]></description>
			<content:encoded><![CDATA[<p>After messing about for literally hours trying to p/invoke <a href="http://msdn.microsoft.com/en-us/library/aa446671%28VS.85%29.aspx">GetTokenInformation</a> only for it to return what appeared to be sinographs, I came accross the <a href="http://clrinterop.codeplex.com/releases/view/14120">P/Invoke interop assistant</a> on CodePlex.</p>
<div id="attachment_901" class="wp-caption aligncenter" style="width: 460px"><a href="http://blog.hypercomplex.co.uk/wp-content/uploads/2010/05/pinvoke.jpg"><img src="http://blog.hypercomplex.co.uk/wp-content/uploads/2010/05/pinvoke.jpg" alt="" title="pinvoke assistant" width="450" height="258" class="size-medium wp-image-901" /></a><p class="wp-caption-text">The P/Invoke Interop Assistant: it generates some useful stuff</p></div>
<p>Although this didn&#8217;t solve the my problem (which was correctly marshalling a fixed size char array), it would doubtlessly have saved me time writing the boiler plate structs, enums and method signatures. Highly recommended.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/05/pinvoke-interop-assistant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing HTML tables into System.Data.DataTable</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/05/parsing-html-tables-into-system-data-datatable/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/05/parsing-html-tables-into-system-data-datatable/#comments</comments>
		<pubDate>Thu, 06 May 2010 20:50:08 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DataSet]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[RegEx]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=877</guid>
		<description><![CDATA[What follows is a quick and dirty class I made to parse HTML tables into DataTables. As usual, it is the result of internet search/run/bug fix/refactor. In use, it looks little like this: WebClient client = new WebClient&#40;&#41;; string html = client.DownloadString&#40;@&#34;http://www.table.co.uk&#34;&#41;; DataSet dataSet = HtmlTableParser.Parse&#40;html&#41;; Here is the implementation. It&#8217;s not optimised for runtime [...]]]></description>
			<content:encoded><![CDATA[<p>What follows is a quick and dirty class I made to parse HTML tables into <a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx">DataTable</a>s. As usual, it is the result of internet search/run/bug fix/refactor.</p>
<p>In use, it looks little like this:</p>

<div class="wp_codebox"><table><tr id="p8776"><td class="code" id="p877code6"><pre class="csharp" style="font-family:monospace;">WebClient client <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> WebClient<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">string</span> html <span style="color: #008000;">=</span> client<span style="color: #008000;">.</span><span style="color: #0000FF;">DownloadString</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;http://www.table.co.uk&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
DataSet dataSet <span style="color: #008000;">=</span> HtmlTableParser<span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>html<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Here is the implementation. It&#8217;s not optimised for runtime performance, but it works.</p>

<div class="wp_codebox"><table><tr id="p8777"><td class="code" id="p877code7"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// HtmlTableParser parses the contents of an html string into a System.Data DataSet or DataTable.</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> HtmlTableParser
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> RegexOptions ExpressionOptions <span style="color: #008000;">=</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000FF;">Singleline</span> <span style="color: #008000;">|</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000FF;">Multiline</span> <span style="color: #008000;">|</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000FF;">IgnoreCase</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> CommentPattern <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&lt;!--(.*?)--&gt;&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> TablePattern <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&lt;table[^&gt;]*&gt;(.*?)&lt;/table&gt;&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> HeaderPattern <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&lt;th[^&gt;]*&gt;(.*?)&lt;/th&gt;&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> RowPattern <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&lt;tr[^&gt;]*&gt;(.*?)&lt;/tr&gt;&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> CellPattern <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&lt;td[^&gt;]*&gt;(.*?)&lt;/td&gt;&quot;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Given an HTML string containing n table tables, parse them into a DataSet containing n DataTables.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;html&quot;&gt;An HTML string containing n HTML tables&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;A DataSet containing a DataTable for each HTML table in the input HTML&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> DataSet ParseDataSet<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> html<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        DataSet dataSet <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DataSet<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        MatchCollection tableMatches <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>
            WithoutComments<span style="color: #008000;">&#40;</span>html<span style="color: #008000;">&#41;</span>,
            TablePattern,
            ExpressionOptions<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Match tableMatch <span style="color: #0600FF; font-weight: bold;">in</span> tableMatches<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            dataSet<span style="color: #008000;">.</span><span style="color: #0000FF;">Tables</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>ParseTable<span style="color: #008000;">&#40;</span>tableMatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> dataSet<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Given an HTML string containing a single table, parse that table to form a DataTable.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;tableHtml&quot;&gt;An HTML string containing a single HTML table&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;A DataTable which matches the input HTML table&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> DataTable ParseTable<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tableHtml<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">string</span> tableHtmlWithoutComments <span style="color: #008000;">=</span> WithoutComments<span style="color: #008000;">&#40;</span>tableHtml<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        DataTable dataTable <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DataTable<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        MatchCollection rowMatches <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>
            tableHtmlWithoutComments,
            RowPattern,
            ExpressionOptions<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        dataTable<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AddRange</span><span style="color: #008000;">&#40;</span>tableHtmlWithoutComments<span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;th&quot;</span><span style="color: #008000;">&#41;</span>
                                       <span style="color: #008000;">?</span> ParseColumns<span style="color: #008000;">&#40;</span>tableHtml<span style="color: #008000;">&#41;</span>
                                       <span style="color: #008000;">:</span> GenerateColumns<span style="color: #008000;">&#40;</span>rowMatches<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        ParseRows<span style="color: #008000;">&#40;</span>rowMatches, dataTable<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> dataTable<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Strip comments from an HTML stirng</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;html&quot;&gt;An HTML string potentially containing comments&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;The input HTML string with comments removed&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span> WithoutComments<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> html<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>html, CommentPattern, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span>, ExpressionOptions<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Add a row to the input DataTable for each row match in the input MatchCollection</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;rowMatches&quot;&gt;A collection of all the rows to add to the DataTable&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;dataTable&quot;&gt;The DataTable to which we add rows&lt;/param&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> ParseRows<span style="color: #008000;">&#40;</span>MatchCollection rowMatches, DataTable dataTable<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Match rowMatch <span style="color: #0600FF; font-weight: bold;">in</span> rowMatches<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// if the row contains header tags don't use it - it is a header not a row</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>rowMatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;th&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                DataRow dataRow <span style="color: #008000;">=</span> dataTable<span style="color: #008000;">.</span><span style="color: #0000FF;">NewRow</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                MatchCollection cellMatches <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>
                    rowMatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span>,
                    CellPattern,
                    ExpressionOptions<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> columnIndex <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> columnIndex <span style="color: #008000;">&lt;</span> cellMatches<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> columnIndex<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    dataRow<span style="color: #008000;">&#91;</span>columnIndex<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> cellMatches<span style="color: #008000;">&#91;</span>columnIndex<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Groups</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                dataTable<span style="color: #008000;">.</span><span style="color: #0000FF;">Rows</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>dataRow<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Given a string containing an HTML table, parse the header cells to create a set of DataColumns</span>
    <span style="color: #008080; font-style: italic;">/// which define the columns in a DataTable.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;tableHtml&quot;&gt;An HTML string containing a single HTML table&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;A set of DataColumns based on the HTML table header cells&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> DataColumn<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> ParseColumns<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> tableHtml<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        MatchCollection headerMatches <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>
            tableHtml,
            HeaderPattern,
            ExpressionOptions<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">from</span> Match headerMatch <span style="color: #0600FF; font-weight: bold;">in</span> headerMatches
                <span style="color: #0600FF; font-weight: bold;">select</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DataColumn<span style="color: #008000;">&#40;</span>headerMatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Groups</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// For tables which do not specify header cells we must generate DataColumns based on the number</span>
    <span style="color: #008080; font-style: italic;">/// of cells in a row (we assume all rows have the same number of cells).</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;rowMatches&quot;&gt;A collection of all the rows in the HTML table we wish to generate columns for&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;A set of DataColumns based on the number of celss in the first row of the input HTML table&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> DataColumn<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> GenerateColumns<span style="color: #008000;">&#40;</span>MatchCollection rowMatches<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">int</span> columnCount <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>
            rowMatches<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>,
            CellPattern,
            ExpressionOptions<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">from</span> index <span style="color: #0600FF; font-weight: bold;">in</span> Enumerable<span style="color: #008000;">.</span><span style="color: #0000FF;">Range</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, columnCount<span style="color: #008000;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;">select</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DataColumn<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Column &quot;</span> <span style="color: #008000;">+</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span>index<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>As always, here are the tests. They yield 100% coverage but I still need to add some asserts on the column names.</p>

<div class="wp_codebox"><table><tr id="p8778"><td class="code" id="p877code8"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// Tests for the HtmlTableParser class</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #008000;">&#91;</span>TestClass<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ParserTest
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> TestContext testContextInstance<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Verify that HtmlTableParser can parse an HTML file containing a single table. The</span>
    <span style="color: #008080; font-style: italic;">/// test file includes a commented out table which should be ignored. Note some tags use</span>
    <span style="color: #008080; font-style: italic;">/// attributes (we test we can parse tags with and without attributes).</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008000;">&#91;</span>TestMethod<span style="color: #008000;">&#93;</span>
    <span style="color: #008000;">&#91;</span>DeploymentItem<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;data\singleTable.txt&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TestParseSingleTable<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">string</span> html <span style="color: #008000;">=</span> File<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadAllText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;singleTable.txt&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        DataTable table <span style="color: #008000;">=</span> HtmlTableParser<span style="color: #008000;">.</span><span style="color: #0000FF;">ParseTable</span><span style="color: #008000;">&#40;</span>html<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        AssertTable<span style="color: #008000;">&#40;</span>GetExpectedData<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, table<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Verify that HtmlTableParser can parse an HTML file containing multiple tables. The</span>
    <span style="color: #008080; font-style: italic;">/// test file includes a commented out table which should be ignored. The test file</span>
    <span style="color: #008080; font-style: italic;">/// contains tables both with and without headers.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008000;">&#91;</span>TestMethod<span style="color: #008000;">&#93;</span>
    <span style="color: #008000;">&#91;</span>DeploymentItem<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;data\multipleTables.txt&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TestParseMultipleTables<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">string</span> html <span style="color: #008000;">=</span> File<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadAllText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;multipleTables.txt&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        DataSet dataSet <span style="color: #008000;">=</span> HtmlTableParser<span style="color: #008000;">.</span><span style="color: #0000FF;">ParseDataSet</span><span style="color: #008000;">&#40;</span>html<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">3</span>, dataSet<span style="color: #008000;">.</span><span style="color: #0000FF;">Tables</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        var expected <span style="color: #008000;">=</span> GetExpectedData<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>DataTable table <span style="color: #0600FF; font-weight: bold;">in</span> dataSet<span style="color: #008000;">.</span><span style="color: #0000FF;">Tables</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            AssertTable<span style="color: #008000;">&#40;</span>expected, table<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> GetExpectedData<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #008000;">&#123;</span>
            <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">&quot;row 1, cell 1&quot;</span>, <span style="color: #666666;">&quot;row 1, cell 2&quot;</span> <span style="color: #008000;">&#125;</span>,
            <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">&quot;row 2, cell 1&quot;</span>, <span style="color: #666666;">&quot;row 2, cell 2&quot;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> AssertTable<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> expected, DataTable table<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&#40;</span>expected<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, table<span style="color: #008000;">.</span><span style="color: #0000FF;">Rows</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span>, <span style="color: #666666;">&quot;Table did not contain the expected number of rows&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> expected<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> j <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> j <span style="color: #008000;">&lt;</span> expected<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> j<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #6666cc; font-weight: bold;">string</span> actualElement <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>table<span style="color: #008000;">.</span><span style="color: #0000FF;">Rows</span><span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <span style="color: #0600FF; font-weight: bold;">as</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Trim</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #6666cc; font-weight: bold;">string</span> expectedElement <span style="color: #008000;">=</span> expected<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
                Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>expectedElement, actualElement, <span style="color: #666666;">&quot;Table did not contain the expected element&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>These are the test files, which are just some basic HMTL.</p>

<div class="wp_codebox"><table><tr id="p8779"><td class="code" id="p877code9"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
      &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
    &lt;meta name=&quot;robots&quot; content=&quot;all&quot; /&gt;
      &lt;title&gt;Title&lt;/title&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
      &lt;!-- This table is commented out, so it shouldn't be parsed.
      &lt;table border=&quot;1&quot;&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;th&gt;Commented Heading 1&lt;/th&gt;
                  &lt;th&gt;Commented Heading 2&lt;/th&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;Commented row 1, cell 1&lt;/td&gt;
                  &lt;td&gt;Commented row 1, cell 2&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;Commented row 2, cell 1&lt;/td&gt;
                  &lt;td&gt;Commented row 2, cell 2&lt;/td&gt;
            &lt;/tr&gt;
      &lt;/table&gt;
      --&gt;
&nbsp;
      &lt;!-- The parser should ignore the border attributes --&gt;
      &lt;table border=&quot;1&quot;&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;th&gt;Heading 1&lt;/th&gt;
                  &lt;th&gt;Heading 2&lt;/th&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                  &lt;td border=&quot;1&quot;&gt;row 1, cell 1&lt;/td&gt;
                  &lt;td&gt;row 1, cell 2&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;row 2, cell 1&lt;/td&gt;
                  &lt;td&gt;row 2, cell 2&lt;/td&gt;
            &lt;/tr&gt;
      &lt;/table&gt; 
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p87710"><td class="code" id="p877code10"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
      &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
    &lt;meta name=&quot;robots&quot; content=&quot;all&quot; /&gt;
      &lt;title&gt;Title&lt;/title&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
      &lt;!-- The parser should ignore the border attributes --&gt;
      &lt;table border=&quot;1&quot;&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;row 1, cell 1&lt;/td&gt;
                  &lt;td&gt;row 1, cell 2&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;row 2, cell 1&lt;/td&gt;
                  &lt;td&gt;row 2, cell 2&lt;/td&gt;
            &lt;/tr&gt;
      &lt;/table&gt; 
      &lt;!-- This table is commented out, so it shouldn't be parsed.
      &lt;table border=&quot;1&quot;&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;th&gt;Commented Heading 1&lt;/th&gt;
                  &lt;th&gt;Commented Heading 2&lt;/th&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;Commented row 1, cell 1&lt;/td&gt;
                  &lt;td&gt;Commented row 1, cell 2&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;Commented row 2, cell 1&lt;/td&gt;
                  &lt;td&gt;Commented row 2, cell 2&lt;/td&gt;
            &lt;/tr&gt;
      &lt;/table&gt;
      --&gt;
      &lt;table border=&quot;1&quot;&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;th&gt;Heading 1&lt;/th&gt;
                  &lt;th&gt;Heading 2&lt;/th&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;row 1, cell 1&lt;/td&gt;
                  &lt;td&gt;row 1, cell 2&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;row 2, cell 1&lt;/td&gt;
                  &lt;td&gt;row 2, cell 2&lt;/td&gt;
            &lt;/tr&gt;
      &lt;/table&gt; 
      &lt;table&gt;
            &lt;tr&gt;
                  &lt;td&gt;row 1, cell 1&lt;/td&gt;
                  &lt;td&gt;row 1, cell 2&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr  border=&quot;1&quot;&gt;
                  &lt;td&gt;row 2, cell 1&lt;/td&gt;
                  &lt;td border=&quot;1&quot;&gt;row 2, cell 2&lt;/td&gt;
            &lt;/tr&gt;
      &lt;/table&gt; 
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/05/parsing-html-tables-into-system-data-datatable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hi-Fi Burn in and Demagnetisation</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/04/hi-fi-burn-in-and-demagnetisation/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/04/hi-fi-burn-in-and-demagnetisation/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 17:16:05 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Hi-Fi]]></category>
		<category><![CDATA[demagnetisation]]></category>
		<category><![CDATA[IsoTek Full System Enhancer]]></category>
		<category><![CDATA[Tweaks]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=849</guid>
		<description><![CDATA[I purchased a second hand copy of the IsoTek Full System Enhancer CD. My aim? To debunk the incredulous claims that this CD can improve the fidelity of my Hi-Fi system. 6moons, amongst others, have given favourable reviews, which made me curious. The sleeve states this disc can be used for two things: burning in [...]]]></description>
			<content:encoded><![CDATA[<p>I purchased a second hand copy of the <a href="http://www.isoteksystems.com/cds.asp">IsoTek Full System Enhancer CD</a>. My aim? To debunk the incredulous claims that this CD can improve the fidelity of my Hi-Fi system. <a href="http://www.6moons.com/audioreviews/isotek/cd.html">6moons</a>, amongst others, have given favourable reviews, which made me curious.</p>
<p>The sleeve states this disc can be used for two things: burning in components and demagnetising the whole sytem. The track listing is as follows:</p>
<ol>
<li>Full system burn-in &#038; demagnetisation.</li>
<li>Full system burn-in &#038; demagnetisation with low level tones.</li>
<li>Full system rejuvenation, including demagnetisation tones.</li>
</ol>
<p><strong>Burn In</strong></p>
<p>To be honest, burn in seemed plausible to me. In particular, it seems intuitative that speakers may be &#8220;burned in&#8221; because they have moving parts which might loosen up over time. I have burned in speakers and been able to discern a change in their sound.</p>
<p>I have also observed that my system sounds better if left powered on. I can&#8217;t remember ever realising that the sound of a cable had changed over time, however. Perhaps because I&#8217;m not in the habit listening analytically to my system. I generally prefer listening to music.</p>
<p>I hadn&#8217;t previously thought about the scientific explanation for burning in electronic components (or cables for that matter), but I now suspect that it relates to a stabilisation of the intrinsic magnetic state of the conductors. I&#8217;ll return to this later.</p>
<p><strong>Demagnetisation</strong></p>
<p>I was extremely skeptical that playing a CD could somehow affect the state of my HiFi such that later reproduction of music would be audibly better. Then I played track 2 of the Full System Enhancer. It sounds like white noise with some clicks and pops, and the occaisonal continuous tone.</p>
<div id="attachment_865" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.hypercomplex.co.uk/wp-content/uploads/2010/04/2.jpg"><img src="http://blog.hypercomplex.co.uk/wp-content/uploads/2010/04/2-300x181.jpg" alt="" title="Spectral analysis of Track 2" width="300" height="181" class="size-medium wp-image-865" /></a><p class="wp-caption-text">Spectral analysis of Track 2 (via CoolEdit Pro)</p></div>
<p>The result: a subtle improvement. Whilst I try to avoid <a href="http://stereophile.com/reference/50/">Hi-Fi bollocks</a> where ever possible, a tenuous description is required at this point. To expand on subtle improvement, I would say that the sound was slightly more realistic in terms of ambience and timbre. This seemed more apparent with live recordings.</p>
<p><strong>Is it really better? Could it really happen?</strong></p>
<p>I&#8217;m tempted to say yes, but I have doubts about anything I don&#8217;t fully understand. I therefore decided to try to explain what might be happening by applying some basic physics. A quick scan of Wikipedia (which I assume is acurate enough for the purposes of this discussion) highlighted the following pertinent facts:</p>
<ul>
<li>Conductors have atoms with free electrons. The free electrons move around randomly until an electric force is applied, at which point they flow in the direction of the force as a current.</li>
<li>When a material is magnetized, the free electrons remain bound to their respective atoms, but behave as if they were orbiting the nucleus in a particular direction, creating a microscopic current.</li>
<li>All materials can be magnetised to an extent, even diamagnetic metals such as copper, silver or lead (diamagnetic materials have a relative magnetic permeability of less than one).</li>
</ul>
<p>From that, I inferred that my Hi-Fi could be magnetised (though perhaps not very much because it is primarily composed of diamagnetic materials). Clearly, when magnetised, a conductor&#8217;s ability to transmit an electric current will be affected. Audio signals are transmitted as a voltage in analogue form (everything after the <a href="http://en.wikipedia.org/wiki/Digital-to-analog_converter">DAC</a>). Therefore, it is possible that there would be an audible difference between the magnetised and demagnetised state.</p>
<p>I know that a magnetic field can induce an electric current, and vice versa. So it seems that there exists a mechanism for a Hi-Fi system to become magnetised through normal use, and demagnetised using a magic sequence of audio signals. </p>
<p>In conclusion, this process seems plausible to me. To truly understand what is happening requires a firmer grasp on the laws of electromagnetism.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/04/hi-fi-burn-in-and-demagnetisation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixels</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/04/pixels/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/04/pixels/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 17:19:05 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[breakout]]></category>
		<category><![CDATA[donkey kong]]></category>
		<category><![CDATA[frogger]]></category>
		<category><![CDATA[pacman]]></category>
		<category><![CDATA[pong]]></category>
		<category><![CDATA[space invaders]]></category>
		<category><![CDATA[tetris]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=836</guid>
		<description><![CDATA[Perhaps this should have been called Voxels, but its good nevertheless.]]></description>
			<content:encoded><![CDATA[<p><object width="480" height="270"><param name="movie" value="http://www.dailymotion.com/swf/video/xcv6dv_pixels-by-patrick-jean_creation"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xcv6dv_pixels-by-patrick-jean_creation" width="480" height="270" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<p>Perhaps this should have been called Voxels, but its good nevertheless.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/04/pixels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crysis 2 Teaser</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/04/crysis-2-teaser/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/04/crysis-2-teaser/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 21:48:09 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[crysis]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=794</guid>
		<description><![CDATA[This doesn&#8217;t give too much away. Hopefully by the time it comes out I&#8217;ll have a PC fast enough to play Crysis 1.]]></description>
			<content:encoded><![CDATA[<p><object width="540" height="330"><param name="movie" value="http://www.youtube.com/v/1IVBR5GFGMY&#038;hl=en_GB&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/1IVBR5GFGMY&#038;hl=en_GB&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="540" height="330"></embed></object></p>
<p>This doesn&#8217;t give too much away. Hopefully by the time it comes out I&#8217;ll have a <a href="http://www.hypercomplex.co.uk/ap/rig.shtml">PC</a> fast enough to play Crysis 1.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/04/crysis-2-teaser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filtering sqlmetal output using XSLT</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/03/filtering-sqlmetal-output-using-xslt/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/03/filtering-sqlmetal-output-using-xslt/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 21:50:41 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[build target]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlmetal]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=799</guid>
		<description><![CDATA[I needed to generate LINQ to SQL O/RM classes for a subset of the objects in a large database. Unfortunately, sqlmetal doesn&#8217;t provide a mechanism to filter it&#8217;s output, so I made my own using XSLT, a batch file and a custom build target. This post explains how. Overview When you invoke a build, a [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to generate <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx">LINQ to SQL</a> O/RM classes for a subset of the objects in a large database. Unfortunately, <a href="http://msdn.microsoft.com/en-us/library/bb386987.aspx">sqlmetal</a> doesn&#8217;t provide a mechanism to filter it&#8217;s output, so I made my own using XSLT, a batch file and a custom build target. This post explains how. </p>
<p>
<strong>Overview</strong></p>
<p>When you invoke a build, a custom &#8220;BeforeBuild&#8221; build target runs to do the code generation. This code generation is driven by a batch file, this is what it does:</p>
<ol>
<li> Run sqlmetal to output a dbml file for the entire database schema</li>
<li> Using an XML configuration file and an XSLT transform, generate a test .cs file containing a reference to each expected table. When included in our project, this gives us a compile time test that we generated the expected classes (we make this internal).</li>
<li> Run a second XSLT transform based on the configuration file and the output a dbml file from step 1. In this step we prune the xml according to the config file. The result is a dbml file containing only the tables we specify in our configuration.</li>
<li> Run sqlmetal again using the result of step 3 as input. This time sqlmetal outputs our CSharp code for our Linq to Sql classes. </li>
</ol>
<p>The XSLT transforms are run from the command line using MSXSL.exe, which is available <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2FB55371-C94E-4373-B0E9-DB4816552E41&#038;displaylang=en">here</a>.</p>
<p>The generated CSharp files are part of my Visual Studio project. After the BeforeBuild target is run (which does the code generation), the generated code is compiled into an Assembly.</p>
<p>
<strong>Custom build target</strong></p>
<p>These are the pertinent parts of my project file. You can see that inside my project directory, I created a directory called Prebuild where the work happens. This is where the Configuration.xml, DbmlPruner.xslt, GenerateTestTypes.xslt and generate.bat files live.</p>

<div class="wp_codebox"><table><tr id="p79916"><td class="code" id="p799code16"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Project</span> <span style="color: #000066;">ToolsVersion</span>=<span style="color: #ff0000;">&quot;3.5&quot;</span> <span style="color: #000066;">DefaultTargets</span>=<span style="color: #ff0000;">&quot;Build&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #808080; font-style: italic;">&lt;!-- most of the project file omitted for brevity --&gt;</span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Target</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;BeforeBuild&quot;</span> <span style="color: #000066;">DependsOnTargets</span>=<span style="color: #ff0000;">&quot;GenerateDbClasses;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Target</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;GenerateDbClasses&quot;</span> <span style="color: #000066;">Inputs</span>=<span style="color: #ff0000;">&quot;Prebuild\Configuration.xml;Prebuild\DbmlPruner.xslt;Prebuild\GenerateTestTypes.xslt&quot;</span> <span style="color: #000066;">Outputs</span>=<span style="color: #ff0000;">&quot;MasterDb.Generated.cs;TestMasterDbTypes.cs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Exec</span> <span style="color: #000066;">Command</span>=<span style="color: #ff0000;">&quot;$(ProjectDir)Prebuild\generate.bat $(ProjectDir) $(TargetName) master.dbml prunedmaster.dbml TestMasterDbTypes.cs MasterDb Configuration.xml master&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>
<strong>Configuration.xml</strong></p>

<div class="wp_codebox"><table><tr id="p79917"><td class="code" id="p799code17"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- This configuration is used to specify which tables should generate linq to SQL classes, </span>
<span style="color: #808080; font-style: italic;">  and to generate a sanity check class which verifies all the expected types exist in the </span>
<span style="color: #808080; font-style: italic;">  generated code.</span>
<span style="color: #808080; font-style: italic;">  --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Configuration</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Master Tables&quot;</span> <span style="color: #000066;">SourceXml</span>=<span style="color: #ff0000;">&quot;master.dbml&quot;</span> <span style="color: #000066;">Namespace</span>=<span style="color: #ff0000;">&quot;Master.Data.Linq&quot;</span> <span style="color: #000066;">TestClassName</span>=<span style="color: #ff0000;">&quot;TestMasterTypes&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Table</span> <span style="color: #000066;">SqlName</span>=<span style="color: #ff0000;">&quot;dbo.TestTable&quot;</span> <span style="color: #000066;">DataContextPropertyName</span>=<span style="color: #ff0000;">&quot;TestTable&quot;</span> <span style="color: #000066;">ClassName</span>=<span style="color: #ff0000;">&quot;TestTableRow&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>
<strong>GenerateTestTypes.xslt</strong></p>

<div class="wp_codebox"><table><tr id="p79918"><td class="code" id="p799code18"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- ===========================================================</span>
<span style="color: #808080; font-style: italic;">  Generate a C# class with members corresponding to all the linq</span>
<span style="color: #808080; font-style: italic;">  to SQL tables specified in the input file.</span>
<span style="color: #808080; font-style: italic;">================================================================ --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:output</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
//-----------------------------------------------------------------------
// <span style="color: #339933;">&lt;![CDATA[&lt;auto-generated&gt;]]&gt;</span>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost 
//     if the code is regenerated.
// <span style="color: #339933;">&lt;![CDATA[&lt;/auto-generated&gt;]]&gt;</span>
//-----------------------------------------------------------------------
&nbsp;
// Disable warning CS0169: The private field 'foo' is never used. This is 
// by design.
#pragma warning disable 0169
&nbsp;
namespace <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;/Configuration/@Namespace&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
{
    /// <span style="color: #339933;">&lt;![CDATA[&lt;summary&gt;]]&gt;</span>
    /// This class is provided as a compile time test for the linq to SQL
    /// classes specified in Prebuild/configuration.xml. It will fail to
    /// compile if one of the dependent classes is not generated (or not
    /// generated with the expected name). This is by design.
    /// <span style="color: #339933;">&lt;![CDATA[&lt;/summary&gt;]]&gt;</span>
    internal class <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;/Configuration/@TestClassName&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    {      
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:for-each</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;/Configuration/Table&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;#9;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;#9;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>private <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;@ClassName&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;' '&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;concat(@ClassName, 'Member')&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;#xa;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/xsl:for-each<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;#9;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>}
}
&nbsp;
#pragma warning restore 0169
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>
<strong>DbmlPruner.xslt</strong></p>

<div class="wp_codebox"><table><tr id="p79919"><td class="code" id="p799code19"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- ===========================================================</span>
<span style="color: #808080; font-style: italic;">  Replicate a .dbml file based on the tables specified in a </span>
<span style="color: #808080; font-style: italic;">  configuration.</span>
<span style="color: #808080; font-style: italic;">================================================================ --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span></span>
<span style="color: #009900;">	 <span style="color: #000066;">xmlns:sql</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/linqtosql/dbml/2007&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:output</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;xml&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000066;">indent</span>=<span style="color: #ff0000;">&quot;yes&quot;</span></span>
<span style="color: #009900;">  	  omit-xml-declaration = <span style="color: #ff0000;">&quot;no&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;Configuration&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
		<span style="color: #808080; font-style: italic;">&lt;!-- load sql metal output as $database --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;database&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;document(@SourceXml)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;namespace&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;namespace-uri($database/sql:Database)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> =====================================================================================
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;@Name&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> generated from database <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$database/sql:Database/@Name&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> (<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;@SourceXml&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>)
========================================================================================== <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
		<span style="color: #808080; font-style: italic;">&lt;!-- Output a tree which replicates @SourceXml but contains only the table nodes in the configuration --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Database&quot;</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;{$namespace}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$database/sql:Database/@Name&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:for-each</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;/Configuration/Table&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sqlName&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;@SqlName&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
				<span style="color: #808080; font-style: italic;">&lt;!-- only output a table element when the source table exists --&gt;</span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:if</span> <span style="color: #000066;">test</span>=<span style="color: #ff0000;">&quot;$database/sql:Database/sql:Table[@Name=$sqlName]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
					<span style="color: #808080; font-style: italic;">&lt;!-- Output the table substituting Member and Type for the ClassName in the configuration --&gt;</span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Table&quot;</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;{$namespace}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;@SqlName&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Member&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;@DataContextPropertyName&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Type&quot;</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;{$namespace}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
								<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;@ClassName&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
							<span style="color: #808080; font-style: italic;">&lt;!-- Copy the children (Columns etc) --&gt;</span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:copy-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$database/sql:Database/sql:Table[@Name=$sqlName]/sql:Type/*&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:for-each<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>
<strong>generate.bat</strong></p>
<p>This is my entire generate.bat file, you can glean the input arguments from the custom build target above.</p>

<div class="wp_codebox"><table><tr id="p79920"><td class="code" id="p799code20"><pre class="bat" style="font-family:monospace;">::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Generate LINQ to SQL classes based on tables defined in an xml config
::
&nbsp;
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
&nbsp;
setlocal 
&nbsp;
set SQLMETAL=&lt;put your path here!&gt;\sdk\Win2008\Bin\sqlmetal.exe
set MSXSL=&lt;put your path here!&gt;\msxsl.exe
&nbsp;
set PRJDIR=%1%
set PREDIR=%PRJDIR%Prebuild\
&nbsp;
set NAMESPACE=%2
&nbsp;
set METALOUT=%PREDIR%%3
set METALIN=%PREDIR%%4
&nbsp;
set COMPILETESTCLASS=%PRJDIR%%5
set CONTEXTCLASS=%6
set CONTEXTCLASSFILE=%PRJDIR%%CONTEXTCLASS%.Generated.cs
&nbsp;
set CONFIGPATH=%PREDIR%%7
set DATABASE=%8
&nbsp;
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
&nbsp;
echo ================ Generation of LINQ to SQL classes started ================
echo Using %CONFIGPATH%
&nbsp;
echo 1. Building %METALOUT% for entire %DATABASE% database 
%SQLMETAL% /conn:&quot;server=localhost; database=%DATABASE%;Integrated Security=SSPI&quot; /dbml:%METALOUT%
if errorlevel 1 goto :Failed
&nbsp;
echo 2. Generating %COMPILETESTCLASS% to test linq to sql types were generated correctly at compile time
%MSXSL% %CONFIGPATH% %PREDIR%GenerateTestTypes.xslt -o %COMPILETESTCLASS%
if errorlevel 1 goto :Failed
&nbsp;
echo 3. Building %METALIN% from %CONFIGPATH%
%MSXSL% %CONFIGPATH% %PREDIR%DbmlPruner.xslt -o %METALIN%
if errorlevel 1 goto :Failed
&nbsp;
echo 4. Generating %CONTEXTCLASSFILE% using %METALIN%
%SQLMETAL% %METALIN% /code:%CONTEXTCLASSFILE% /language:csharp /context:%CONTEXTCLASS% /namespace:%NAMESPACE% /serialization:Unidirectional
if errorlevel 1 goto :Failed
&nbsp;
echo ======== Generation of LINQ to SQL classes completed successfully =========
endlocal
goto :EOF
&nbsp;
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:Failed
&nbsp;
echo Configuration %CONFIG% FAILED
endlocal
exit /B 1</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/03/filtering-sqlmetal-output-using-xslt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Folding plug</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2010/03/folding-plug/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2010/03/folding-plug/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 21:38:00 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[plug]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/index.php/2010/03/folding-plug/</guid>
		<description><![CDATA[This is a really nice design. The voiceover is considerably less inspiring.]]></description>
			<content:encoded><![CDATA[<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/f6DvjKkGT6s&#038;hl=en_GB&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/f6DvjKkGT6s&#038;hl=en_GB&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>This is a really nice design. The voiceover is considerably less inspiring.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2010/03/folding-plug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
