Skip to main content


Showing posts from December, 2007

How to change the version of HTTP that your .NET web-service client proxy class uses ...

.NET uses HTTP version 1.1 by default for HTTP traffic. There are a number of differences between HTTP 1.1 and HTTP 1.0, so if you are talking to a HTTP 1.0 web-service (which you will be if you are talking with a Java web-service), then your generated .NET client proxy class will not be able to successfully communicate. This is frustrating, given the fact that you can read and process the WSDL, and build a client against it, but then not use the web-service.

The easy work-around for this problem is to use a .NET 2.0+ Partial Class - as follows:


using System;
using System.Net;

public partial class YourProxyClassName
        protected override System.Net.WebRequest GetWebRequest(Uri uri)
            // set proxy config while we are in here
            WebRequest.DefaultWebProxy = null;

            System.Net.HttpWebRequest req;
            req = ( System.Net.HttpWebRequest)base.Get…

XSLT replace - the code

Extending on my post earlier today - thought I may as well include the code:

<?xml version="1.0" ?>
<xsl:stylesheetxmlns:xsl=" " version="1.0">

<!-- reusable replace-string function -->
<xsl:template name="replace-string">
<xsl:when test="contains($text, $from)">
<xsl:variablename="before" select="substring-before($text, $from)"/>
<xsl:variablename="after" select=" substring-after($text, $from)"/>
<xsl:variablename="prefix" select="concat($before, $to)"/>
< xsl:value-ofselect="$before"/>
< xsl:value-ofselect="$to"/>
< xsl:call-templatename="replace-string">
<xsl:with-param name="text" select="$after"/&g…

XSLT output-tokens function ...

This can be used to split a string into tokens and add <br />s where appropriate:

<!-- reusable tokening function -->
<xsl:template name="output-tokens">
<xsl:param name="list" />
<xsl:variable name="newlist" select="concat(normalize-space($list), ' ')" />
<xsl:variable name="first" select="substring-before($newlist, ' ')" />
<xsl:variable name="remaining" select="substring-after($newlist, ' ')" />
<br />
<xsl:value-of select="$first" />
<br />
<xsl:if test="$remaining">
<xsl:call-template name="output-tokens">
<xsl:with-param name="list" select="$remaining" />

very handy ...

XSLT replace(,,) in VS200* ...

I would really like to be able to use the XSLT replace(,,) function in some work that I'm doing right now - but it seems as though I'm not able to, even in VS2008, because the .NET framework class libraries only support XSLT and XPath 1.0.

Have looked into Saxon for .NET, but there seems to be almost no documentation avialable as to how to use this component. The VS2008 XSLT debugger is actually superb, so I'm a bit baffled by this lack of support for XSLT and XPath 2.0 :-/

Anyway, I was sent this link ...

Which provides a code-listing that implements a custom search-and-replace function in XSLT. Works like a charm ;-)