Subject: Re: [xsl] Resolving Netscape 4.7, and IE 5 issues with XSL From: Mike Brown <mike@xxxxxxxx> Date: Wed, 16 May 2001 11:47:33 -0600 (MDT) |
Niranjan Perera wrote: > In my demo.xsl, I have the following fragment > > <xsl:attribute > name="href">getDemo.xml?Id=<xsl:value-of > select="@Account"/></xsl:attribute> > > where @Account is holding onto 'Hello World' Not sure if you need to do more complex calculations to get your attribute values, but a simpler syntax in this case would be: <a href="getDemo.xml?Id={@Account}">click</a> In any case, your output HTML contains href="getDemo.xml?Id=Hello World" And you should note that the attribute value here is not a legal URI. Raw space characters are not allowed in URIs. > When I use IE 5, Netscape 6, or Opera 5 this is what > is sent via the http call: > > http://localhost/demo/getDemo.xml?Id=Hello%20World Then IE 5, Netscape 6 and Opera 5 are being very nice to translate your unescaped space for you. They are under no obligation to do that. > When I use Netscape 4.7 this is what is sent via the http call > > http://localhost/demo/getDemo.xml?Id=Hello World Netscape 4.7 is not doing anything wrong, although one could argue that since an href value must be a URI, any disallowed characters in the value should be considered part of the URI and should be escaped so as not to have this situation. But there is no requirement that this actually happen. You should just translate the spaces in the first place. If you are sure that your server will accept '+' instead of ' ', you might try using the translate() function: <a href="getDemo.xml?Id={translate(@Account,' ','+')}">click</a> or, the way I would do it, would be to do a string replacement of ' ' with '%20': <a> <xsl:attribute name="href"> <xsl:text>getDemo.xml?Id=</xsl:text> <xsl:call-template name="replace"> <xsl:with-param name="stringIn" select="@Account"/> <xsl:with-param name="charsIn" select="' '"/> <xsl:with-param name="charsOut" select="'%20'"/> </xsl:call-template> </xsl:attribute> <xsl:text>click</xsl:text> </a> The named template is below. <xsl:template name="replace"> <xsl:param name="stringIn"/> <xsl:param name="charsIn"/> <xsl:param name="charsOut"/> <xsl:choose> <xsl:when test="contains($stringIn,$charsIn)"> <xsl:value-of select="concat(substring-before($stringIn,$charsIn),$charsOut)"/> <xsl:call-template name="replaceCharsInString"> <xsl:with-param name="stringIn" select="substring-after($stringIn,$charsIn)"/> <xsl:with-param name="charsIn" select="$charsIn"/> <xsl:with-param name="charsOut" select="$charsOut"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$stringIn"/> </xsl:otherwise> </xsl:choose> </xsl:template> Also please note that you are asking an HTML question, not an XSL question, really. - Mike _____________________________________________________________________________ mike j. brown, software engineer at | xml/xslt: http://skew.org/xml/ webb.net in denver, colorado, USA | personal: http://hyperreal.org/~mike/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Resolving Netscape 4.7, and I, Niranjan Perera | Thread | [xsl] character transformation, pos, Julie Mc Cabe |
Re: [xsl] translate function, Mike Brown | Date | Re: [xsl] What is the scope of temp, Wendell Piez |
Month |