Hi Krishna; you need to be sure to include the needed jars for gml support. 
Looks like you want WFS1_0 support?

You may also need to write out the xml schema file for your collection first? 
Remember that GML is not an actual format; instead it is a recipe for how to 
make your own XML format in a consistent manner.

There are some docs here:
- http://docs.codehaus.org/display/GEOTDOC/13+XML#13XML-GML2Encoding

I included a complete parsing example; but do not see a complete encoding 
example; but even so it shows you the two steps required.

I have tried to make it easier with that GML utility class; but I don't think I 
have managed it yet.

Behind the scenes it is doing:
- http://docs.codehaus.org/display/GEOTDOC/05+GTXML+Parsing+and+Encoding

For background on what jars are involved in working with GML see this page:
- http://docs.geotools.org/latest/userguide/guide/welcome/geotools.html

-- 
Jody Garnett

On Friday, 4 March 2011 at 3:25 AM, Krishna Rajendra Alapati wrote: 
> Hi All,
> 
> I am new to Geotools and trying to create a GML from a simple feature 
> collection. I am using the following code
> 
>  OutputStream out = new FileOutputStream(new File("C:\\test.gml"));
>  GML gml = new GML(Version.WFS1_0);
>  gml.encode(out, collection);
>  gml.setNamespace("test", "http://test.com";);
> 
>  out.close();
> 
> 
> But it's throwing NullPointerException 
> 
> Exception in thread "main" java.lang.NullPointerException
>  at 
> org.xml.sax.helpers.NamespaceSupport.declarePrefix(NamespaceSupport.java:289)
>  at org.geotools.GML.encode(GML.java:297)
> 
> Please help me to getrid of this error. 
> 
> Thank you,
> Krishna.
> 
> 
> 
> ------------------------------------------------------------------------------
> Free Software Download: Index, Search & Analyze Logs and other IT data in 
> Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
> generated by your applications, servers and devices whether physical, virtual
> or in the cloud. Deliver compliance at lower cost and gain new business 
> insights. http://p.sf.net/sfu/splunk-dev2dev 
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> 
------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to