cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dumon Bruno <>
Subject [C2] XSP problems: xsp-request:default and quoteString
Date Mon, 23 Apr 2001 12:39:00 GMT
Some bugs/problems I discovered while working with XSP/Java (Cocoon2 cvs,
tomcat 3.3, linux, ibmjdk1.3):

in the org/apache/cocoon/components/language/markup/xsp/java/request.xsl
file, the following piece of xsl is used on multiple places:
  <xsl:when test="default">
     <xsl:call-template name="get-nested-content">
     <xsl:with-param name="content" select="xsp-request:default"/>

the test on the xsl:when should be "xsp-request:default" instead of just

Another, more important problem, is that in the XSPMarkupLanguage class, all
characters are replaced by escaped versions (e.g. a newline is replaced by
the string \n, a tab by \t). In some circumstances, this can cause the
generation of code like this:
myclass.methocall("hello", this.characters("\n\t\t   ");
which of course doesn't compile. (this can occur when e.g. the second
parameter is generated by a nested xsp-tag which is put on a new line in the
xsp file)

To fix this, I added a check to see if the characters are all whitespace. If
they are, I don't quote them or pass them on. The characters method in now looks like (note the added isWhiteSpace

public void characters(char[] ch, int start, int length) throws SAXException
  String[] tag = (String[]) stack.peek();
  String tagName = tag[2];
  if (
    tagName.equals("xsp:expr") ||
    tagName.equals("xsp:logic") ||
    tagName.equals("xsp:structure") ||
   ) {
    super.characters(ch, start, length);
   } else {
     // check if it's not all whitespace
     if (isWhiteSpace(ch, start, length))
    // Quote the string depending on the programming language
    String value = this.language.quoteString(String.valueOf(ch, start,
    // Create a new element <xsp:text that wrap the quoted PCDATA
    super.startElement(Constants.XSP_URI, "text", "xsp:text", new
AttributesImpl() );
    super.characters(value.toCharArray(), 0, value.length());
    super.endElement(Constants.XSP_URI, "text", "xsp:text");
public boolean isWhiteSpace(char[] ch, int start, int length)
  boolean all = true;
  for (int i = start; i < start + length; i++)
    switch (ch[i])
     case ' ':
     case '\t':
     case '\n':
        all = false;
  return all;

To unsubscribe, e-mail:
For additional commands, email:

View raw message