You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Per Kreipke <pe...@onclave.com> on 2000/09/20 02:14:02 UTC

Request taglib...

Attached is some code to add missing functionality to the request taglib in
XSPRequestLibrary.java. It includes the following to return a node set of
all parameters.

public static Element getAllParameterValues(
	HttpServletRequest request,
	Document document
	) {
	String[] parameterNames = XSPRequestLibrary.getParameterNames(request);
	Element newElement =
document.createElement("request:all-parameter-values");

	for (int i = 0; i < parameterNames.length; i++) {
		Element paramElement = XSPRequestLibrary.getParameterValues(request,
parameterNames[i], document);
		newElement.appendChild(paramElement);
	}

	return(newElement);
}


It also includes additional functions which might make life easier and the
XML produced by the request taglib a little more terse for some
applications.

I'm sorry, I couldn't actually test a taglib snippet in request.xsl because
I haven't built my own taglibs yet. But it should look like somethign like
the following (string returns not allowed):

  <xsl:template match="request:get-all-parameter-values">
    <xsl:variable name="as">
      <xsl:call-template name="value-for-as">
        <xsl:with-param name="default" select="'node'"/>
      </xsl:call-template>
    </xsl:variable>

    <xsp:expr>
      <xsl:choose>
        <xsl:when test="$as = 'node'">
          XSPRequestLibrary.getAllParameterValues(
            request,
            document
          )
        </xsl:when>
      </xsl:choose>
    </xsp:expr>
  </xsl:template>

Hope this helps someone. It helped me get request params into my XSL style
sheets.

Per.