• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in castor mapping file

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Can you please look on the mapping xml for the following xml file .I need to unmarshell the xml file .

The source xml file is like

<product_model>
<record>
<categories>C</categories>
<levelRank>00</levelRank>
<parentID>00</parentID>
<id>01</id>
<catalogName>Consumer Products</catalogName>
<materialName>Consumer Products</materialName>
</record>
<record>
<categories>C</categories>
<levelRank>00</levelRank>
<parentID>01</parentID>
<id>02</id>
<catalogName>Television Projector</catalogName>
<materialName>Television Projector</materialName>
</record>
<record>
<categories>C</categories>
<levelRank>00</levelRank>
<parentID>01</parentID>
<id>03</id>
<catalogName>Home Video</catalogName>
<materialName>Home Video</materialName>
</record>
.....................................
..............................
<product_model>


I defined the mapping xml in the following format


<class name="ProductModel">

<map-to xml="product_model"/>

<field name="categories" type="java.lang.String" >
<bind-xml name="categories" node="element" location="record" />
</field>
<field name="levelRank" type="java.lang.String" >
<bind-xml name="levelRank" node="element" location="record" />
</field>
<field name="parentID" type="java.lang.String" >
<bind-xml name="parentID" node="element" location="record"/>
</field>
<field name="id" type="java.lang.String" >
<bind-xml name="id" node="element" location="record"/>
</field>
<field name="catalogName" type="java.lang.String" >
<bind-xml name="catalogName" node="element" location="record"/>
</field>

<field name="materialName" type="java.lang.String" >
<bind-xml name="materialName" node="element" location="record"/>
</field>
</class>
</mapping>

It is not binding the data to the object.
The value of object is showing null.
Can anybody please help me?
[ October 22, 2008: Message edited by: Nishad Abdul kareem ]
 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post your command lines you use to do the unmarshalling as well as your class and xml files you use therefore.
[ October 25, 2008: Message edited by: Darya Akbari ]
 
Nishad Abdul kareem
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The format of xml file I metioned in the fiest posting.In the xml file I have lots of record fields.I want to get each record as an object.The unmarshalled data should be an object which i want to add in to a list.
the code is like

Mapping mapping = new Mapping();
mapping.loadMapping(productModelMapping);
Unmarshaller unmar = new Unmarshaller(ProductModel.class);
unmar.setMapping(mapping);

List unmarshaledList = new ArrayList();
unmarshaledList.add((List) unmar.unmarshal(inputSourceFile));


The inputSourceFile has the path of xml files.

How do I get the objects,to the list?

My mapping file is

<mapping>

<class name="com.sony.homepage.promotion.product.ProductModel">
<map-to xml="record"/>

<field name="categories" type="java.lang.String">
<bind-xml name="categories" node="element" />
</field>
<field name="levelRank" type="java.lang.String" >
<bind-xml name="levelRank" node="element" />
</field>

<field name="parentID" type="java.lang.String" >
<bind-xml name="parentID" node="element"/>
</field>

<field name="id" type="java.lang.String" >
<bind-xml name="id" node="element" />
</field>

<field name="catalogName" type="java.lang.String" >
<bind-xml name="catalogName" node="element" />
</field>

<field name="materialName" type="java.lang.String" >
<bind-xml name="materialName" node="element" />
</field>
</class>
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic