Look at this further. It seems the problem may be in XMLWriter
specifically in writeAttributes.

It will only not write the attribute it if relates to a default
namespace. Qualified namspaces will be written out
no matter what.

Does anyone have any ideas for a work around?

Thanks a lot,
Regards,
Nicholas

For reference:

private void writeAttributes(Attributes atts) throws SAXException {
        final int len = atts.getLength();
        for (int i = 0; i < len; i++) {
            if (!"xmlns".equals(atts.getQName(i))) {
                final char ch[] = atts.getValue(i).toCharArray();
                write(' ');
                writeName(atts.getURI(i), atts.getLocalName(i),
                        atts.getQName(i), false);
                write("=\"");
                writeEsc(ch, 0, ch.length, true);
                write('"');
            } else {
                // Redefines the default namespace.
                forceNSDecl(atts.getValue(i));
            }
        }
    }






On Tue, Apr 3, 2012 at 3:28 PM, Nicholas Waltham <[email protected]> wrote:
> Hi All,
>  I have produced some simplified code to demonstrate what appears to
> be a bug. However I would like to check with the list before I file a
> report.
>
> If I have the following code:
>
>
> String uri = LocalReference.createClapReference(getClass().getPackage())
> + "/xmlwns.xml";
> Representation listVtl = new ClientResource(uri).get();
> SaxRepresentation r = new SaxRepresentation(listVtl);
> log.debug(r.getText());
>
> I observe the following behavior:
>
> inputfile xmlwns.xml
>
> <a xmlns="uri:a" xmlns:b="uri:b"  >
>  <b:content/>
> </a>
>
> gives as output to the logger:
>
> <a xmlns:b="uri:b" xmlns="uri:a">
>  <b:content xmlns:b="uri:b"></b:content>
> </a>
>
> which is a little more verbose, but technically correct.
>
> While with inputfile xmlwns.xml
>
> <a:doc xmlns:a="uri:a" xmlns:b="uri:b" >
>  <b:content/>
> </a:doc>
>
> gives as output to the logger:
>
> <a:doc xmlns:a="uri:a" xmlns:b="uri:b" xmlns:a="uri:a">
>  <b:content xmlns:b="uri:b"></b:content>
> </a:doc>
>
> you will see that the namspace definition for xmlns:a is duplicated,
> which gives an error on some XML readers. For example Google Chrome
> will complain about a redefinition of the namespace.
>
> Whats your view on this? Is this a bug in Restlet?
>
> Thanks a lot,
> Regards,
> Nicholas

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2944521

Reply via email to