Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Castor is not marshalling/unmarshalling a Enumeration for me

Reply
Thread Tools

Castor is not marshalling/unmarshalling a Enumeration for me

 
 
PPA
Guest
Posts: n/a
 
      02-13-2007
Hi Guys

I am really new to XML/XSD and Castor. Could you please help me out
here?

I have following XSD:
-----------------------------XSD
STARTS-----------------------------------
<xs:schema xmlnss="http://www.w3.org/2001/XMLSchema">

<xs:simpleType name="valueType">
<xs:restriction base="xs:string">
<xs:enumeration value="string"/>
<xs:enumeration value="boolean"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="param">
<xs:attribute name="name" use="required" type="xs:string"></
xs:attribute>
<xs:attribute name="value" use="required" type="xs:string"></
xs:attribute>
<xs:attribute name="type" use="required" type="valueType"></
xs:attribute>
</xs:complexType>
</xs:schema>
------------------------------XSD
ENDS----------------------------------
I have generated the Java class against this xsd and the class Param
has following attributes

private java.lang.String _name;

private java.lang.String _value;

private com.test.types.ValueType _type;

Now, just to test I created the the java object Param, populate it
with name, value and type and then MARSHALL'ed it. The generated XML
does not have <type> tag at all.

Similarly if I create an XML with all three tags, and then unmarshall
it, for Param object, type is coming out to be NULL.

What is that I am missing? Please help.

Regards,
-PPA

 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      02-13-2007
> <xs:attribute name="type" use="required" type="valueType"></
....
> Now, just to test I created the the java object Param, populate it
> with name, value and type and then MARSHALL'ed it. The generated XML
> does not have <type> tag at all.


As others keep saying: Don't think in terms of tags; it just messes you
up. Think in terms of elements and attributes. This avoids the confusion
you've just displayed over what "tag" means.

According to your schema, type is defined as an attribute of the param
element. So what you should be seeing is

<param name="something" value="something else" type="whatever"/>



--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re-using a simple type definition; with enumeration constraint andwithout enumeration constraint puvit82 XML 4 02-01-2008 03:46 PM
HtmlTextWriterStyle enumeration does not contain most of the available CSS properties Nathan Sokalski ASP .Net 1 10-09-2005 12:26 PM
HtmlTextWriterStyle enumeration does not contain most of the available CSS properties Nathan Sokalski ASP .Net Building Controls 1 10-09-2005 12:26 PM
[Castor]How to install Castor properly? Sam Hwang Java 0 04-26-2005 08:54 AM
Object relational mapping with Castor D L.Strang Java 0 07-09-2003 03:01 PM



Advertisments