dev@jax-ws.java.net

Reporting namespaces of fragments <was> Re: CVS update: /xmlstreambuffer/streambuffer/src/com/sun/xml/stream/buffer/stax/

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 22 Feb 2006 11:13:15 +0100

kohsuke_at_dev.java.net wrote:
> --------------------
> --- StreamReaderBufferProcessor.java 19 Feb 2006 17:24:40 -0000 1.17
> +++ StreamReaderBufferProcessor.java 21 Feb 2006 23:12:57 -0000 1.18
> @@ -632,9 +632,15 @@
> if ((item & FLAG_NAMESPACE_ATTRIBUTE) == 0) {
> processAttributes(item);
> } else {
> - // Skip the namespace declarations on the element
> - // they will have been added already
> - item = skipNamespaceAttributes(item);
> + // In-scope namespaces are for namespaces that are declared
> + // on ancestors, and doesn't include the namespaces declared
> + // on the element itself.
> + //
> + // so even if we fill in inscopeNamespaces above, we still
> + // need to take this into account, which is namespaces declared
> + // on the element.
> + // I appreciate a review from Paul - KK
> + item = processNamespaceAttributes(item);
> if ((item & TYPE_MASK) == T_ATTRIBUTE) {
> processAttributes(item);
> }
>

I think the fix will work. Originally no namespaces were reported on the
element.

Perhaps there is another bug here (as was there before) in relation to
writing. If XMLStreamReader is used to produce a self-contained fragment
then all in-scope namespaces need to be declared on the element (not
just the ones that were originally declared).

Do you think it acceptable that all namespaces that are in-scope should
be declared on the element fragment? If so it is a very easy fix, and it
avoids the duplication of the current fix.


Can i know the origin of the problem? (not because i do not think this
fix should be pulled) but because i am wondering if it is necessary to
go through all namespaces declared on the fragment or that
XMLStreamReader.getNamespaceURI(java.lang.String prefix) could be used
instead, which may be more efficient.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109