|
From: Justin D. <jde...@op...> - 2007-12-03 13:12:51
|
Hi all, Been on vacation so coming in late. Nice work on figuring this out!! There definitely needs to be a utility method somewhere that wraps this up because doing all that is nasty. The question is where to put it. When parsing gml, the code that does this is in GML2ParsingUtils... but it is not really set up to be something that this called from application code, its called from a binding. I tried to create said method before but ran into issues because the type mappings required the bindings to be around which as you can see requires the contianer. This is kind of ugly. So i experimented with the idea of the "Schema" class, which defined type to class mappings as well, narrowing to a "Profile" which defines the mappings in a java class unique way. My type mapping profile idea never gained all that much steam... but is probably something we should revisit. The pain is that it duplicates a lot of what the bindings do... agghh... a mess. Anyways, for now if this works then lets go for it. Saul what do you think about putting it in the wfs xml module since it already depends on both filter and gml. I am also curious to here gabriels thoughts on this. -Justin Saul Farber wrote: > Ok, replying to my own email again. > > Here's how to do it with the streaming parser (the "xml binding" parser > as you call it). Watch out, it's a bit longer. > > > String parseurl = > "http://giswebservices.massgis.state.ma.us/geoserver/wms?request=describefeaturetype&service=wfs&version=1.0.0&typeName=massgis:GISDATA.TOWNS_POLYM"; > //InputStream inStr = new > URL(parseurl).openConnection().getInputStream(); > > Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", > new XSDResourceFactoryImpl()); > ResourceSet resourceSet = new ResourceSetImpl(); > XSDResourceImpl xsdSchemaResource = > (XSDResourceImpl)resourceSet.getResource(URI.createURI(parseurl), true); > > XSDSchema schema = null; > for (Iterator resources = resourceSet.getResources().iterator(); > resources.hasNext(); /* no-op */) { > Resource res = (Resource)resources.next(); > if (res instanceof XSDResourceImpl) { > schema = ((XSDResourceImpl)res).getSchema(); > break; > } > } > > Configuration config = new OGCConfiguration(); > MutablePicoContainer ctx = new DefaultPicoContainer(); > ctx = config.setupContext(ctx); > BindingLoader bindingLoader = new BindingLoader(); > BindingWalker bindingWalker = new BindingWalker( bindingLoader ); > > //configure the bindings > MutablePicoContainer container = bindingLoader.getContainer(); > container = config.setupBindings( container ); > bindingLoader.setContainer( container ); > BindingWalkerFactory bwf = new BindingWalkerFactoryImpl( bindingLoader , > ctx ); > > > List eltDecs = schema.getElementDeclarations(); > FeatureType ft = null; > for (int i = 0; i < eltDecs.size(); i++) { > XSDElementDeclaration xsdElt = (XSDElementDeclaration)eltDecs.get(i); > if (xsdElt.getName().contains("GISDATA")) { > System.out.println("ft declr: " + eltDecs.get(i)); > ft = GML2ParsingUtils.featureType(xsdElt, bwf); > } > } > > System.out.println("ft is " + ft); > > > > > Any ideas about a utility class where I might stick this? I'll poke > around a bit in the code and see if I can come up with anything. Also > I'll ask Justin when he gets back (as this is largely his area of > expertise/code, right?) > > --saul > > > > > On Fri, 2007-11-30 at 12:51 -0500, Saul Farber wrote: >> Hey all, >> >> So I know on some level that there's code to read a .XSD file and turn >> it into a FeatureType object (at minimum for GML2 there's the 'old' SAX >> parsing stuff in gt2-xml). >> >> My goal is something like this: >> >> FeatureType t = FeatureTypeFromSchema.readXSD(new >> File("myfeaturetype.xsd)); >> >> t.getNumAttributes(); >> ... >> >> >> Any hints on whether this is possible? Any classes to look at? >> >> --saul >> >> >> ------------------------------------------------------------------------- >> SF.Net email is sponsored by: The Future of Linux Business White Paper >> from Novell. From the desktop to the data center, Linux is going >> mainstream. Let it simplify your IT future. >> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 >> _______________________________________________ >> Geotools-devel mailing list >> Geo...@li... >> https://lists.sourceforge.net/lists/listinfo/geotools-devel > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > _______________________________________________ > Geotools-devel mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-devel > > !DSPAM:4007,47509970275301431913854! > -- Justin Deoliveira The Open Planning Project http://topp.openplans.org |