Michael Lutz wrote: > Thanks. The StreamingParser works considerably better (if a little > slower). Note that the xPath expression must be "//featureMember" > (without the prefix). Right.. :) JXPath seems to not like the prefixes..., probably how the context is being setup.
Yeah the streaming parser will be considerably slower. I haven't quite got around to optimizing it yet. Right now a jxpath context is created for each element that gets parsed, this could definitely be improved. > I also tried "Alternative 2: Ignoring the Application Schema", but this > didn't work. I get > > org.xml.sax.SAXException: Handler for wfs:FeatureCollection could not be > found. > at > org.geotools.xml.impl.ParserHandler.startElement(ParserHandler.java:357) > at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown > Source) > at ... > > I don't understand why the parser requires a handler for > "wfs:FeatureCollection" if I tell it to ignore the schema? When I use > the WFSConfiguration (which I created for WFS feature collections) > instead of GMLConfiguration, I get the same exception for the > application schema type, i.e. test:TestFeature in the example. > Sorry, the docs are somewhat at fault here :). You also need to specify the following property: configuration.getProperties().add(Parser.Properties.PARSE_UNKNOWN_ELEMENTS); Also, how recent is the snapshot you are working from? I have recently made some changes that make the parser a bit more lax when it comes to this situation. We have nigthtly snapshots going now so it should be available. -Justin > Any ideas? > > Cheers, > Michael > > > Justin Deoliveira wrote: >> Hi Michael, >> >> I suggest for any reasonable size dataset you use the StreamingParser: >> >> StreamingParser parser = >> new StreamingParser(configuration,"//gml:featureMember"); >> >> try{ >> Feature f = null; >> while ( ( f = parser.parse() ) != null ) { >> ... >> } >> >> }... >> } >> >> Some more info about streaming here: >> >> http://docs.codehaus.org/display/GEOTDOC/GML+XML+Support >> >> -Justin >> >> Michael Lutz wrote: >>> We are running into big memory problems when trying to parse large GML >>> files containing WFS feature collections (e.g. 25000 points, about 25MB >>> as GML) using the following code: >>> >>> public static FeatureCollection readFromInputStream(InputStream in) { >>> Configuration configuration = new WFSConfiguration(); >>> Parser parser = new Parser(configuration); >>> try{ >>> FeatureCollection fc = (FeatureCollection) parser.parse( in ); >>> in.close(); >>> return fc; >>> } ... >>> } >>> >>> For this example, the used memory goes up to 800MB. After the parsing, >>> it goes down again to around 60MB. >>> >>> Any ideas why this is, and where we should be looking for memory leaks? >>> >>> Cheers, >>> Michael >>> >>> ------------------------------------------------------------------------- >>> Take Surveys. Earn Cash. Influence the Future of IT >>> Join SourceForge.net's Techsay panel and you'll get the chance to share your >>> opinions on IT & business topics through brief surveys-and earn cash >>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >>> _______________________________________________ >>> Geotools-devel mailing list >>> Geotools-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/geotools-devel >>> >>> >>> >> > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Geotools-devel mailing list > Geotools-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-devel > > !DSPAM:1004,45dd6e58260167731818748! > -- Justin Deoliveira The Open Planning Project http://topp.openplans.org ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel