Issue Type: Bug Bug
Assignee: Unassigned
Attachments: test.gml
Components: xml
Created: 08/Apr/13 5:20 PM
Description:

The parser is unable to cast an int to a String when trying to create a SimpleFeature from a GML file containing OS Mastermap Topographic layer data.

Code:

 public static void main( String[] args ) throws Exception
    {
        System.out.println( "Hello World!" );

        InputStream in = new FileInputStream("C:\\tmp\\Download_small+testset_63185\\mastermap-topo_150544\\test.gml");
                
        GML gml = new GML(Version.WFS1_1);
        CRSAuthorityFactory crsFac = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null);
        CoordinateReferenceSystem osgbCrs = crsFac.createCoordinateReferenceSystem("EPSG:27700");
        gml.setCoordinateReferenceSystem(osgbCrs);
        
        SimpleFeatureIterator iter = gml.decodeFeatureIterator(in);
        while (iter.hasNext())
        {
        	System.out.println(iter.next());
        	break;
        }

        System.out.println("done!");
 }

Error log:

 
Hello World!
Apr 08, 2013 11:07:40 PM org.geotools.xml.impl.HTTPURIHandler createInputStream
INFO: http://www.ordnancesurvey.co.uk/xml/schema/v6/OSDNFFeatures.xsd
Apr 08, 2013 11:07:43 PM org.geotools.xml.Schemas getImports
INFO: Schema import wasn't resolved: http://www.w3.org/1999/xlink declared location: null
done!
Exception in thread "Thread-2" java.lang.RuntimeException: java.lang.RuntimeException: Parsing failed for featureCode: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at org.geotools.xml.StreamingParser$1.run(StreamingParser.java:250)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Parsing failed for featureCode: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:164)
	at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:227)
	at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:186)
	at org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:236)
	at org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:719)
	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.DTDConfiguration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.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:246)
	... 1 more
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at org.geotools.xs.bindings.XSUnsignedLongBinding.parse(XSUnsignedLongBinding.java:93)
	at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:153)
	... 16 more

Most relevant part of the GML (see attachment for more):

<osgb:CartographicSymbol fid="osgb1000001161051405">
<osgb:featureCode>10066</osgb:featureCode>
<osgb:version>3</osgb:version>
<osgb:versionDate>2008-04-27</osgb:versionDate>
<osgb:theme>Terrain And Height</osgb:theme>

And relevant part of the XSD (http://www.ordnancesurvey.co.uk/xml/schema/v6/OSDNFFeatures.xsd):

This defines the properties common to all Ordnance Survey features.
</documentation>
        </annotation>
        <sequence>
            <element name="featureCode" type="unsignedInt" minOccurs="0"/>
            <element name="version" type="unsignedInt"/>
            <element name="versionDate" type="date"/>
            <element name="theme" type="osgb:themeType" maxOccurs="unbounded"/>
        </sequence>
    </group>
    <complexType name="AbstractFeatureType">
        <annotation>
            <documentation xml:lang="en">
    Abstract base type for all ordnance survey features.  Extends the gml abstract
    feature in order to ensure compliance with GML.
</documentation>

As far as I can trace the problem is that it the parser can't cast the value (10066 as unsignedInt) to a String such that it can be handled by java. Other numbers in the XML that are not classified in the XSD as unsignedInt can be parsed. So it feels like it's going wrong because the unsignedInt might accidentally be cast to a java object because it fits the object so well while all other types from the XSD make no relevance to the Java core objects.

Environment: Windows 7 x64, JRE 7, Eclipse Juno Service Release 1
Project: GeoTools
Priority: Major Major
Reporter: A Melchior
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to