George V. Reilly

Upgrade your installation of NAnt

My colleague, Greg, and I spent all day debugging a build break in some unit tests that exercise a webservice interface in legacy .NET 1.1 code. Last night, the tests stopped working on our CruiseC­on­trol.NET build server. We couldn't understand it. The tests had been working for months. Now we were getting timeouts in SOAP. The tests es­sen­tial­ly mock a SOAP service using the soap.inproc transport and a stub im­ple­men­ta­tion that signaled an event to ac­knowl­edge a method being called.

The only thing that had changed in the code tree was that another colleague, Pavel, had discovered that two of our .csproj files somehow shared the same GUID, and had repaired continue.

Throwing from XSLT

I needed to add some de­clar­a­tive error checking to some XSLT templates recently. Specif­i­cal­ly, I wanted to throw an error if my selects yielded an empty string, indicating that the input XML was wrong.

Un­for­tu­nate­ly, there seems to be no easy way of doing this in XSLT, nor in XslTrans­form. The approved way is to validate against an XSD schema, but for various reasons, I didn't want to go to the hassle of creating one.

I found a partial solution using xsl:message with the terminate="yes" attribute. Under XslTrans­form.Transform() the following code throws an exception if the XPath expression is empty.

<xsl:if test="not(/some/xpath/expression)">
    <xsl:message terminate="yes">Missing expression</xsl:message>
</xsl:if>
<xsl:value-of select="/some/xpath/expression" 
continue.

How to be a Good Developer or User

18 Ways to be a Good Developer, inspired by 20 Ways to be a Good User.

« Next