Skip to main content

@XmlRootElement problem

2 replies [Last post]
play4fun_82
Offline
Joined: 2009-03-13
Points: 0

I have some schema like below :


.....

And the generated classes looks like this :

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Error", propOrder = {

})
@XmlRootElement(name = "exc")
public class Exc
extends XmlCommandBase
{
....

I don't get it why class name is like this. Class name should be like element type, Error in my case.

This should be a very simple thing to do. to generate a class with a rootElement from a schema, but even that, is not working.
Can anybody help me ? I'm getting at the end of my patience with this jaxb technology :(.

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Felipe Gaúcho

try:

objectFactory.createExc(objectFactory.createError())

It will return a JAXBElement that is what your schema modeled..

you defined the type: xsd:element name="exc"

so, the java class is public class Exc

On Mon, Apr 6, 2009 at 11:11 AM, wrote:
> I have some schema like below :
>
> [i]
>        
>                
>                [/i]
> .....
>
> And the generated classes looks like this :
>
> [i]@XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "Error", propOrder = {
>
> })
> @XmlRootElement(name = "exc")
> public class Exc
>    extends XmlCommandBase
> {[/i]
> ....
>
> I don't get it why class name is like this. Class name should be like element type, [b]Error[/b] in my case.
>
> This should be a very simple thing to do. to generate a class with a rootElement from a schema, but even that, is not working.
> Can anybody help me ? I'm getting at the end of my patience with this jaxb technology :(.
>
> Thanks
> [Message sent by forum member 'play4fun_82' (play4fun_82)]
>
> http://forums.java.net/jive/thread.jspa?messageID=340723
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>
>

--

Please help to test this application:
http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

play4fun_82
Offline
Joined: 2009-03-13
Points: 0

The problem is that i need that jaxb to create and [b]Error [/b]object ( I need Error class not exc class, exc is just the xml root node). All examples i've found say the same thing :

http://lia.deis.unibo.it/Courses/TecnologieWeb0708/materiale/laboratorio...

As in example 3 from this link, element name is associated to XmlRootElement, and type to class name. Like is supposed to be. But in my case class name is set according to element Name. Which is correct way ? And why my class name is not generated properly?

//schema
[i]
[/i]

//class code
[i]@XmlRootElement(name="PriceElement")
public class USPrice {[/i]

Thanks for your time and sorry if i didn't made myself clear enough from beginning.