<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Using Groovy to Create Sample Data in XML format for AppFuse</title>
	<atom:link href="http://www.patricbrown.com/blog/21/using-groovy-to-create-sample-data-in-xml-format-for-appfuse/feed" rel="self" type="application/rss+xml" />
	<link>http://www.patricbrown.com/blog/21/using-groovy-to-create-sample-data-in-xml-format-for-appfuse</link>
	<description>Mostly about Software Development and Data Science</description>
	<lastBuildDate>Sat, 21 Mar 2009 13:39:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Sebastian Gärtner</title>
		<link>http://www.patricbrown.com/blog/21/using-groovy-to-create-sample-data-in-xml-format-for-appfuse/comment-page-1#comment-23</link>
		<dc:creator>Sebastian Gärtner</dc:creator>
		<pubDate>Thu, 11 Sep 2008 13:50:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricbrown.com/blog/?p=21#comment-23</guid>
		<description>Hi,
here is another short one, without the cost of fetching MetaData
...
def sql = Sql.newInstance(URL,USER,PWD, DRIVER)
def tablename=&quot;any_table&quot;;
table=sql.rows(&quot;select * from &quot;+tablename)
xml = new groovy.xml.MarkupBuilder()
xml.&quot;${tablename}&quot;(){
    for (row in table){
        Row(){
            for (field in row){
                &quot;${field.key}&quot;(field.value)
            }
        }
    }
}</description>
		<content:encoded><![CDATA[<p>Hi,<br />
here is another short one, without the cost of fetching MetaData<br />
&#8230;<br />
def sql = Sql.newInstance(URL,USER,PWD, DRIVER)<br />
def tablename=&#8221;any_table&#8221;;<br />
table=sql.rows(&#8220;select * from &#8220;+tablename)<br />
xml = new groovy.xml.MarkupBuilder()<br />
xml.&#8221;${tablename}&#8221;(){<br />
    for (row in table){<br />
        Row(){<br />
            for (field in row){<br />
                &#8220;${field.key}&#8221;(field.value)<br />
            }<br />
        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig MacKay</title>
		<link>http://www.patricbrown.com/blog/21/using-groovy-to-create-sample-data-in-xml-format-for-appfuse/comment-page-1#comment-15</link>
		<dc:creator>Craig MacKay</dc:creator>
		<pubDate>Thu, 04 Sep 2008 20:29:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricbrown.com/blog/?p=21#comment-15</guid>
		<description>pretty useful way to dump data. I wanted to do something similar so I altered what you had and made the following:  

        def db = Sql.newInstance(databaseUrl, databaseUsername, databasePassword, databaseDriver)
        def file = new File(&quot;output.xml&quot;)
        def tables = [&quot;tableA&quot;, &quot;tableB&quot;]
        def xml = new MarkupBuilder(file.newWriter())
        xml.data {
            tables.each { table -&gt;
                xml.table(name:&quot;${table}&quot;) {
                    db.eachRow(&quot;select * from ${table}&quot;.toString()) { row -&gt;
                        def data = [:]
                        def metaData = row.getMetaData()
                        for (i in 0..&lt;metaData.columnCount) {
                            def name = metaData.getColumnLabel(i+1)
                            def value = row[i]
                            data.&quot;${name}&quot; = value
                        }
                        xml.row(data)
                    }
                }
            }
        }

Pretty much the same thing as yours except I wanted to dump data for multiple tables and I merged the metadata code with iterating the rows.</description>
		<content:encoded><![CDATA[<p>pretty useful way to dump data. I wanted to do something similar so I altered what you had and made the following:  </p>
<p>        def db = Sql.newInstance(databaseUrl, databaseUsername, databasePassword, databaseDriver)<br />
        def file = new File(&#8220;output.xml&#8221;)<br />
        def tables = ["tableA", "tableB"]<br />
        def xml = new MarkupBuilder(file.newWriter())<br />
        xml.data {<br />
            tables.each { table -&gt;<br />
                xml.table(name:&#8221;${table}&#8221;) {<br />
                    db.eachRow(&#8220;select * from ${table}&#8221;.toString()) { row -&gt;<br />
                        def data = [:]<br />
                        def metaData = row.getMetaData()<br />
                        for (i in 0..&lt;metaData.columnCount) {<br />
                            def name = metaData.getColumnLabel(i+1)<br />
                            def value = row[i]<br />
                            data.&#8221;${name}&#8221; = value<br />
                        }<br />
                        xml.row(data)<br />
                    }<br />
                }<br />
            }<br />
        }</p>
<p>Pretty much the same thing as yours except I wanted to dump data for multiple tables and I merged the metadata code with iterating the rows.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patric Brown</title>
		<link>http://www.patricbrown.com/blog/21/using-groovy-to-create-sample-data-in-xml-format-for-appfuse/comment-page-1#comment-7</link>
		<dc:creator>Patric Brown</dc:creator>
		<pubDate>Thu, 14 Aug 2008 00:07:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricbrown.com/blog/?p=21#comment-7</guid>
		<description>I actually played around with using DbUnit&#039;s export feature, as I thought that would be the easy way to do it.  I first had some issues in that the exported XML contained the schema&#039;s  from which I was migrating data,  though I ultimately was able to get around that, and then I found my exported xml was not nearly as pretty (I&#039;m picky).  Writing the Groovy script probably took less time than learning more about DbUnit to fix my issues.  Groovy is a no-brainer language to pick up for a Java developer, and it rocks as a quick, get-it-done, scripting language for tasks such as this.</description>
		<content:encoded><![CDATA[<p>I actually played around with using DbUnit&#8217;s export feature, as I thought that would be the easy way to do it.  I first had some issues in that the exported XML contained the schema&#8217;s  from which I was migrating data,  though I ultimately was able to get around that, and then I found my exported xml was not nearly as pretty (I&#8217;m picky).  Writing the Groovy script probably took less time than learning more about DbUnit to fix my issues.  Groovy is a no-brainer language to pick up for a Java developer, and it rocks as a quick, get-it-done, scripting language for tasks such as this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Raible</title>
		<link>http://www.patricbrown.com/blog/21/using-groovy-to-create-sample-data-in-xml-format-for-appfuse/comment-page-1#comment-5</link>
		<dc:creator>Matt Raible</dc:creator>
		<pubDate>Tue, 12 Aug 2008 00:24:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricbrown.com/blog/?p=21#comment-5</guid>
		<description>You can also use DbUnit&#039;s &quot;export&quot; feature to export a database&#039;s tables to XML format. I&#039;ve used this in the past to export a prod database to dev to reproduce an issue related to bad data.</description>
		<content:encoded><![CDATA[<p>You can also use DbUnit&#8217;s &#8220;export&#8221; feature to export a database&#8217;s tables to XML format. I&#8217;ve used this in the past to export a prod database to dev to reproduce an issue related to bad data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andhapp</title>
		<link>http://www.patricbrown.com/blog/21/using-groovy-to-create-sample-data-in-xml-format-for-appfuse/comment-page-1#comment-4</link>
		<dc:creator>andhapp</dc:creator>
		<pubDate>Mon, 11 Aug 2008 10:06:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricbrown.com/blog/?p=21#comment-4</guid>
		<description>You can do the loops in a much better way in groovy... look it up..</description>
		<content:encoded><![CDATA[<p>You can do the loops in a much better way in groovy&#8230; look it up..</p>
]]></content:encoded>
	</item>
</channel>
</rss>

