Namespace usage and xsd:any element problem

View: New views
2 Messages — Rating Filter:   Alert me  

Namespace usage and xsd:any element problem

by Fernando González :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: Namespace usage and xsd:any element problem

by Fernando González :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...> 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/>
LightInTheBox - Buy quality products at wholesale price!