cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Schmitt, Christian" <Christian.Schm...@Dresdner-Bank.com>
Subject [C2] xsp-attribute behaviour
Date Thu, 30 Nov 2000 13:23:54 GMT
Hi all,
please consider the following XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsp:page language="java"
	xmlns:xsp="http://apache.org/xsp">
  <my-root>
    <xsp:attribute name="attr">
      <xsp:expr>new String("something").toString()</xsp:expr>
    </xsp:attribute>
    <element>
      Should have no attribute
    </element>
  </my-root>
</xsp:page>

I was expecting something like this as output:

<?xml version="1.0"?>
<my-root attr="something">
  <element>
    Should have no attribute
  </element>
</my-root>

Instead I'm getting the attribute in <element> and <my-root> has no
attribute.
Here's a snippet from the generated source code:
  public void generate() throws SAXException, ProcessingException {
    try {
      this.contentHandler.startDocument();
      AttributesImpl xspAttr = new AttributesImpl();
      this.contentHandler.startPrefixMapping("xsp",
"http://apache.org/xsp");
      this.contentHandler.startElement("", "my-root", "my-root", xspAttr);
      xspAttr.clear();
      this.characters("\n    ");
      xspAttr.addAttribute("", "attr", "attr", "CDATA",
                           String.valueOf(new
String("something").toString()) + "");
      this.characters("\n    ");
      this.contentHandler.startPrefixMapping("xsp",
"http://apache.org/xsp");
      this.contentHandler.startElement("", "element", "element", xspAttr);
      xspAttr.clear();
      this.characters("\n      Should have no attribute\n    ");
      this.contentHandler.endElement("", "element", "element");
      this.contentHandler.endPrefixMapping("xsp");
      this.characters("\n  ");
      this.contentHandler.endElement("", "my-root", "my-root");
      this.contentHandler.endPrefixMapping("xsp");
      this.contentHandler.endDocument();
    } catch (Throwable t) {
      cocoonLogger.debug("xsp.xsl: handled developer exception: ", t);
      throw new ProcessingException(t.getMessage());
    }
  }

Mime
View raw message