dev@jax-ws.java.net

Re: XMLStreamWriterEx

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 06 Jan 2006 09:39:10 +0100

Kohsuke Kawaguchi wrote:
> Paul Sandoz wrote:
>
>> Hi,
>>
>> I have include set/getNamespaceContext on XMLStreamWriterEx.
>
>
> I think getNamespaceContext makes sense but I don't know about
> setNamespaceContext. The said method on StAX API never made any sense to
> me.
>

Yeah, the javadoc is a real head scratcher.


> I could see passing NamespaceContext as a parameter to create new writer
> instance, (that indicates the currently in-scope namespace bindings so
> that you can write a good fragment when you are using StAX.)
>
> But what does it mean to 'set' a new NamespaceContext in the middle of
> writing? And it's not like the get method will return what you set, and
> it's not like the writer will hold on to the reference of
> NamespaceContext we 'set'.
>
> So I think it's better if we just leave it to getNamespaceContext.
>

For the case of:

    Header.writeTo(XMLStreamWriter w)

how can the Header tell the XMLStreamWriter what the in-scope namespaces
  are?

The implementation of XMLStreamWriter could be one that canonicallly
serializes a fragment. In this respect writing is only performed for the
fragment.

I think the semantics could be that the setting of the namespace context
can ignored by an XMLStreamWriterEx if it wants to.


Ah!!... hold on. The alternative is to use the XMLStreamReaderEx to get
the in-scope namespaces. Then the canonical XMLStreamWriterEx can be
instantiated with the NamespaceContextEx.

(Also i wonder if it would be more efficient to write a canonical
serializer that uses XMLStreamReaderEx instead.... but that is another
issue)

Better? If you think so i will remove the set method.


>> I have not used Maven before, tried to compile but gave up after about
>> 5 mins... (i know not very persistent but i have to get home before
>> the rush hour) ... i downloaded version 2.0.1...
>
>
> You are welcome to write an ant build script :-) it should be pretty easy.
>

Yes, i will commit a netbeans project. It would be even easier if there
was a Maven to Ant convertor :-)


> Maven 1 and Maven 2 aren't really compatible, and I still use Maven 1.
> So download that, and you'll be happy :-)
>

Ah, OK i will try Maven 1.

Paul.

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