<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>REVERT TO CONSOLE &#187; Xml</title>
	<atom:link href="http://www.reverttoconsole.com/blog/category/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.reverttoconsole.com</link>
	<description>for f in *;do echo &#124; sed &#039;i\rtc&#039; &#62;&#62; $f;done; java programming et al</description>
	<lastBuildDate>Thu, 25 Aug 2011 15:02:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Marshalling and Unmarshalling Xml &#8211; Step by Step tutorial with Castor in 10 mins</title>
		<link>http://www.reverttoconsole.com/blog/xml/marshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes/</link>
		<comments>http://www.reverttoconsole.com/blog/xml/marshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes/#comments</comments>
		<pubDate>Sat, 14 Jul 2007 22:25:40 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[Xml]]></category>

		<guid isPermaLink="false">http://reverttoconsole.com/archives/122</guid>
		<description><![CDATA[If you want a simple way to marshall / unmarshall your pojo -&#62; Xml files, Castor could be very handy. Before reading the docs on the setup and overview and breaking your nerves on it&#8217;s rich feature set, lets get going in less than 10 minutes. Castor is extremely powerful but if your purpose is [...]]]></description>
			<content:encoded><![CDATA[<p>If you want a simple way to marshall / unmarshall your pojo -&gt; Xml files, <a href="http://http://www.castor.org/">Castor</a> could be very handy. Before reading the docs on the setup and overview and breaking your nerves on it&#8217;s rich feature set, lets get going in less than 10 minutes. Castor is extremely powerful but if your purpose is pure marshalling of pojos into xml with namespaces from your xsd, you need to understand -</p>
<p>- 2 method calls (marshal, unmarshall)<br />
- understand how to write a mapping file (pojo to xml)<br />
- the pojo ofcourse<br />
- (optional) xsd file and ofcourse a sample xml file for the xsd</p>
<p>Lets see a basic example with &#8216;profile&#8217;. A <a href="http://helloworld2.svn.sourceforge.net/viewvc/helloworld2/projects/struts/profile/src/main/java/com/reverttoconsole/profile/model/">profile</a> is a simple pojo which consists of a user profile information (like your facebook profile). It has a Bio Interests, Contact as complex types. Now, create an <a href="http://helloworld2.svn.sourceforge.net/viewvc/helloworld2/projects/struts/profile/src/main/java/resources/profile.xsd?revision=1&amp;view=markup">xsd</a> (optional, you can really skip this step) for the pojo. More often you would prefer to create an xml first and generate the xsd from your favorite tool or you could do vice versa. (I&#8217;d recommend using eclipse 3x. Right click and generate!)</p>
<p>Once you figured out the pojo &#038; xml, you have to create a <a href="http://helloworld2.svn.sourceforge.net/viewvc/helloworld2/projects/struts/profile/src/main/java/resources/castor-mapping.xml?view=markup">castor mapping file.</a> I&#8217;m not going to go in detail on how to create one. The best way I figured out is to read an example mapping file and once you understand, writing your own is a matter of improvising along with a<a href="http://www.castor.org/xml-mapping.html"> reference guide</a>. Now, the final part &#8211; Create a <a href="http://helloworld2.svn.sourceforge.net/viewvc/helloworld2/projects/struts/profile/src/main/java/com/reverttoconsole/util/xml/XmlMarshaller.java?view=markup">utility class</a> for wrapping up the basic methods of castor along with some exception handling. To make life absolutely easy, I&#8217;ve added a main method for testing standalone without a JUnit. Download these 4 files along with <a href="http://www.castor.org/download.html#Castor">castor.jar</a> and you just got a standalone castor example!</p>
<p>Castor xml marshalling/unmarshalling &#8211; its that easy!</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F&amp;title=Marshalling+and+Unmarshalling+Xml+%26%238211%3B+Step+by+Step+tutorial+with+Castor+in+10+mins" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F&amp;title=Marshalling+and+Unmarshalling+Xml+%26%238211%3B+Step+by+Step+tutorial+with+Castor+in+10+mins" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F&amp;title=Marshalling+and+Unmarshalling+Xml+%26%238211%3B+Step+by+Step+tutorial+with+Castor+in+10+mins" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F&amp;title=Marshalling+and+Unmarshalling+Xml+%26%238211%3B+Step+by+Step+tutorial+with+Castor+in+10+mins" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F&amp;title=Marshalling+and+Unmarshalling+Xml+%26%238211%3B+Step+by+Step+tutorial+with+Castor+in+10+mins', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F&amp;title=Marshalling+and+Unmarshalling+Xml+%26%238211%3B+Step+by+Step+tutorial+with+Castor+in+10+mins" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fxml%2Fmarshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes%2F&amp;title=Marshalling+and+Unmarshalling+Xml+%26%238211%3B+Step+by+Step+tutorial+with+Castor+in+10+mins" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/xml/marshalling-and-unmarshalling-pojos-to-xml-castor-example-in-10-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

