This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Problem in castor mapping file

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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>
 
mooooooo ..... tiny ad ....
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!