« Return to Thread: Duplicated namespace declaration from output xml

AW: AW: Duplicated namespace declaration from output xml

by Claus Nagel :: Rate this Message:

Reply to Author | View in Thread

Hi,

As the tutorial says, a namespace prefix mapper answers the question: "What
prefix do you want for this namespace URI?". However, I want the question
"Do you want this namespace URI to be automatically declared on the root
element?" to be raised. And I want to tell the Marshaller "No, skip this
namespace declaration!".

Nevertheless, I think the NamespacePrefixMapper class could be enhanced with
that functionality?!

Cheers,
Claus

> -----Ursprüngliche Nachricht-----
> Von: Martin.Grebac@... [mailto:Martin.Grebac@...]
> Gesendet: Dienstag, 18. November 2008 16:36
> An: users@...
> Betreff: Re: AW: Duplicated namespace declaration from output xml
>
> Hi,
>  I think providing a prefix mapper:
> http://java.sun.com/webservices/docs/2.0/jaxb/vendorProperties.html#prefix
> mapper
>  shall solve most of your issues.
>   MartinG
>
>
> Claus Nagel wrote:
> > Hi all -
> >
> > From the responses in this thread I understand that having control over
> the
> > namespace declarations produced by the Marshaller is an issue for many
> > people which is not addressed by the JAXB API so far.
> >
> > Currently I have also implemented a SAX filter for this purpose.
> However, I
> > would really prefer a simple way to customize the marshalling process.
> Is
> > there any chance that this will be a feature of upcoming JAXB versions?
> >
> > Cheers,
> > Claus
> >
> > ________________________________________
> > Von: Colin Fleming [mailto:colin.mailinglist@...]
> > Gesendet: Dienstag, 18. November 2008 13:01
> > An: users@...
> > Cc: claus.nagel@...
> > Betreff: Re: Duplicated namespace declaration from output xml
> >
> > Hi all,
> >
> > Sorry for the late response, I just saw this.
> >
> > For a slightly less foul solution, consider marshalling through a
> > TransformerHandler, and using SAX to filter the namespace events you
> don't
> > want. It's still pretty ugly, but it works for us.
> >
> > Cheers,
> > Colin
> > 2008/10/22 Wolfgang Laun <wolfgang.laun@...>
> > I'm aware that I'm suggesting a terrible hack, wrought with ifs and
> buts, so
> > don't tell me.
> >
> > To effect certain local modifications on the marshalled text you could
> do
> > the following:
> >
> > Call marshal with a PipedOutputStream pos as its second parameter.
> Connect a
> > PipedInputStream pis to that and start a thread reading from pis,
> > accumulating characters into a StringBuffer. At certain positions
> (e.g.at
> > line ends, after requesting JAXB_FORMATTED_OUTPUT) delete strings such
> as
> > xmlns:xs="..." from the StringBuffer and emit the StringBuffer to the
> > ultimate destination for your marhalled text. Insert is, of course,
> possible
> > as well, assuming you can identify the position.
> >
> >
> > On Tue, Oct 21, 2008 at 6:25 PM, Son Nguyen <sontrang91@...>
> wrote:
> >
> >
> > I think the problem comes from the xs:anySimpleType. If I change it to
> > string, it will works as normal. It also make sense that jaxb create
> output
> > with types for anySimpleType element. However, it will be a lot nicer if
> > jaxb can group all the xml declaration on the top and just use the
> nametag
> > for it. Do you know a way to tell jaxb to do that?
> >
> > Attachment is the complete project for you to run.
> >
> > Thanks,
> >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/Duplicated-namespace-declaration-from-output-xml-
> tp200
> > 69914p20094153.html
> > Sent from the java.net - jaxb users mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
>
> --
> Martin Grebac, http://blogs.sun.com/mgrebac
>
> Web Technologies & Standards
> Sun Microsystems Czech
>
> ICQ: 93478885
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Duplicated namespace declaration from output xml