You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Peter Davis <pd...@attbi.com> on 2002/03/23 15:01:21 UTC

Bug when serializing XML and xmlns=""

Hi everybody, I'm new to this list so bear with me...

It started off as one problem, but when I was trying to create a bug report 
for the first I discovered a second.  They both occur between lines 381 and 
394 of org/apache/cocoon/serialization/AbstractTextSerializer.java.

The second problem is easier to recreate, so I'll cover it first.  The result 
is this:
java.lang.NullPointerException
        at 
org.apache.cocoon.serialization.AbstractTextSerializer$NamespaceAsAttributes.startElement(AbstractTextSerializer.java:386)
        at 
org.apache.cocoon.xml.AbstractXMLPipe.startElement(AbstractXMLPipe.java:88)
        at 
org.apache.xalan.transformer.ResultTreeHandler.flushElem(ResultTreeHandler.java:856)

Here is a simple XML file that causes the problem:

<page xmlns="foo">
  <test xmlns="">
    this is a test
  </test>
</page>

and the offending code (in AbstractTextSerializer.java):

boolean found = false;
for (int attr = 0; attr < attrCount; attr++) {
    if (qName.equals(attrs.getQName(attr))) {
        // Check if mapping and attribute URI match
///*** uri is null here ***///
        if (! uri.equals(attrs.getValue(attr))) {
            getLogger().error("URI in prefix mapping and attribute do not 
match : '" + uri + "' - '" + attrs.g
            throw new SAXException("URI in prefix mapping and attribute do 
not match");
        }
        found = true;
        break;
    }
}

In my sitemap.xmap, I have:
<map:match pattern="the-test-page.xml">
  <map:generate type="file" src="{0}"/>
  <map:serialize type="xml"/>
</map:match>


The other error is prooving really hard for me to reproduce with a 
minimalized example.  I do know that it is caused when I do a transformation 
with Xalan using something like:

<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
...
<element name="foo" namespace="">...</element>
...
</stylesheet>

I think it might be that Xalan is sending a startPrefixMapping() for the 
<stylesheet> or other XSL elements, and this is confusing the serializer when 
it gets to the <element namespace=""/>.  If I replace <element name="foo" 
namespace=""/> with <foo xmlns=""/>, it works fine.

The error is the SAXException("URI in prefix mapping and attribute do not 
match") from the code above, and the log message is:

URI in prefix mapping and attribute do not match : 
'http://www.w3.org/1999/XSL/Transform' - 'http://www.w3.org/2000/xmlns/'

which is why I believe Xalan is confusing the serializer, since the 
XSL/Transform namespace is never output by my stylesheet.

Sorry I can't help to recreate this one further.  Thanks for your help!

-- 
Peter Davis
Where's the man could ease a heart
Like a satin gown?
		-- Dorothy Parker, "The Satin Dress"

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