This XSLT 1.0 transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="pServerName" select="'http://MyServer'"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="a/@href[not(starts-with(.,'http://'))]">
<xsl:attribute name="href">
<xsl:value-of select="concat($pServerName, .)"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
when applied to this XML document:
<html>
<a href="/dir/file1.htm">Link 1</a>
<a href="/dir/file2.htm">Link 2</a>
<a href="/dir/file3.htm">Link 3</a>
</html>
produces the wanted, correct result:
<html>
<a href="http://MyServer/dir/file1.htm">Link 1</a>
<a href="http://MyServer/dir/file2.htm">Link 2</a>
<a href="http://MyServer/dir/file3.htm">Link 3</a>
</html>
II. XSLT 2.0 solution:
In XPath 2.0 one can use the standard function resolve-uri()
This transformation:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:variable name="vBaseUri" select="'http://Myserver/ttt/x.xsl'"/>
<xsl:template match="/">
<xsl:value-of select="resolve-uri('/mysite.aspx', $vBaseUri)"/>
</xsl:template>
</xsl:stylesheet>
when applied on any XML document (not used), produces the wanted, correct result:
http://Myserver/mysite.aspx
If the stylesheet module comes from the same server as the relative URLs to be resolved, then there is no need to pass the base uri in a parameter -- doing the following produces the wanted result:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:variable name="vBaseUri">
<xsl:for-each select="document('')">
<xsl:sequence select="resolve-uri('')"/>
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<xsl:value-of select="resolve-uri('/mysite.aspx', $vBaseUri)"/>
</xsl:template>
</xsl:stylesheet>