You are welcome. Cheers Werner
Steve Kingsland wrote: > This did not work: > > <field name="yesNo"> > <bind-xml name="myElement" *type="string"*> > </field> > > I still got this: > > <myElement xmlns:java="http://java.sun.com" > xsi:type="java:java.lang.String">Yes</myElement> > > However, when I set this: > > marshaller.setSuppressXSIType(true); > > Then I got what I wanted: > > <myElement>Yes</myElement> > > > > That works for me. Thanks for your help! > > > > -Steve > > > > From: *Werner Guttmann* <[email protected]> > Date: Thu, May 28, 2009 at 2:31 AM > Subject: Re: [castor-user] [xml] Marshalling a Java5 Enum > To: [email protected] > > > Steve, > > can I actually ask you something ? Have you tried to map the enum as > follows: > > <field name="yesNo"> > <bind-xml name="myElement" type="string"> > </field> > > as I am almost sure that this will cause the xsi:type definition to > disappear. Here's why: If you don't use a type definition as part of > your field mapping, Castor will assume a default type of > "java.lang.Object" for this field. As such, it will have to annotate the > XML produced with type information so that things can be unmarshalled > back. Does this make sense ? > > Alternatively, you could always instruct the Marshaller to omit xsi:type > defs from the XML produced. > > Cheers > Werner > > > Steve Kingsland wrote: >> Well first, I'm not really sure this is a problem. I just found this fixed >> bug: >> >> http://jira.codehaus.org/browse/CASTOR-2231 >> >> which makes it sound like the "xmlns:java="http://java.sun.com" >> xsi:type="java:java.lang.String"" is being added on purpose, perhaps for >> unmarshalling? It must have to do with the XML field being mapped to an >> enum, I just can't figure out exactly why... >> >> -Steve >> >> On Wed, May 27, 2009 at 5:48 AM, Werner Guttmann <[email protected] >> wrote: >> >>> Steve, >>> >>> can you please create a new Jira ticket at >>> http://jira.codehaus.org/browse/CASTOR, and attach a fully working >>> (JUnit preferably) test case that allows us to reproduce the problem. >>> >>> Thanks >>> Werner >>> >>> Steve Kingsland wrote: >>>> Sorry to dig up an old thread, but I think I'm having the same issue >>>> as NMcLoughlin >>>> was. My case is pretty simple though: when I marshall a Java5 enum, it >>>> works, but I get extra namespace details added to the XML Element that I >>>> don't want. I'm using Castor 1.3. >>>> >>>> My POJO contains a simple Java5 enum: >>>> >>>> public enum MyEnum {Yes, No} >>>> >>>> public MyEnum yesNo; >>>> >>>> My mapping maps the Java property to an XML Element: >>>> >>>> <field name="yesNo"> >>>> <bind-xml name="myElement"> >>>> </field> >>>> >>>> And when I marshall to XML, I'd expect to see this, right? >>>> >>>> <myElement>Yes</myElement> >>>> >>>> But what I'm getting is this: >>>> >>>> <myElement *xmlns:java="http://java.sun.com" >>> xsi:type="java:java.lang.** >>>> String"*>Yes</myElement> >>>> >>>> Can anyone explain why that is? >>>> >>>> I haven't tried *unmarshalling*, because for the current project I'm >>> working >>>> on, I only need to marshall. >>>> >>>> -Steve >>>> >>>> On Wed, Dec 17, 2008 at 4:52 PM, <[email protected]> wrote: >>>> >>>>> Sorry I should have been more clear. That is where the problem is. >>> Object >>>>> --> xml. I don't have a call for the other way, but can set one up. >>>>> >>>>> >>>>> >>>>> >>>>> Werner Guttmann >>>>> <werner.guttmann@ >>>>> gmx.net> >>> To >>>>> [email protected] >>>>> 12/17/2008 03:39 >>> cc >>>>> PM >>>>> >>> Subject >>>>> Re: [castor-user] Java 5 Enums > and >>>>> Please respond to xsi:type >>>>> [email protected] >>>>> aus.org >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> Hi, >>>>> >>>>> before looking into this, can I ask you to marshal some Object instance >>>>> to XML to make sure whether that side of things work. >>>>> >>>>> Regards >>>>> Werner Guttmann >>>>> >>>>> [email protected] wrote: >>>>>> Yes, I'm using a mapping based approach. Just a simple enum: >>>>>> >>>>>> public enum Type { >>>>>> >>>>>> ABC, VDR, ICZ; >>>>>> >>>>>> } >>>>>> >>>>>> And here's the relevant part of my mapping: >>>>>> >>>>>> <field name="type" type="com.mycompany.Type"> >>>>>> <bind-xml name="cv:type" node="element" >>>>>> xmlns:cv="http://www.mycompany.com/Type" /> >>>>>> </field> >>>>>> >>>>>> Thanks for your help. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> Werner Guttmann >>>>>> <werner.guttmann@ >>>>>> gmx.net> >>>>> To >>>>>> [email protected] >>>>>> 12/17/2008 03:15 >>>>> cc >>>>>> PM >>>>> Subject >>>>>> Re: [castor-user] Java 5 Enums >>> and >>>>>> Please respond to xsi:type >>>>>> [email protected] >>>>>> aus.org >>>>>> >>>>>> >>>>>> >>>>>> Hi, >>>>>> >>>>>> yes, this could be an issue, as it all depends how you've developed >>> your >>>>>> enum to which this XML should be mapped (assuming that you are using a >>>>>> mapping-based approach). >>>>>> >>>>>> How does your enum look like ? >>>>>> >>>>>> Regards >>>>>> Werner >>>>>> >>>>>> [email protected] wrote: >>>>>> >>>>>> I'm having an issue with marshalling java 5 enums. >>>>>> >>>>>> The generated xml has the following declaration: >>>>>> xsi:type="java:java.lang.String", as in: >>>>>> >>>>>> <cv:type xsi:type="java:java.lang.String" >>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>>>> xmlns:c="http://www.mycompany.com/Type">ABC</cv:type> >>>>>> >>>>>> ... which obviously doesn't validate. How can this be prevented? >>>>>> >>>>>> I've seen this issue posted several times against previous versions of >>>>>> Castor but with no solutions. I'm using Castor version 1.3rc1. Is this >>>>>> still an issue? >>>>>> >>>>>> Thanks. >>>>> ----------------------------------------- >>>>> CONFIDENTIALITY STATEMENT: >>>>> This e-mail transmission contains information that is intended to >>>>> be confidential. It is intended only for the addressee named >>>>> above. If you receive this e-mail in error, please do not read, >>>>> copy, or disseminate it. If you are not the intended recipient, >>>>> any disclosure, copying, distribution or use of the contents of >>>>> this information is prohibited. Please reply to the message >>>>> immediately by informing the sender that the message was >>>>> misdirected. After replying, please erase it from your computer >>>>> system. Your assistance in correcting this error is appreciated. >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe from this list, please visit: >>>>> >>>>> http://xircles.codehaus.org/manage_email >>>>> >>>>> >>>>> >>> --------------------------------------------------------------------- >>> To unsubscribe from this list, please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >>> >>> > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

