Hi,
I tried Cocoon 2.1 with the latest Resin Servlet Container.
Problem:
com.caucho.xml.QDOMException:
`null:' is an invalid XML name because the local name is empty.
XML names must be `prefix:name' or simply `name'.
at com.caucho.xml.QName.init(QName.java:102)
[...]
at com.caucho.xml.DOMBuilder.startElement(DOMBuilder.java:287)
at
org.apache.cocoon.serialization.AbstractTextSerializer.needsNamespacesAsAttributes(AbstractTextSerializer.java:341)
The current implementation does use an empty string as qualified
name and is missing a call to endElement():
// Output a single element
handler.startDocument();
handler.startPrefixMapping(prefix, uri);
handler.startElement(uri, "element", "", new AttributesImpl());
handler.endPrefixMapping(prefix);
handler.endDocument();
AbstractTextSerializer.needsNamespace could be changed as follows:
String uri = "namespaceuri";
String prefix = "nsp";
String check = "xmlns:" + prefix + "='" + uri + "'";
String localName="element";
String qName= prefix+":"+localName;
[...]
// Output a single element
handler.startDocument();
handler.startPrefixMapping(prefix, uri);
handler.startElement(uri, localName, qName, new
org.xml.sax.helpers.AttributesImpl());
handler.endElement(uri, localName, qName);
handler.endPrefixMapping(prefix);
handler.endDocument();
I tried this code with the Resin Transformer and Xalan. It correctly
detects the two cases without errors.
What do you think?
Regards,
Thomas