cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Collins" <scoll...@fastmail.fm>
Subject DOMStreamer namespace problems
Date Wed, 14 Apr 2004 12:44:28 GMT
Hi all,

I was having a problem with Cocoon Forms down where I was losing the
namespace prefix mapping declaration on the root element when I saved the
form contents to a DOM document and then serialized that out to an XML
file.

I've found a workaround for now but there seems to be a bug somewhere. It
doesn't appear to be a forms related issue but rather one with
org.apache.cocoon.xml.DOMStreamer which is used like this in my code (and
in the Form GUI Cocoon sample):

-- snip --

var source = null;
var resolver = null;
var outputStream = null;
  try {
    resolver =
    cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
    source = resolver.resolveURI(uri);
    var tf =
    Packages.javax.xml.transform.TransformerFactory.newInstance();

    if (source instanceof
    Packages.org.apache.excalibur.source.ModifiableSource
     &&
     tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE))
     {

       outputStream = source.getOutputStream();
       var transformerHandler = tf.newTransformerHandler();
       var transformer = transformerHandler.getTransformer();
       transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT,
       "true");
       transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD,
       "xml");
       transformerHandler.setResult(new
       Packages.javax.xml.transform.stream.StreamResult(outputStream));

       var streamer = new
       Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);

       streamer.stream(document);

-- snip --

By default, DOMStreamer uses the NamespaceNormalizingDOMStreamer inner
class to write out SAX events. If I turn this off with

streamer.setNormalizeNamespaces(false);

then it uses DefaultDOMStreamer and the document is correctly written out
with the namespace declaration added.

>From a bit of debugging it seems like NamespaceNormalizingDOMStreamer is
spitting out the correct SAX events but for some reason they're not
making it into to the output XML.

If you want to try and replicate the problem just use the Cocoon Forms
GUI Builder sample and submit the form. Then look at
forms/form_model_gui_data-result.xml. The namespace declaration for
prefix "fd" should be missing on the root element.

I'm using Apache Tomcat/4.1.27, JDK 1.4.2_04-b05 with the nightly build
of 2.1.5 for 6/4/04.

Anyone got any ideas as to why this might be happening?

cheers,

Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message