You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jeremy Quinn <sh...@mac.com> on 2002/06/02 16:30:56 UTC
NS problems with AbstractSAXTransformer & SourceWritingTransformer
Hi All,
SourceWritingTransformer in HEAD is broken, I am working on it.
It's not committed yet, but I have a version here that has the
<source:write/> tag implemented using the same pattern as the
new <source:insert/> tag Carsten added.
So now the <source:write/> tag also uses the
AbstractSAXTransformer.startRecording() method to buffer the
content to be written to a org.w3c.dom.DocumentFragment, writing
it to source when the tag closes.
I got it working with <slash-edit/> last night and this morning
started work on the tests.
I found a rather nasty problem with test2, the namespace test.
The results are odd.
This is the Fragment as it starts out. You can tell from the log
transformer that the all expected events are sent.
<page xmlns:xl="http://www.w3.org/1999/xlink">
<title>SourceWritingTransformer Test Result 2</title>
<content>
<para>Congratulations!</para>
<para><link xl:to="test/2">I am in the XLink
NameSpace</link></para>
</content>
</page>
This is the report in the sitemap.log showing the content of the
captured DOM fragment (the code uses
XMLUtils.serializeNodeToXML() to log the fragment).
The xmlns declaration has moved from the <page/> to the <link/>
tag, was the <page/>'s startPrefixMapping registered during the
capture process?
<page>
<title>SourceWritingTransformer Test Result 2</title>
<content>
<para>Congratulations!</para>
<para>
<link xmlns:xl="http://www.w3.org/1999/xlink" xl:to="test/2">I
am in the XLink NameSpace</link>
</para>
</content>
</page>
This is the content that get's written to file.
Now the namespace declaration has gone completely, meaning the
file cannot even be parsed.
<page>
<title>SourceWritingTransformer Test Result 2</title>
<content>
<para>Congratulations!</para>
<para><link xl:to="test/2">I am in the XLink
NameSpace</link></para>
</content>
</page>
SourceWritingTransformer copies the DocumentFragment into a new
Document thus:
Parser parser = (Parser)this.manager.lookup(Parser.ROLE);
Document resource = parser.createDocument();
Node importNode = resource.importNode(fragment, true);
resource.appendChild(importNode);
Then uses the DOMStreamer to output to Source.
Have I missed something?
There might be a general problem with AbstractSAXTransformer,
because I tried to <source:insert/> a fragment containing a
namespace declaration, and that got lost too.
Thanks for any suggestions
regards Jeremy
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org