On Wed, 2004-04-14 at 14:44, Simon Collins wrote:
> 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.

Note that JXPath (the XPath engine used by the binding framework)
doesn't support namespaces. I don't how it handles documents that
actually have namespaces.

> 
> 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 could somehow put the LogTransformer in there that would be very
helpful. Especially to compare the output of the two DOMStreamers.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[EMAIL PROTECTED]                          [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to