users@jaxb.java.net

Re: Namespace usage and xsd:any element problem

From: Fernando González <fergonco_at_gmail.com>
Date: Sat, 20 Sep 2008 13:27:31 +0200

If someone understood my problem and is interested on it: I solved it. The
application had a custom classloader that provided no information about
packages. This caused Class.getPackage() to return null and makes JAXB
unable to read the @javax.xml.bind.annotation.XmlSchema annotation in the
package-info.java

After fixing the classloader, JAXB reads the annotation:
@javax.xml.bind.annotation.XmlSchema(namespace = "org.orbisgis.mapContext",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

and qualifies the elements belonging to "org.orbisgis.mapContext" namespace.

Hope this can save someone the three hours I debugged through JAXB (to
finally arrive to my own classloader)

On Sat, Aug 23, 2008 at 11:56 AM, Fernando González <fergonco_at_gmail.com>wrote:

> Hi,
>
> I'm using JAXB to generate XML using different context directories as
> context path and I'm having a strange behavior. The application I'm building
> reads and writes XML fine, but I get no namespace prefix in the XML.
> However, when I run the same code from an unit test it generates XML's with
> namespace prefix in some of nodes (corresponding to a "any" element in the
> schema). As a result, test cases cannot map the XML files produced by the
> application to the objects JAXB generated but to a default NSElement (I
> think it's something from the parser). The context path is identical in both
> cases.
>
> I would like to know which is the JAXB policy for namespace usage. Any hint
> would be appreciated.
>
> Greetings,
> Fernando
>



-- 
Fernando González Cortés
Ingeniero informático,
Jefe de desarrollo de OrbisGIS,
Institut de recherche en sciences et techniques de la ville
<http://www.irstv.cnrs.fr/>