users@jaxb.java.net

Marshal also "unnecessary" namespaces

From: fgeller <fgeller_at_gmail.com>
Date: Tue, 20 May 2008 00:24:12 -0700 (PDT)

Hi,

   I'm running into the following problem when using JAXB: I need to read
the declared namespace URIs and associated prefixes, even though the
namespaces aren't used for elements but instead as follows:

<element xmlns:foo="http://www.example.com">
foo:Test
</element>

This use of namespaces is as defined in OASIS' WSN Topics specification (for
the Simple dialect).

Browsing through documentation I found the following bit [1]:

 * By default, the JAXB RI 1.0.x produces namespace declarations only when
 * they are necessary, only at where they are used.
 
Now, it seems that there is no direct way to obtain the declared namespace
from the object that corresponds to the "element" element in the above
example. So instead I'm trying to (re)marshal the object and attach a
NamespacePrefixMapper in order to obtain a callback when processing the
namespace. However, the namespace declaration is never generated and
therefore no callback. Now, is there a way to change the default behavior
as outlined in [1], or would you know of any other way to obtain the prefix
and URI from the given unmarshalled object? Any hints would be greatly
appreciated.

Cheers,
Felix

[1] https://jaxb.dev.java.net/2.1.2/docs/vendorProperties.html
(NamespacePrefixMapper documentation)
-- 
View this message in context: http://www.nabble.com/Marshal-also-%22unnecessary%22-namespaces-tp17334757p17334757.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.