Subject: Re: [xsl] Embedding HTML in JSP From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 5 Apr 2001 18:12:37 +0100 |
Hi Amit, Welcome to the list. > Trying to output : > <input type="hidden" name="ProductID" > value="<%=request.getParameter(\"productid\")%>"> > the \ act as the escape characters. Unfortunately (but perhaps unsurprisingly), XSLT processors don't understand JSP. As far as an XSLT processor is concerned - in fact, as far as an XML parser or an HTML browser's concerned - the above syntax is illegal, because they don't recognise \ as an escape character and therefore think that you close the attribute with the first ". In fact, I'm very surprised that you managed to get a processor to output: <input type="hidden" name="ProductID" value="<%=request.getParameter(\"productid\")%>"> as again, this is non-well-formed XML/HTML - less than signs should be escaped with entities in XML/HTML to give: <input type="hidden" name="ProductID" value="<%=request.getParameter(\"productid\")%>"> I think you're probably viewing the output in something like IE that automatically unescapes the less-than sign for the view - have a look at the raw source in a basic text editor to see what's really there. Mainly, processors output attribute values using double quotes. Hence, they have to escape double quotes in the attribute values using " to keep it legal. So if you can, I suggest that you change the JSP to use single quotes rather than double quotes. Just give: <input type="hidden" name="ProductID" value="<%=request.getParameter(\'productid\')%>" /> in the stylesheet - there's no need to use xsl:element. Here, the processor doesn't need to escape the single quotes (although it legally can, just as it can legally escape any character in the attribute value). This will not get around the fact that you get an escaped less-than sign in the output. If you absolutely want the string: <input type="hidden" name="ProductID" value="<%=request.getParameter(\"productid\")%>"> Then the only way to get it is to disable output escaping and construct the entire element as text (you can't disable output escaping for an attribute value): <xsl:text disable-output-escaping="yes"> <input type="hidden" name="ProductID" value="<%=request.getParameter(\"productid\")%>"> </xsl:text> This will only work in processors that support disabling output escaping, but I think most of them do. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Embedding HTML in JSP, Amit Khare | Thread | Re: [xsl] Copying only attributes, , Oliver Becker |
Re: [xsl] case insensitive attribut, David Carlisle | Date | RE: [xsl] XSL vs. JSP, anupama |
Month |