Hi Justin,

thanks for your help on this. However, it was not quite what I wanted to 
achieve. Actually, I had already managed to get it to work *not* 
ignoring the schema. And this worked well enough, if just a little slow.

So actually what I was trying to do is not use the schema and see 
whether this would be faster. That's why I started experimenting with 
the IGNORE_SCHEMA_LOCATION property, which threw the strange exceptions.

Any new ideas why the parser apparently does not ignore the schema even 
though it's told so? (If not, no worries - as I said, the 
schema-assisted parsing works fine, I just wanted to see if there's a 
faster alternative...)

Cheers,
Michael


Justin Deoliveira wrote:
> Hi Michael,
> 
> I took a look at this and was able to successfully stream parse the
> feature collection. Here is the code:
> 
> 
> GMLConfiguration configuration = new GMLConfiguration();
> configuration.getProperties().add(Parser.Properties.PARSE_UNKNOWN_ELEMENTS);
> 
> InputStream xml = new URL("http://pisa007.....";).openStream();
> 
> StreamingParser parser = new StreamingParser(configuration, xml,
> "//featureMember");
> 
> Feature f = null;
> while( ( f = (Feature) parser.parse()  ) != null ) {
>   //do something with feature
> }
> 
> This relies on a recent fix to the parser, so make sure you are working
> with recent snapshots of both gt2-xml-xsd and gt2-xml-gml2. The easiest
> way to ensure you have a recent snapshot would be to depend on with via
> a maven project, not sure if you can do that though.
> 
> I apologize for initially misdiagnosing your problem. You actually don't
> want to use the property IGNORE_SCHEMA_LOCATION in this case since the
> document correctly specifies the definition of the application schemas.
> 
> Please let me know if you have any more problems.
> 
> -Justin
> 
> 
> Michael Lutz wrote:
>> Hi Justin, Andrea,
>>
>> here's my code. The WFS (GeoServer) request included should work as an 
>> example.
>>
>>
>> public static void main(String[] args) {
>>    try {
>>      InputStream in = new 
>> URL("http://pisa007.pisa.intecs.it/geoserver/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=topp:Portugal_Creation_20Points";)
>>                                              .openStream();
>>      Configuration configuration  = new WFSConfiguration();          
>>      configuration.getProperties().add( 
>> Parser.Properties.IGNORE_SCHEMA_LOCATION );
>>      configuration.getProperties().add( 
>> Parser.Properties.PARSE_UNKNOWN_ELEMENTS );
>>      Parser parser = new Parser(configuration);
>>      Map map = (Map) parser.parse(in);
>>      List members = (List) map.get( "featureMember" );
>>      for ( Iterator i = members.iterator(); i.hasNext(); ) {
>>        Map f = (Map) i.next();
>>        Point point = (Point) f.get( "pointProperty" );
>>      }
>>      in.close();
>>    } catch (Throwable t) {
>>      t.printStackTrace();
>> }
>>
>>
>> I also tried with a streaming parser:
>>
>>      (...)
>>      String xpath = "//Point";
>>      StreamingParser parser = new StreamingParser( configuration, in, 
>> xpath );
>>      Point f = null;
>>      while(  (f = (Point) parser.parse()) != null ) {
>>      // do something
>>      }
>>      (...)
>>
>> but with the same effect:
>>
>> Exception in thread "Thread-0" java.lang.RuntimeException: 
>> java.lang.RuntimeException: Parsing failed for 
>> Portugal_Creation_20Points: 
>> org.geotools.feature.IllegalAttributeException: No attribute named the_geom
>>      at org.geotools.xml.StreamingParser$1.run(StreamingParser.java:227)
>>      at java.lang.Thread.run(Unknown Source)
>> Caused by: java.lang.RuntimeException: Parsing failed for 
>> Portugal_Creation_20Points: 
>> org.geotools.feature.IllegalAttributeException: No attribute named the_geom
>>      at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:96)
>>      at 
>> org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:204)
>>      at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:163)
>>      at 
>> org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:191)
>>      at 
>> org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:399)
>>      at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
>> Source)
>>      at 
>> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown 
>> Source)
>>      at 
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>>  
>> Source)
>>      at 
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
>> Source)
>>      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>>      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>>      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>>      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>>      at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
>> Source)
>>      at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>      at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>      at org.geotools.xml.StreamingParser$1.run(StreamingParser.java:223)
>>      ... 1 more
>> Caused by: org.geotools.feature.IllegalAttributeException: No attribute 
>> named the_geom
>>      at 
>> org.geotools.feature.DefaultFeature.setAttribute(DefaultFeature.java:283)
>>      at 
>> org.geotools.gml2.bindings.GMLAbstractFeatureTypeBinding.parse(GMLAbstractFeatureTypeBinding.java:236)
>>      at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:84)
>>      ... 17 more
>>
>>
>> Also the same for the GMLConfiguration.
>>
>> Hope this helps. Thanks again for your help.
>> Michael
>>
>>
>>
>> Justin Deoliveira wrote:
>>>> Michal, I think we would be able to solve this faster if you could
>>>> give us a small GML document and a main with the code you're using
>>>> to parse it. Add a bit of patience too, since Justin lives in Canada, west 
>>>> coast,
>>>> so he's quite out of synch with our timezone.
>>> Well I believe it is a bit more complicated then just a simple gml file.
>>> Michael is trying to parse features from a wfs. But by all means send me
>>> some sample xml and the code you are using to parse and I would be happy
>>> to debug what is going on and help you worth through this issue.
>>>
>>>> Cheers
>>>> Andrea
>>>>
>>>> -------------------------------------------------------------------------
>>>> 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,45df1e41215174750375898!
>>
> 
> 


-------------------------------------------------------------------------
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

Reply via email to