cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@locus.apache.org
Subject cvs commit: xml-cocoon/src/resources/libraries/java base-library.xsl context.xsl cookie.xsl global.xsl request.xsl response.xsl session.xsl util.xsl
Date Wed, 05 Jan 2000 16:09:16 GMT
stefano     00/01/05 08:09:16

  Added:       src/resources/libraries/java base-library.xsl context.xsl
                        cookie.xsl global.xsl request.xsl response.xsl
                        session.xsl util.xsl
  Log:
  this new location gets automatically copied over into the jar file by Ant
  
  Revision  Changes    Path
  1.1                  xml-cocoon/src/resources/libraries/java/base-library.xsl
  
  Index: base-library.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
  >
    <!-- Default copy-over's -->
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
    </xsl:template>
  
    <!-- *** Utility Templates *** -->
    <!-- Retrieve "name" parameter as either attribute or element -->
    <xsl:template name="value-for-name">
      <xsl:choose>
        <!-- As attribute (String constant) -->
        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
        <!-- As nested (presumably dynamic) element -->
        <xsl:when test="name">
          <!-- Recursively evaluate nested expression -->
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="name"/>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>
  
    <!-- Return nested element content as expression or constant -->
    <xsl:template name="get-nested-content">
      <xsl:choose>
        <!-- Nested element -->
        <xsl:when test="$content/*">
          <xsl:apply-templates select="$content/*"/>
        </xsl:when>
        <!-- Plain Text -->
        <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <!-- Ensure attribute "as" has a value -->
    <xsl:template name="value-for-as">
      <xsl:choose>
        <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  
    <!-- Default xsp:page preprocessing -->
    <!--
    <xsl:template match="xsp:page">
      <xsp:page>
        <xsl:copy>
          <xsl:apply-templates select="@*"/>
        </xsl:copy>
  
        <xsl:apply-templates/>
  
      </xsp:page>
    </xsl:template>
    -->
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon/src/resources/libraries/java/context.xsl
  
  Index: context.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
    xmlns:context="http://apache.org/DTD/XSP/context"
  >
    <!-- *** ServletContext Templates *** -->
  
    <!-- Import Global XSP Templates -->
    <!-- <xsl:import href="base-library.xsl"/> -->
    <!-- Default copy-over's -->
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
    </xsl:template>
  
    <!-- *** Utility Templates *** -->
    <!-- Retrieve "name" parameter as either attribute or element -->
    <xsl:template name="value-for-name">
      <xsl:choose>
        <!-- As attribute (String constant) -->
        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
        <!-- As nested (presumably dynamic) element -->
        <xsl:when test="name">
          <!-- Recursively evaluate nested expression -->
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="name"/>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>
  
    <!-- Return nested element content as expression or constant -->
    <xsl:template name="get-nested-content">
      <xsl:choose>
        <!-- Nested element -->
        <xsl:when test="$content/*">
          <xsl:apply-templates select="$content/*"/>
        </xsl:when>
        <!-- Plain Text -->
        <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <!-- Ensure attribute "as" has a value -->
    <xsl:template name="value-for-as">
      <xsl:choose>
        <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  
    <!-- context.getAttribute -->
    <xsl:template match="context:get-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getAttribute(
              servletContext,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            XSPContextLibrary.getAttribute(
              servletContext,
              String.valueOf(<xsl:copy-of select="$name"/>)
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getAttributeNames -->
    <xsl:template match="context:get-attribute-names">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getAttributeNames(servletContext, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPContextLibrary.getAttributeNames(servletContext)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getInitParameter -->
    <xsl:template match="context:get-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getInitParameter(
              servletContext,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            XSPContextLibrary.getInitParameter(
              servletContext,
              String.valueOf(<xsl:copy-of select="$name"/>)
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getInitParameterNames -->
    <xsl:template match="context:get-attribute-names">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getInitParameterNames(servletContext, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPContextLibrary.getInitParameterNames(servletContext)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getMajorVersion -->
    <xsl:template match="context:get-major-version">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'int'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getMajorVersion(
              servletContext,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(
              servletContext.getMajorVersion()
            )
          </xsl:when>
          <xsl:when test="$as = 'int'">
            servletContext.getMajorVersion()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getMimeType -->
    <xsl:template match="context:get-mime-type">
      <!-- Get "file" parameter as either attribute or nested element -->
      <xsl:variable name="file">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@file">"<xsl:value-of select="@file"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="file">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="file"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getMimeType(
              servletContext,
              <xsl:copy-of select="$file"/>,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            servletContext.getMimeType(
              <xsl:copy-of select="$file"/>
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getMinorVersion -->
    <xsl:template match="context:get-minor-version">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'int'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getMinorVersion(
              servletContext,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(
              servletContext.getMinorVersion()
            )
          </xsl:when>
          <xsl:when test="$as = 'int'">
            servletContext.getMinorVersion()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getRealPath -->
    <xsl:template match="context:get-real-path">
      <!-- Get "path" parameter as either attribute or nested element -->
      <xsl:variable name="path">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@path">"<xsl:value-of select="@path"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="path">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="path"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getRealPath(
              servletContext,
              <xsl:copy-of select="$path"/>,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            servletContext.getRealPath(
              <xsl:copy-of select="$path"/>
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getResource -->
    <xsl:template match="context:get-resource">
      <!-- Get "path" parameter as either attribute or nested element -->
      <xsl:variable name="path">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@path">"<xsl:value-of select="@path"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="path">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="path"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:expr>
        servletContext.getResource(
          <xsl:copy-of select="$path"/>
        )
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getResourceAsStream -->
    <xsl:template match="context:get-resource-as-stream">
      <!-- Get "path" parameter as either attribute or nested element -->
      <xsl:variable name="path">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@path">"<xsl:value-of select="@path"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="path">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="path"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:expr>
        servletContext.getResourceAsStream(
          <xsl:copy-of select="$path"/>
        )
      </xsp:expr>
    </xsl:template>
  
    <!-- context.getServerInfo -->
    <xsl:template match="context:get-server-info">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPContextLibrary.getServerInfo(
              servletContext,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            servletContext.getServerInfo()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- context.log -->
    <xsl:template match="context:log">
      <!-- Get "message" parameter as either attribute or nested element -->
      <xsl:variable name="message">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@message">"<xsl:value-of select="@message"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="message">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="message"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        servletContext.log(
          String.valueOf(<xsl:copy-of select="$message"/>)
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- context.removeAttribute -->
    <xsl:template match="context:remove-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <xsp:logic>
        servletContext.removeAttribute(
          String.valueOf(<xsl:copy-of select="$name"/>)
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- context.setAttribute -->
    <xsl:template match="context:set-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Recursively evaluate nested attribute value -->
      <xsl:variable name="content">
        <xsl:call-template name="get-nested-content">
          <xsl:with-param name="content">
            <content><xsl:apply-templates/></content>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:logic>
        servletContext.setAttribute(
          String.valueOf(<xsl:copy-of select="$name"/>),
          <xsl:copy-of select="$content"/>
        );
      </xsp:logic>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon/src/resources/libraries/java/cookie.xsl
  
  Index: cookie.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
    xmlns:cookie="http://apache.org/DTD/XSP/cookie"
  >
    <!-- *** Cookie Templates *** -->
  
    <!-- Import Global XSP Templates -->
    <!-- <xsl:import href="base-library.xsl"/> -->
    <!-- Default copy-over's -->
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
    </xsl:template>
  
    <!-- *** Utility Templates *** -->
    <!-- Retrieve "name" parameter as either attribute or element -->
    <xsl:template name="value-for-name">
      <xsl:choose>
        <!-- As attribute (String constant) -->
        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
        <!-- As nested (presumably dynamic) element -->
        <xsl:when test="name">
          <!-- Recursively evaluate nested expression -->
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="name"/>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>
  
    <!-- Return nested element content as expression or constant -->
    <xsl:template name="get-nested-content">
      <xsl:choose>
        <!-- Nested element -->
        <xsl:when test="$content/*">
          <xsl:apply-templates select="$content/*"/>
        </xsl:when>
        <!-- Plain Text -->
        <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <!-- Ensure attribute "as" has a value -->
    <xsl:template name="value-for-as">
      <xsl:choose>
        <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  
    <!-- cookie.clone -->
    <xsl:template match="cookie:clone">
      <xsp:expr>
        cookie.clone()
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.getComment -->
    <xsl:template match="cookie:get-comment">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getComment(
              cookie,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            cookie.getComment()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.getDomain -->
    <xsl:template match="cookie:get-domain">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getDomain(
              cookie,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            cookie.getDomain()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.getMaxAge -->
    <xsl:template match="cookie:get-max-age">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'int'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getMaxAge(
              cookie,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(cookie.getMaxAge())
          </xsl:when>
          <xsl:when test="$as = 'int'">
            cookie.getMaxAge()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.getName -->
    <xsl:template match="cookie:get-name">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getName(
              cookie,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            cookie.getName()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.getPath -->
    <xsl:template match="cookie:get-path">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getPath(
              cookie,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            cookie.getPath()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.getSecure -->
    <xsl:template match="cookie:get-secure">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'boolean'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getSecure(
              cookie,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(cookie.getSecure())
          </xsl:when>
          <xsl:when test="$as = 'boolean'">
            cookie.getSecure()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.getValue -->
    <xsl:template match="cookie:get-value">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getValue(
              cookie,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            cookie.getValue()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.getVersion -->
    <xsl:template match="cookie:get-version">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'int'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getVersion(
              cookie,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(cookie.getVersion())
          </xsl:when>
          <xsl:when test="$as = 'int'">
            cookie.getVersion()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- cookie.setComment -->
    <xsl:template match="cookie:set-comment">
      <!-- Get "purpose" parameter as either attribute or nested element -->
      <xsl:variable name="purpose">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@purpose">"<xsl:value-of select="@purpose"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="purpose">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="purpose"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        cookie.setComment(
          String.valueOf(
            <xsl:copy-of select="$purpose"/>
          )
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- cookie.setDomain -->
    <xsl:template match="cookie:set-domain">
      <!-- Get "pattern" parameter as either attribute or nested element -->
      <xsl:variable name="pattern">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@pattern">"<xsl:value-of select="@pattern"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="pattern">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="pattern"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        cookie.setDomain(
          String.valueOf(
            <xsl:copy-of select="$pattern"/>
          )
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- cookie.setMaxAge -->
    <xsl:template match="cookie:set-max-age">
      <!-- Get "expiry" parameter as either attribute or nested element -->
      <xsl:variable name="expiry">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@expiry">"<xsl:value-of select="@expiry"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="expiry">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="expiry"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        cookie.setMaxAge(
          Integer.ParseInt(
            String.valueOf(
              <xsl:copy-of select="$expiry"/>
            )
          )
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- cookie.setPath -->
    <xsl:template match="cookie:set-path">
      <!-- Get "path" parameter as either attribute or nested element -->
      <xsl:variable name="path">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@path">"<xsl:value-of select="@path"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="path">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="path"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        cookie.setPath(
          String.valueOf(
            <xsl:copy-of select="$path"/>
          )
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- cookie.setSecure -->
    <xsl:template match="cookie:set-secure">
      <!-- Get "flag" parameter as either attribute or nested element -->
      <xsl:variable name="flag">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@flag">"<xsl:value-of select="@flag"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="flag">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="flag"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        cookie.setSecure(
          new Boolean(
            String.valueOf(
              <xsl:copy-of select="$flag"/>
            )
          ).booleanValue()
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- cookie.setValue -->
    <xsl:template match="cookie:set-value">
      <!-- Get "new-value" parameter as either attribute or nested element -->
      <xsl:variable name="new-value">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@new-value">"<xsl:value-of select="@new-value"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="new-value">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="new-value"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        cookie.setValue(
          String.valueOf(
            <xsl:copy-of select="$new-value"/>
          )
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- cookie.setVersion -->
    <xsl:template match="cookie:set-version">
      <!-- Get "value" parameter as either attribute or nested element -->
      <xsl:variable name="value">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="value">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="value"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        cookie.setVersion(
          Integer.ParseInt(
            String.valueOf(
              <xsl:copy-of select="$value"/>
            )
          )
        );
      </xsp:logic>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon/src/resources/libraries/java/global.xsl
  
  Index: global.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
    xmlns:global="http://apache.org/DTD/XSP/global"
  >
    <!-- *** XSPGlobal Templates *** -->
  
    <!-- Import Global XSP Templates -->
    <!-- <xsl:import href="base-library.xsl"/> -->
    <!-- Default copy-over's -->
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
    </xsl:template>
  
    <!-- *** Utility Templates *** -->
    <!-- Retrieve "name" parameter as either attribute or element -->
    <xsl:template name="value-for-name">
      <xsl:choose>
        <!-- As attribute (String constant) -->
        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
        <!-- As nested (presumably dynamic) element -->
        <xsl:when test="name">
          <!-- Recursively evaluate nested expression -->
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="name"/>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>
  
    <!-- Return nested element content as expression or constant -->
    <xsl:template name="get-nested-content">
      <xsl:choose>
        <!-- Nested element -->
        <xsl:when test="$content/*">
          <xsl:apply-templates select="$content/*"/>
        </xsl:when>
        <!-- Plain Text -->
        <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <!-- Ensure attribute "as" has a value -->
    <xsl:template name="value-for-as">
      <xsl:choose>
        <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  
    <!-- global.getAttribute -->
    <xsl:template match="global:get-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPGlobalLibrary.getAttribute(
              global,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            XSPGlobalLibrary.getAttribute(
              global,
              String.valueOf(<xsl:copy-of select="$name"/>)
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- global.getAttributeNames -->
    <xsl:template match="global:get-attribute-names">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPGlobalLibrary.getAttributeNames(global, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPGlobalLibrary.getAttributeNames(global)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- global.removeAttribute -->
    <xsl:template match="global:remove-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <xsp:logic>
        global.removeAttribute(
          String.valueOf(<xsl:copy-of select="$name"/>)
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- global.setAttribute -->
    <xsl:template match="global:set-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Recursively evaluate nested attribute value -->
      <xsl:variable name="content">
        <xsl:call-template name="get-nested-content">
          <xsl:with-param name="content">
            <content><xsl:apply-templates/></content>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:logic>
        global.setAttribute(
          String.valueOf(<xsl:copy-of select="$name"/>),
          <xsl:copy-of select="$content"/>
        );
      </xsp:logic>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon/src/resources/libraries/java/request.xsl
  
  Index: request.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
    xmlns:request="http://apache.org/DTD/XSP/request"
  >
    <!-- *** ServletRequest Templates *** -->
  
    <!-- Import Global XSP Templates -->
    <!-- <xsl:import href="base-library.xsl"/> -->
    <!-- Default copy-over's -->
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
    </xsl:template>
  
    <!-- *** Utility Templates *** -->
    <!-- Retrieve "name" parameter as either attribute or element -->
    <xsl:template name="value-for-name">
      <xsl:choose>
        <!-- As attribute (String constant) -->
        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
        <!-- As nested (presumably dynamic) element -->
        <xsl:when test="name">
          <!-- Recursively evaluate nested expression -->
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="name"/>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>
  
    <!-- Return nested element content as expression or constant -->
    <xsl:template name="get-nested-content">
      <xsl:choose>
        <!-- Nested element -->
        <xsl:when test="$content/*">
          <xsl:apply-templates select="$content/*"/>
        </xsl:when>
        <!-- Plain Text -->
        <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <!-- Ensure attribute "as" has a value -->
    <xsl:template name="value-for-as">
      <xsl:choose>
        <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  
    <!-- request.getAttribute -->
    <xsl:template match="request:get-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getAttribute(
              request,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            XSPRequestLibrary.getAttribute(
  	    request,
              String.valueOf(<xsl:copy-of select="$name"/>)
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getAttributeNames -->
    <xsl:template match="request:get-attribute-names">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getAttributeNames(request, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPRequestLibrary.getAttributeNames(request)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getCharacterEncoding -->
    <xsl:template match="request:get-character-encoding">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getCharacterEncoding(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getCharacterEncoding()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getContentLength -->
    <xsl:template match="request:get-content-length">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'int'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getContentLength(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(request.getContentLength())
          </xsl:when>
          <xsl:when test="$as = 'int'">
            request.getContentLength()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getContentType -->
    <xsl:template match="request:get-content-type">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getContentType(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getContentType()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getLocale -->
    <xsl:template match="request:get-locale">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'object'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getLocale(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getLocale(request).toString()
          </xsl:when>
          <xsl:when test="$as = 'object'">
            request.getLocale(request)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getLocales -->
    <xsl:template match="request:get-locales">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getLocales(request, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPRequestLibrary.getLocales(request)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getParameter -->
    <xsl:template match="request:get-parameter">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getParameter(
              request,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getParameter(String.valueOf(<xsl:copy-of select="$name"/>))
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getParameterNames -->
    <xsl:template match="request:get-parameter-names">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getParameterNames(request, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPRequestLibrary.getParameterNames(request)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getParameterValues -->
    <xsl:template match="request:get-parameter-values">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getParameterValues(
              request,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'array'">
            request.getParameterValues(
  	    String.valueOf(<xsl:copy-of select="$name"/>)
  	  )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getProtocol -->
    <xsl:template match="request:get-protocol">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getProtocol(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getProtocol()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getRemoteAddr -->
    <xsl:template match="request:get-remote-addr">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getRemoteAddr(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getRemoteAddr()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getRemoteHost -->
    <xsl:template match="request:get-remote-host">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getRemoteHost(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getRemoteHost()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getScheme -->
    <xsl:template match="request:get-scheme">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getScheme(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getScheme()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
  
    <!-- request.getServerPort -->
    <xsl:template match="request:get-server-port">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'int'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getServerPort(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(request.getServerPort())
          </xsl:when>
          <xsl:when test="$as = 'int'">
            request.getServerPort()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.isSecure -->
    <xsl:template match="request:is-secure">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'boolean'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.isSecure(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(request.isSecure())
          </xsl:when>
          <xsl:when test="$as = 'boolean'">
            request.isSecure()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.removeAttribute -->
    <xsl:template match="request:remove-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <xsp:logic>
        request.removeAttribute(
          String.valueOf(<xsl:copy-of select="$name"/>)
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- request.setAttribute -->
    <xsl:template match="request:set-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Recursively evaluate nested attribute value -->
      <xsl:variable name="content">
        <xsl:call-template name="get-nested-content">
          <xsl:with-param name="content">
            <content><xsl:apply-templates/></content>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:logic>
        request.setAttribute(
          String.valueOf(<xsl:copy-of select="$name"/>),
          <xsl:copy-of select="$content"/>
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- request.getMethod -->
    <xsl:template match="request:get-method">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getMethod(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getMethod()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getPathInfo -->
    <xsl:template match="request:get-path-info">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getPathInfo(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getPathInfo()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getPathTranslated -->
    <xsl:template match="request:get-path-translated">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getPathTranslated(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getPathTranslated()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getQueryString -->
    <xsl:template match="request:get-query-string">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getQueryString(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getQueryString()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getRemoteUser -->
    <xsl:template match="request:get-remote-user">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getRemoteUser(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getRemoteUser()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getRequestedSessionId -->
    <xsl:template match="request:get-requested-session-id">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getRequestedSessionId(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getRequestedSessionId()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getRequestURI -->
    <xsl:template match="request:get-request-uri">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getRequestURI(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getRequestURI()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getServletPath -->
    <xsl:template match="request:get-servlet-path">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getServletPath(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getServletPath()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getUserPrincipal -->
    <xsl:template match="request:get-user-principal">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'object'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getUserPrincipal(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(request.getUserPrincipal())
          </xsl:when>
          <xsl:when test="$as = 'object'">
            request.getUserPrincipal()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- *** HttpServletRequest *** -->
  
    <!-- request.getAuthType -->
    <xsl:template match="request:get-auth-type">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getAuthType(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getAuthType()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getContextPath -->
    <xsl:template match="request:get-context-path">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getContextPath(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getContextPath()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getCookies -->
    <xsl:template match="request:get-cookies">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getCookies(request, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            request.getCookies()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getDateHeader -->
    <xsl:template match="request:get-date-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'long'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <!-- Get "format" parameter as either attribute or nested element -->
      <xsl:variable name="format">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@format">"<xsl:value-of select="@format"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="format">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="format"/>
            </xsl:call-template>
          </xsl:when>
  	<xsl:otherwise>null</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getDateHeader(
              request,
              String.valueOf(<xsl:copy-of select="$name"/>),
              <xsl:copy-of select="$format"/>,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            XSPUtil.formatDate (
              new Date(
                request.getDateHeader(
                  String.valueOf(
  		  String.valueOf(<xsl:copy-of select="$name"/>)
  		)
                )
              ),
              <xsl:copy-of select="$format"/>
            )
          </xsl:when>
          <xsl:when test="$as = 'date'">
            new Date(
              request.getDateHeader(
                String.valueOf(<xsl:copy-of select="$name"/>)
              )
            )
          </xsl:when>
          <xsl:when test="$as = 'long'">
            request.getDateHeader(
              String.valueOf(<xsl:copy-of select="$name"/>)
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getHeader -->
    <xsl:template match="request:get-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getHeader(
              request,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            request.getHeader(String.valueOf(<xsl:copy-of select="$name"/>))
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getHeaderNames -->
    <xsl:template match="request:get-header-names">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getHeaderNames(request, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPRequestLibrary.getHeaderNames(request)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getHeaders -->
    <xsl:template match="request:get-headers">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getHeaders(
              request,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPRequestLibrary.getHeaders(
              request,
              String.valueOf(<xsl:copy-of select="$name"/>),
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- request.getIntHeader -->
    <xsl:template match="request:get-int-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'int'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getIntHeader(
              request,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.ValueOf(
                request.getIntHeader(
                  String.valueOf(<xsl:copy-of select="$name"/>)
              )
            )
          </xsl:when>
          <xsl:when test="$as = 'int'">
            request.getIntHeader(
              String.valueOf(<xsl:copy-of select="$name"/>)
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
   
    <!-- request.isRequestedSessionIdFromCookie -->
    <xsl:template match="request:is-requested-session-id-from-cookie">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'boolean'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.isRequestedSessionIdFromCookie(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(request.isRequestedSessionIdFromCookie())
          </xsl:when>
          <xsl:when test="$as = 'boolean'">
            request.isRequestedSessionIdFromCookie()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
   
    <!-- request.isRequestedSessionIdFromURL -->
    <xsl:template match="request:is-requested-session-id-from-url">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'boolean'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.isRequestedSessionIdFromURL(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(request.isRequestedSessionIdFromURL())
          </xsl:when>
          <xsl:when test="$as = 'boolean'">
            request.isRequestedSessionIdFromURL()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
   
    <!-- request.isRequestedSessionIdValid -->
    <xsl:template match="request:is-requested-session-id-valid">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'boolean'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.isRequestedSessionIdValid(request, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(request.isRequestedSessionIdValid())
          </xsl:when>
          <xsl:when test="$as = 'boolean'">
            request.isRequestedSessionIdValid()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
   
    <!-- request.isUserInRole -->
    <xsl:template match="request:is-user-in-role">
      <!-- Get "role" parameter as either attribute or nested element -->
      <xsl:variable name="role">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@role">"<xsl:value-of select="@role"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="role">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="role"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'boolean'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.isUserInRole(
              request,
              String.valueOf(<xsl:copy-of select="$role"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(
              request.isUserInRole(
                String.valueOf(<xsl:copy-of select="$role"/>),
              )
            )
          </xsl:when>
          <xsl:when test="$as = 'boolean'">
            request.isUserInRole(
              String.valueOf(<xsl:copy-of select="$role"/>),
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon/src/resources/libraries/java/response.xsl
  
  Index: response.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
    xmlns:response="http://apache.org/DTD/XSP/response"
  >
    <!-- *** ServletResponse Templates *** -->
  
    <!-- Import Global XSP Templates -->
    <!-- <xsl:import href="base-library.xsl"/> -->
    <!-- Default copy-over's -->
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
    </xsl:template>
  
    <!-- *** Utility Templates *** -->
    <!-- Retrieve "name" parameter as either attribute or element -->
    <xsl:template name="value-for-name">
      <xsl:choose>
        <!-- As attribute (String constant) -->
        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
        <!-- As nested (presumably dynamic) element -->
        <xsl:when test="name">
          <!-- Recursively evaluate nested expression -->
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="name"/>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>
  
    <!-- Return nested element content as expression or constant -->
    <xsl:template name="get-nested-content">
      <xsl:choose>
        <!-- Nested element -->
        <xsl:when test="$content/*">
          <xsl:apply-templates select="$content/*"/>
        </xsl:when>
        <!-- Plain Text -->
        <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <!-- Ensure attribute "as" has a value -->
    <xsl:template name="value-for-as">
      <xsl:choose>
        <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  
    <!-- response.getCharacterEncoding -->
    <xsl:template match="response:get-character-encoding">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getCharacterEncoding(response, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            response.getCharacterEncoding()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
  
    <!-- response.getLocale -->
    <xsl:template match="response:get-locale">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'object'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPRequestLibrary.getLocale(response, document)
          </xsl:when>
          <xsl:when test="$as = 'string'">
            response.getLocale(response).toString()
          </xsl:when>
          <xsl:when test="$as = 'object'">
            response.getLocale(response)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- response.setContentType -->
    <xsl:template match="response:set-content-type">
      <!-- Get "type" parameter as either attribute or nested element -->
      <xsl:variable name="type">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@type">"<xsl:value-of select="@type"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="type">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="type"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        response.setContentType(
          String.valueOf(
            <xsl:copy-of select="$type"/>
  	)
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- response.setLocale -->
    <xsl:template match="response:set-locale">
      <xsp:logic>
        response.setLocale(
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="locale"/>
          </xsl:call-template>
        );
      </xsp:logic>
    </xsl:template>
  
  
    <!-- *** HttpServletResponse *** -->
  
    <!-- response.addCookie -->
    <xsl:template match="response:add-cookie">
      <xsp:logic>
        response.addCookie(
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="*[1]"/>
          </xsl:call-template>
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- response.addDateHeader -->
    <xsl:template match="response:add-date-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Get "date" parameter as either attribute or nested element -->
      <xsl:variable name="date">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@date">"<xsl:value-of select="@date"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="date">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="date"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <!-- Get "format" parameter as either attribute or nested element -->
      <!-- This optional parameter only applies for dates expressed as String -->
      <xsl:variable name="format">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@format">"<xsl:value-of select="@format"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="format">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="format"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        <xsl:choose>
          <xsl:when test="$format">
            XSPResponseLibrary.addDateHeader(
              response,
              String.valueOf(<xsl:copy-of select="$name"/>),
  	    String.valueOf(
                <xsl:call-template name="get-nested-content">
                  <xsl:with-param name="content" select="$date"/>
                </xsl:call-template>
  	    ),
  	    String.valueOf(<xsl:copy-of select="$format"/>)
            );
          </xsl:when>
          <xsl:otherwise>
            XSPResponseLibrary.addDateHeader(
              response,
              String.valueOf(<xsl:copy-of select="$name"/>),
              <xsl:call-template name="get-nested-content">
                <xsl:with-param name="content" select="$date"/>
              </xsl:call-template>
            );
          </xsl:otherwise>
        </xsl:choose>
      </xsp:logic>
    </xsl:template>
  
    <!-- response.addHeader -->
    <xsl:template match="response:add-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Get "value" parameter as either attribute or nested element -->
      <xsl:variable name="value">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="value">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="value"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        response.addHeader(
         String.valueOf(<xsl:copy-of select="$name"/>),
         String.valueOf(<xsl:copy-of select="$value"/>)
       );
      </xsp:logic>
    </xsl:template>
  
    <!-- response.addIntHeader -->
    <xsl:template match="response:add-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Get "value" parameter as either attribute or nested element -->
      <xsl:variable name="value">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="value">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="value"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        response.addIntHeader(
         String.valueOf(<xsl:copy-of select="$name"/>),
         Integer.parseInt(
           String.valueOf(<xsl:copy-of select="$value"/>)
         )
       );
      </xsp:logic>
    </xsl:template>
  
    <!-- response.containsHeader -->
    <xsl:template match="response:contains-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'boolean'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPResponseLibrary.containsHeader(
              response,
              String.valueOf(<xsl:copy-of select="$value"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(
              response.containsHeader(
                String.valueOf(<xsl:copy-of select="$value"/>),
              )
            )
          </xsl:when>
          <xsl:when test="$as = 'boolean'">
            response.containsHeader(
              String.valueOf(<xsl:copy-of select="$value"/>),
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- response.encodeRedirectURL -->
    <xsl:template match="response:encode-redirect-url">
      <!-- Get "url" parameter as either attribute or nested element -->
      <xsl:variable name="url">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@url">"<xsl:value-of select="@url"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="url">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="url"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPResponseLibrary.encodeRedirectURL(
              response,
              String.valueOf(<xsl:copy-of select="$url"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            response.encodeRedirectURL(
              String.valueOf(<xsl:copy-of select="$url"/>),
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- response.encodeURL -->
    <xsl:template match="response:encode-url">
      <!-- Get "url" parameter as either attribute or nested element -->
      <xsl:variable name="url">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@url">"<xsl:value-of select="@url"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="url">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="url"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:logic>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPResponseLibrary.encodeURL(
              response,
              String.valueOf(<xsl:copy-of select="$url"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            response.encodeURL(
              String.valueOf(<xsl:copy-of select="$url"/>),
            )
          </xsl:when>
        </xsl:choose>
      </xsp:logic>
    </xsl:template>
  
    <!-- response.sendRedirect -->
    <xsl:template match="response:send-redirect">
      <!-- Get "location" parameter as either attribute or nested element -->
      <xsl:variable name="location">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@location">"<xsl:value-of select="@location"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="location">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="location"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        response.sendRedirect(
         String.valueOf(<xsl:copy-of select="$location"/>)
       );
      </xsp:logic>
    </xsl:template>
  
    <!-- response.setDateHeader -->
    <xsl:template match="response:set-date-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Get "date" parameter as either attribute or nested element -->
      <xsl:variable name="date">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@date">"<xsl:value-of select="@date"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="date">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="date"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <!-- Get "format" parameter as either attribute or nested element -->
      <!-- This optional parameter only applies for dates expressed as String -->
      <xsl:variable name="format">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@format">"<xsl:value-of select="@format"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="format">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="format"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        <xsl:choose>
          <xsl:when test="$format">
            XSPResponseLibrary.setDateHeader(
              response,
              String.valueOf(<xsl:copy-of select="$name"/>),
  	    String.valueOf(
                <xsl:call-template name="get-nested-content">
                  <xsl:with-param name="content" select="$date"/>
                </xsl:call-template>
  	    ),
  	    String.valueOf(<xsl:copy-of select="$format"/>)
            );
          </xsl:when>
          <xsl:otherwise>
            XSPResponseLibrary.setDateHeader(
              response,
              String.valueOf(<xsl:copy-of select="$name"/>),
              <xsl:call-template name="get-nested-content">
                <xsl:with-param name="content" select="$date"/>
              </xsl:call-template>
            );
          </xsl:otherwise>
        </xsl:choose>
      </xsp:logic>
    </xsl:template>
  
    <!-- response.setHeader -->
    <xsl:template match="response:set-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Get "value" parameter as either attribute or nested element -->
      <xsl:variable name="value">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="value">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="value"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        response.setHeader(
         String.valueOf(<xsl:copy-of select="$name"/>),
         String.valueOf(<xsl:copy-of select="$value"/>)
       );
      </xsp:logic>
    </xsl:template>
  
    <!-- response.setIntHeader -->
    <xsl:template match="response:set-header">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Get "value" parameter as either attribute or nested element -->
      <xsl:variable name="value">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="value">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="value"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        response.setIntHeader(
         String.valueOf(<xsl:copy-of select="$name"/>),
         Integer.parseInt(
           String.valueOf(<xsl:copy-of select="$value"/>)
         )
       );
      </xsp:logic>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon/src/resources/libraries/java/session.xsl
  
  Index: session.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
    xmlns:session="http://apache.org/DTD/XSP/session"
  >
    <!-- *** ServletSession Templates *** -->
  
    <!-- Import Global XSP Templates -->
    <!-- <xsl:import href="base-library.xsl"/> -->
    <!-- Default copy-over's -->
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
    </xsl:template>
  
    <!-- *** Utility Templates *** -->
    <!-- Retrieve "name" parameter as either attribute or element -->
    <xsl:template name="value-for-name">
      <xsl:choose>
        <!-- As attribute (String constant) -->
        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
        <!-- As nested (presumably dynamic) element -->
        <xsl:when test="name">
          <!-- Recursively evaluate nested expression -->
          <xsl:call-template name="get-nested-content">
            <xsl:with-param name="content" select="name"/>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>
  
    <!-- Return nested element content as expression or constant -->
    <xsl:template name="get-nested-content">
      <xsl:choose>
        <!-- Nested element -->
        <xsl:when test="$content/*">
          <xsl:apply-templates select="$content/*"/>
        </xsl:when>
        <!-- Plain Text -->
        <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <!-- Ensure attribute "as" has a value -->
    <xsl:template name="value-for-as">
      <xsl:choose>
        <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  
    <!-- session.getAttribute -->
    <xsl:template match="session:get-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getAttribute(
              session,
              String.valueOf(<xsl:copy-of select="$name"/>),
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            XSPSessionLibrary.getAttribute(
              session,
              String.valueOf(<xsl:copy-of select="$name"/>)
            )
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- session.getAttributeNames -->
    <xsl:template match="session:get-attribute-names">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'array'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getAttributeNames(session, document)
          </xsl:when>
          <xsl:when test="$as = 'array'">
            XSPSessionLibrary.getAttributeNames(session)
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- session.getCreationTime -->
    <xsl:template match="session:get-creation-time">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'long'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getCreationTime(
              session,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(session.getCreationTime())
          </xsl:when>
          <xsl:when test="$as = 'long'">
            session.getCreationTime()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- session.getId -->
    <xsl:template match="session:get-id">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'string'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getId(
              session,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            session.getId()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- session.getLastAccessedTime -->
    <xsl:template match="session:get-last-accessed-time">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'long'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getLastAccessedTime(
              session,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(session.getLastAccessedTime())
          </xsl:when>
          <xsl:when test="$as = 'long'">
            session.getLastAccessedTime()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- session.getMaxInactiveInterval -->
    <xsl:template match="session:get-max-inactive-interval">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'int'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.getMaxInactiveInterval(
              session,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(session.getMaxInactiveInterval())
          </xsl:when>
          <xsl:when test="$as = 'int'">
            session.getMaxInactiveInterval()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- session.invalidate -->
    <xsl:template match="session:invalidate">
      <xsp:logic>
        session.invalidate()
      </xsp:logic>
    </xsl:template>
  
    <!-- session.isNew -->
    <xsl:template match="session:is-new">
      <!-- Ensure attribute "as" has a value -->
      <xsl:variable name="as">
        <xsl:call-template name="value-for-as">
          <xsl:with-param name="default" select="'boolean'"/>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:expr>
        <xsl:choose>
          <xsl:when test="$as = 'node'">
            XSPSessionLibrary.isNew(
              session,
              document
            )
          </xsl:when>
          <xsl:when test="$as = 'string'">
            String.valueOf(session.isNew())
          </xsl:when>
          <xsl:when test="$as = 'boolean'">
            session.isNew()
          </xsl:when>
        </xsl:choose>
      </xsp:expr>
    </xsl:template>
  
    <!-- session.removeAttribute -->
    <xsl:template match="session:remove-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <xsp:logic>
        session.removeAttribute(
          String.valueOf(<xsl:copy-of select="$name"/>)
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- session.setAttribute -->
    <xsl:template match="session:set-attribute">
      <!-- Get "name" parameter as either attribute or nested element -->
      <xsl:variable name="name">
        <xsl:call-template name="value-for-name"/>
      </xsl:variable>
  
      <!-- Recursively evaluate nested attribute value -->
      <xsl:variable name="content">
        <xsl:call-template name="get-nested-content">
          <xsl:with-param name="content">
            <content><xsl:apply-templates/></content>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>
  
      <xsp:logic>
        session.setAttribute(
          String.valueOf(<xsl:copy-of select="$name"/>),
          <xsl:copy-of select="$content"/>
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- session.setInactiveInterval -->
    <xsl:template match="session:set-max-inactive-interval">
      <!-- Get "interval" parameter as either attribute or nested element -->
      <xsl:variable name="interval">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@interval">"<xsl:value-of select="@interval"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="interval">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="interval"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic>
        session.setInactiveInterval(
          Integer.parseInt(
  	  String.valueOf(
  	    <xsl:copy-of select="$interval"/>
  	  )
  	)
        );
      </xsp:logic>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon/src/resources/libraries/java/util.xsl
  
  Index: util.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
    xmlns:util="http://www.plenix.com/dtd/xsp/util"
  >
    <xsl:template match="xsp:page">
      <xsp:page>
        <xsl:copy>
          <xsl:apply-templates select="@*"/>
        </xsl:copy>
  
        <xsp:structure>
          <xsp:include>java.net.URL</xsp:include>
          <xsp:include>java.util.Date</xsp:include>
          <xsp:include>java.text.SimpleDateFormat</xsp:include>
        </xsp:structure>
  
        <xsp:logic>
          /* Util Class Level */
  
          private static int count = 0;
          private static synchronized int getCount() {
            return ++count;
          }
          private static synchronized int getSessionCount(HttpSession session) {
            Integer integer = (Integer) session.getValue("util.counter");
            if (integer == null) {
              integer = new Integer(0);
            }
            int cnt = integer.intValue() + 1;
            session.putValue("util.counter", new Integer(cnt));
            return cnt;
          }
          private static String formatDate(Date date, String pattern) {
            if (pattern == null || pattern.length() == 0) {
              pattern = "yyyy/MM/dd hh:mm:ss aa";
            }
            return (new SimpleDateFormat(pattern)).format(date);
          }
        </xsp:logic>
  
        <xsl:apply-templates/>
      </xsp:page>
    </xsl:template>
  
    <xsl:template match="util:embed">
    <!-- Retrieve "uri" parameter as either attribute or element -->
      <xsl:variable name="uri">
        <xsl:choose>
          <!-- As attribute (String constant) -->
          <xsl:when test="@uri">"<xsl:value-of select="@uri"/>"</xsl:when>
          <!-- As nested (presumably dynamic) element -->
          <xsl:when test="util:uri">
            <!-- Recursively evaluate nested expression -->
            <xsl:call-template name="get-nested-content">
              <xsl:with-param name="content" select="util:uri"/>
            </xsl:call-template>
          </xsl:when>
        </xsl:choose>
      </xsl:variable>
  
      <xsp:logic> {
        String embedURI = String.valueOf(<xsl:copy-of select="$uri"/>);
  
        try {
          URL url = new URL(embedURI);
          InputSource is = new InputSource(url.openStream());
          is.setSystemId(url.toExternalForm());
  
          xspCurrentNode.appendChild(
            XSPUtil.cloneNode(
              this.xspParser.parse(is).getDocumentElement(),
              document
            )
          );
        } catch (Exception e) {
          xspCurrentNode.appendChild(
  	  document.createTextNode(
  	    "{" +
  	      "Unable to embed: " +
  	      embedURI +
  	    "}"
  	  )
  	);
        }
      } </xsp:logic>
    </xsl:template>
  
    <xsl:template match="util:counter">
      <xsl:choose>
        <xsl:when test="@scope = 'session'">
          <xsp:expr>getSessionCount(session)</xsp:expr>
        </xsl:when>
        <xsl:otherwise>
          <xsp:expr>getCount()</xsp:expr>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <xsl:template match="util:time">
      <xsp:expr>
        formatDate(new Date(), "<xsl:value-of select="@format"/>")
      </xsp:expr>
    </xsl:template>
  
    <xsl:template match="util:include">
      <xsp:logic>
        xspCurrentNode.appendChild(
          XSPUtil.cloneNode(
            this.xspParser.parse(
              new InputSource(
                new FileReader(
                  XSPUtil.relativeFilename(
                    "<xsl:value-of select="@file"/>",
                    request
                  )
                )
              )
            ).getDocumentElement(),
            document
          )
        );
      </xsp:logic>
    </xsl:template>
  
    <!-- Return nested element content as expression or constant -->
    <xsl:template name="get-nested-content">
      <xsl:choose>
        <!-- Nested element -->
        <xsl:when test="$content/*">
          <xsl:apply-templates select="$content/*"/>
        </xsl:when>
        <!-- Plain Text -->
        <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
    <!-- Default copy-over -->
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  

Mime
View raw message