[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How do you set the action attribute for an HTML fo

Subject: Re: How do you set the action attribute for an HTML form usingXSLT?
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 31 Mar 2003 17:10:32 -0700 (MST)
action attribute
Ricardo Castillo wrote:
> Hi.  I'm trying to transform XML into an HTML/JSP page.

Unfortunately, JSP is not HTML. When you rely on the XSLT processor to
serialize the result tree in HTML syntax, it's going to make conservative
decisions as to how to make abstract elements, attributes, and character data
manifest as encoded text with embedded markup. The HTML it produces is
intended to be processed by a conforming HTML user agent. A JSP engine is not
such an agent.

The serializer does know that certain HTML attributes are subject to different
kinds of formatting, but it has no way of knowing that instead of one of the
standard types of attribute values, you want to insert a completely unescaped
JSP tag.

> I've followed the suggestion at http://www.dpawson.co.uk/xsl/sect2/N1553.html#d1670e229
> 
> using:
> 
> <xsl:attribute name="action" saxon:disable-output-escaping="yes" xmlns:saxon="http://icl.com/saxon">
>   <xsl:text>&lt;&#37;&#61;request.getRequestURI()&#37;&gt;</xsl:text>
> </xsl:attribute>
>
> [...]
>
> This is what I get:
> 
>   <form method="get" action="<%25=request.getRequestURI()%25>">
>
> And of course I'd like:
> 
>   <form method="get" action="<%=request.getRequestURI()%>">

Ordinarily that method would work, but the "action" attribute of an HTML form
element is one of those special attributes that is supposed to be a URI
reference, so the serializer, thinking it is helping you produce a proper
value, is turning "%" into "%25". This behavior is not required by the XSLT
spec except for non-ASCII characters, and IMHO it should not be happening at
all (e.g., what if you already had properly escaped such characters in your
URI?)

So I would call this a bug in Saxon. saxon:disable-output-escaping="yes"
should, IMHO, disable *all* escaping.

> <xsl:attribute name="action">
>   <xsl:text disable-output-escaping="yes">&lt;&#37;&#61;request.getRequestURI()&#37;&gt;</xsl:text>
> </xsl:attribute>

That method would definitely not work because xsl:attribute discards the text
nodes that were created in its content and only uses their encapsulated text.
Escaping only happens at serialization time. The d-o-e flag indicates you'd
prefer the serializer to not escape a text node's encapsulated text upon
output, but that only applies to the serialization of the text node; it
doesn't change the node's encapsulated text at all.

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.