All pastes #1793150 Raw Edit

xslt quote uri

public xml v1 · immutable
#1793150 ·published 2010-02-10 22:31 UTC
rendered paste body
<?xml version="1.0"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  <xsl:template match="/">    <xsl:call-template name="quote-uri">      <xsl:with-param name="uri"	select=" 'http://www.example.org/boy?socks=black&amp;eyes=blye&amp;hair=long&amp;age=19' " />    </xsl:call-template>  </xsl:template>  <!--* quote ampersand, less-than and greater-than in a URI; this is      * not a full URI quoting, and does not hande IRIs.      *-->  <xsl:template name="quote-uri">    <xsl:param name="uri" />    <xsl:variable name="firstchar" select="substring($uri, 1, 1)" />    <xsl:choose>      <xsl:when test="$firstchar = ''"></xsl:when> <!--* finished *-->      <xsl:when test="$firstchar = '&lt;'">	<xsl:text>%3c</xsl:text>	<xsl:call-template name="quote-uri">	  <xsl:with-param name="uri" select="substring($uri, 2)" />	</xsl:call-template>      </xsl:when>      <xsl:when test="$firstchar = '&gt;'">	<xsl:text>%3e</xsl:text>	<xsl:call-template name="quote-uri">	  <xsl:with-param name="uri" select="substring($uri, 2)" />	</xsl:call-template>      </xsl:when>      <xsl:when test="$firstchar = '&amp;'">	<xsl:text>%26</xsl:text>	<xsl:call-template name="quote-uri">	  <xsl:with-param name="uri" select="substring($uri, 2)" />	</xsl:call-template>      </xsl:when>      <xsl:otherwise>	<xsl:value-of select="$firstchar" />	<xsl:call-template name="quote-uri">	  <xsl:with-param name="uri" select="substring($uri, 2)" />	</xsl:call-template>      </xsl:otherwise>    </xsl:choose>  </xsl:template></xsl:stylesheet>