@Test public void parse_geosciml() throws MalformedURLException, IOException { SchemaResolver appSchemaResolver = new SchemaResolver(); EmfComplexFeatureReader reader = EmfComplexFeatureReader.newInstance(); reader.setResolver(appSchemaResolver); FeatureTypeRegistry typeRegistry = new FeatureTypeRegistry( new ComplexFeatureTypeFactoryImpl(), new GmlFeatureTypeRegistryConfiguration(null)); typeRegistry.addSchemas( reader.parse(new URL("http: AttributeDescriptor descriptor = typeRegistry.getDescriptor( new NameImpl("urn:cgi:xmlns:CGI:GeoSciML:2.0", ":", "Borehole"), null); FeatureType featureType = (FeatureType) descriptor.getType(); XmlComplexFeatureParser boreholeParser = new XmlComplexFeatureParser( getResourceAsFileInputStream("wfs_response_borehole.xml"), featureType, new QName("urn:cgi:xmlns:CGI:GeoSciML:2.0", "Borehole", "gsml")); Feature feature = boreholeParser.parse(); Assert.assertEquals("gsml.borehole.rd001", feature.getIdentifier().toString()); Object[] names = feature.getProperties("name").toArray(); Assert.assertEquals( "AttributeImpl:name<CodeType>=[AttributeImpl:simpleContent<string>=http: names[0].toString()); Assert.assertEquals( "AttributeImpl:name<CodeType>=[AttributeImpl:simpleContent<string>=rd001]", names[1].toString()); Assert.assertEquals( "ComplexAttributeImpl:BoreholeCollarPropertyType=[FeatureImpl:BoreholeCollar<BoreholeCollarType id=gsml.borehole.collar.rd001>=[FeatureImpl:BoreholeCollarType<BoreholeCollarType id=gsml.borehole.collar.rd001>=[ComplexAttributeImpl:elevation<DirectPositionType>=[AttributeImpl:simpleContent<doubleList>=0.0]]]]", feature.getProperty("BoreholeCollarPropertyType").toString()); Assert.assertEquals( "ComplexAttributeImpl:BoreholeDetailsPropertyType=[ComplexAttributeImpl:BoreholeDetails<BoreholeDetailsType>=[ComplexAttributeImpl:BoreholeDetailsType=[ComplexAttributeImpl:driller<ReferenceType>=[], AttributeImpl:drillingMethod<BoreholeDrillingMethodCodeType>=Diamond, AttributeImpl:startPoint<BoreholeStartPointCodeType>=natural ground surface, AttributeImpl:inclinationType<BoreholeInclinationCodeType>=vertical, ComplexAttributeImpl:coredInterval<BoundingShapeType>=[ComplexAttributeImpl:BoundingShapeType=[ComplexAttributeImpl:Envelope<EnvelopeType>=[ComplexAttributeImpl:EnvelopeType=[ComplexAttributeImpl:lowerCorner<DirectPositionType>=[AttributeImpl:simpleContent<doubleList>=0.0], ComplexAttributeImpl:upperCorner<DirectPositionType>=[AttributeImpl:simpleContent<doubleList>=324.6]]]]], ComplexAttributeImpl:coreCustodian<ReferenceType>=[]]]]", feature.getProperty("BoreholeDetailsPropertyType").toString()); }
@Override public Feature parse() throws IOException { final String fid; try { if ((fid = seekFeature()) == null) { return null; } ReturnAttribute nextAttribute; while ((nextAttribute = parseNextAttribute(this.targetType)) != null) { if (!Property.class.isAssignableFrom(nextAttribute.value.getClass())) { featureBuilder.append( nextAttribute.name, new AttributeImpl( nextAttribute.value, (AttributeDescriptor) this.targetType.getDescriptor(nextAttribute.name), null)); } else { featureBuilder.append(nextAttribute.name, (Property) nextAttribute.value); } } } catch (XmlPullParserException e) { throw new DataSourceException(e); } Feature feature = featureBuilder.buildFeature(fid); if (filter == null || filter.evaluate(feature)) { return feature; } return null; }
XmlComplexFeatureParser extends XmlFeatureParser<FeatureType, Feature> { @Override public Feature parse() throws IOException { final String fid; try { if ((fid = seekFeature()) == null) { return null; } ReturnAttribute nextAttribute; while ((nextAttribute = parseNextAttribute(this.targetType)) != null) { if (!Property.class.isAssignableFrom(nextAttribute.value.getClass())) { featureBuilder.append( nextAttribute.name, new AttributeImpl( nextAttribute.value, (AttributeDescriptor) this.targetType.getDescriptor(nextAttribute.name), null)); } else { featureBuilder.append(nextAttribute.name, (Property) nextAttribute.value); } } } catch (XmlPullParserException e) { throw new DataSourceException(e); } Feature feature = featureBuilder.buildFeature(fid); if (filter == null || filter.evaluate(feature)) { return feature; } return null; } }
XmlComplexFeatureParser extends XmlFeatureParser<FeatureType, Feature> { @Override public Feature parse() throws IOException { final String fid; try { if ((fid = seekFeature()) == null) { return null; } ReturnAttribute nextAttribute; while ((nextAttribute = parseNextAttribute(this.targetType)) != null) { if (!Property.class.isAssignableFrom(nextAttribute.value.getClass())) { featureBuilder.append( nextAttribute.name, new AttributeImpl( nextAttribute.value, (AttributeDescriptor) this.targetType.getDescriptor(nextAttribute.name), null)); } else { featureBuilder.append(nextAttribute.name, (Property) nextAttribute.value); } } } catch (XmlPullParserException e) { throw new DataSourceException(e); } Feature feature = featureBuilder.buildFeature(fid); if (filter == null || filter.evaluate(feature)) { return feature; } return null; } XmlComplexFeatureParser(
            InputStream getFeatureResponseStream,
            FeatureType targetType,
            QName featureDescriptorName);  XmlComplexFeatureParser(
            InputStream getFeatureResponseStream,
            FeatureType targetType,
            QName featureDescriptorName,
            Filter filter); }
XmlComplexFeatureParser extends XmlFeatureParser<FeatureType, Feature> { @Override public Feature parse() throws IOException { final String fid; try { if ((fid = seekFeature()) == null) { return null; } ReturnAttribute nextAttribute; while ((nextAttribute = parseNextAttribute(this.targetType)) != null) { if (!Property.class.isAssignableFrom(nextAttribute.value.getClass())) { featureBuilder.append( nextAttribute.name, new AttributeImpl( nextAttribute.value, (AttributeDescriptor) this.targetType.getDescriptor(nextAttribute.name), null)); } else { featureBuilder.append(nextAttribute.name, (Property) nextAttribute.value); } } } catch (XmlPullParserException e) { throw new DataSourceException(e); } Feature feature = featureBuilder.buildFeature(fid); if (filter == null || filter.evaluate(feature)) { return feature; } return null; } XmlComplexFeatureParser(
            InputStream getFeatureResponseStream,
            FeatureType targetType,
            QName featureDescriptorName);  XmlComplexFeatureParser(
            InputStream getFeatureResponseStream,
            FeatureType targetType,
            QName featureDescriptorName,
            Filter filter); @Override Feature parse(); }
XmlComplexFeatureParser extends XmlFeatureParser<FeatureType, Feature> { @Override public Feature parse() throws IOException { final String fid; try { if ((fid = seekFeature()) == null) { return null; } ReturnAttribute nextAttribute; while ((nextAttribute = parseNextAttribute(this.targetType)) != null) { if (!Property.class.isAssignableFrom(nextAttribute.value.getClass())) { featureBuilder.append( nextAttribute.name, new AttributeImpl( nextAttribute.value, (AttributeDescriptor) this.targetType.getDescriptor(nextAttribute.name), null)); } else { featureBuilder.append(nextAttribute.name, (Property) nextAttribute.value); } } } catch (XmlPullParserException e) { throw new DataSourceException(e); } Feature feature = featureBuilder.buildFeature(fid); if (filter == null || filter.evaluate(feature)) { return feature; } return null; } XmlComplexFeatureParser(
            InputStream getFeatureResponseStream,
            FeatureType targetType,
            QName featureDescriptorName);  XmlComplexFeatureParser(
            InputStream getFeatureResponseStream,
            FeatureType targetType,
            QName featureDescriptorName,
            Filter filter); @Override Feature parse();  }