From: Chris H. <ch...@op...> - 2005-04-13 14:41:05
|
Forwarding to geotools-devel list, since I'm past my knowledge about gml at this point. Chris ----- Forwarded message from Adrien Anselme <ada...@gm...> ----- Date: Wed, 13 Apr 2005 12:09:29 +0900 From: Adrien Anselme <ada...@gm...> Reply-To: Adrien Anselme <ada...@gm...> Subject: Re: [Geoserver-users] Re: Geoserver Question To: Chris Holmes <ch...@op...> Hi, > Ok, first off, I have never tried out the gml datastore, so I can only > give you guesses. If you could report back success or failures that > would be great. > > The place to get started is in geotools. Get a 2.1 version, and try out > the gml datastore, in plugins/. GeoServer is completely decoupled from > the datastores, it interacts with them through the factory interface, > see > http://svn.geotools.org/geotools/trunk/gt/plugin/gml/src/org/geotools/dat= a/gml/GMLDataStoreFactory.java > It looks like the file needs to end in either .xml or .gml. And you > need to specify the url to the file. Shapefile has examples, see > http://geoserver.sourceforge.net/documentation/user/datastores.html#shape= file > and just change the file name to the one you are using. > > As for specifying the XML schema file, you should do so in the gml file > itself, the parser will resolve the schemaLocation (definitely need to > specify it), and parse the Schema file. So be _sure_ your xml file > points to its schema file. I made some tries with the GML datastore but I still can't get anything to work. I created a custom simple GML file and its Schema using XMLSpy, so I'm sure that the files are correct and validate. The only thing I have to change after saving my xml file in xmlspy is the path to the schema file. Xmlspy wants something like D:\taf\city.xml whereas Geotools expects an URL like file:/D:/taf/city.xml . I then wrote a test code based on the shpDataStore samples of Geotools' wiki : try { //fileSelect is a private method to open a dialog and get a file URL shapeURL =3D fileSelect("gml","GML File","D:\\taf\\city.xml"); //datastore creation GMLDataStoreFactory facto =3D new GMLDataStoreFactory(); GMLDataStore store =3D (GMLDataStore)facto.createDataStore(shapeURL); FeatureType ft =3D store.getSchema(); //is supposed to display the featuretypes of the datastore for (int i =3D 0; i < ft.getAttributeCount(); i++) { //THIS IS LINE 139 AttributeType at =3D ft.getAttributeType( i ); if (!Geometry.class.isAssignableFrom(at.getType())) System.out.print(at.getType().getName() + "\t"); } } catch (IOException ie) { System.err.println("IOException: " + ie.getMessage()); } But I get an exception that I don't understand : Exception in thread "main" java.lang.NullPointerException at adrien.tests.geotools.Test.testGml(Test.java:139) at adrien.tests.geotools.Test.main(Test.java:30) 2005. 4. 13 =EC=98=A4=EC =84 11:40:04 org.geotools.xml.XMLSAXHandler endE= lement =EA=B2=BD=EA=B3 : Stopping 2005. 4. 13 =EC=98=A4=EC =84 11:40:04 org.geotools.xml.XMLSAXHandler endE= lement =EA=B2=BD=EA=B3 : Line 25 Col 15 org.geotools.xml.gml.FCBuffer$StopException: Stopping at org.geotools.xml.gml.GMLComplexTypes$AbstractFeatureType.stream(GMLComple= xTypes.java:4179) at org.geotools.xml.gml.GMLComplexTypes$AbstractFeatureType.getValue(GMLComp= lexTypes.java:4096) at org.geotools.xml.handlers.xsi.ComplexTypeHandler$DefaultComplexType.getVa= lue(ComplexTypeHandler.java:1064) at org.geotools.xml.handlers.ComplexElementHandler.endElement(ComplexElement= Handler.java:184) at org.geotools.xml.XMLSAXHandler.endElement(XMLSAXHandler.java:209) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(U= nknown Source) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndE= lement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Fr= agmentContentDispatcher.dispatch(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.sc= anDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unkno= wn Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unkno= wn Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknow= n Source) at javax.xml.parsers.SAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(Unknown Source) at org.geotools.xml.DocumentFactory.getInstance(DocumentFactory.java:108) at org.geotools.xml.DocumentFactory.getInstance(DocumentFactory.java:81) at org.geotools.xml.gml.FCBuffer.run(FCBuffer.java:335) (Don't pay attention to the korean caracters =EC=98=A4=EC =84 that mean "wednesday" ;) ) I tested different things but I almost always get the same exception (nullPointer). Can't use any of the methods of the GMLDataStore class without raising an exception, appart from the getSchema that seems to work. Any idea? I attached the .xml and .xsd files used for the example. --=20 Adrien ANSELME -------------- Etudiant en G=C3=A9nie Informatique =C3 l'UTC http://www.utc.fr page professionnelle (cv): http://wwwetu.utc.fr/~adanselm/ page perso: http://adrien.adan.free.fr id jabber : aan...@am... ----- End forwarded message ----- ---------------------------------------------------------- This mail sent through IMP: https://webmail.limegroup.com/ |