Search in sources :

Example 1 with XmlInstanceReader

use of eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader in project hale by halestudio.

the class FilterTest method loadXMLInstances.

private InstanceCollection loadXMLInstances(URI schemaLocation, URI xmlLocation) throws IOException, IOProviderConfigurationException {
    SchemaReader reader = new XmlSchemaReader();
    reader.setSharedTypes(null);
    reader.setSource(new DefaultInputSupplier(schemaLocation));
    IOReport schemaReport = reader.execute(null);
    assertTrue(schemaReport.isSuccess());
    Schema sourceSchema = reader.getSchema();
    // 
    InstanceReader instanceReader = new XmlInstanceReader();
    instanceReader.setSource(new DefaultInputSupplier(xmlLocation));
    instanceReader.setSourceSchema(sourceSchema);
    IOReport instanceReport = instanceReader.execute(null);
    assertTrue(instanceReport.isSuccess());
    return instanceReader.getInstances();
}
Also used : ShapeInstanceReader(eu.esdihumboldt.hale.io.shp.reader.internal.ShapeInstanceReader) InstanceReader(eu.esdihumboldt.hale.common.instance.io.InstanceReader) GmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.GmlInstanceReader) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) ShapeSchemaReader(eu.esdihumboldt.hale.io.shp.reader.internal.ShapeSchemaReader) SchemaReader(eu.esdihumboldt.hale.common.schema.io.SchemaReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Example 2 with XmlInstanceReader

use of eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader in project hale by halestudio.

the class TestUtil method loadInstances.

/**
 * Loads an instance collection from the specified XML file with the given
 * source types.
 *
 * @param location the URI specifying the location of the xml instance file
 * @param types the type index
 * @return the loaded instance collection
 * @throws IOException if loading the instance failed
 * @throws IOProviderConfigurationException if configuring the instance
 *             reader failed
 */
public static InstanceCollection loadInstances(URI location, Schema types) throws IOProviderConfigurationException, IOException {
    DefaultInputSupplier input = new DefaultInputSupplier(location);
    XmlInstanceReader instanceReader = new XmlInstanceReader();
    instanceReader.setSource(input);
    instanceReader.setSourceSchema(types);
    IOReport report = instanceReader.execute(null);
    assertTrue(report.isSuccess());
    assertTrue("Errors are contained in the report", report.getErrors().isEmpty());
    return instanceReader.getInstances();
}
Also used : DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Example 3 with XmlInstanceReader

use of eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader in project hale by halestudio.

the class PropertyResolverTest method loadXMLInstances.

private InstanceCollection loadXMLInstances(URI schemaLocation, URI xmlLocation) throws IOException, IOProviderConfigurationException {
    SchemaReader reader = new XmlSchemaReader();
    reader.setSharedTypes(null);
    reader.setSource(new DefaultInputSupplier(schemaLocation));
    IOReport schemaReport = reader.execute(null);
    assertTrue(schemaReport.isSuccess());
    Schema sourceSchema = reader.getSchema();
    // 
    InstanceReader instanceReader = new XmlInstanceReader();
    instanceReader.setParameter(XmlInstanceReader.PARAM_IGNORE_ROOT, Value.of(false));
    instanceReader.setSource(new DefaultInputSupplier(xmlLocation));
    instanceReader.setSourceSchema(sourceSchema);
    IOReport instanceReport = instanceReader.execute(null);
    assertTrue(instanceReport.isSuccess());
    return instanceReader.getInstances();
}
Also used : InstanceReader(eu.esdihumboldt.hale.common.instance.io.InstanceReader) GmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.GmlInstanceReader) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) SchemaReader(eu.esdihumboldt.hale.common.schema.io.SchemaReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Aggregations

IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)3 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)3 XmlInstanceReader (eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader)3 InstanceReader (eu.esdihumboldt.hale.common.instance.io.InstanceReader)2 SchemaReader (eu.esdihumboldt.hale.common.schema.io.SchemaReader)2 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)2 GmlInstanceReader (eu.esdihumboldt.hale.io.gml.reader.internal.GmlInstanceReader)2 XmlSchemaReader (eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader)2 ShapeInstanceReader (eu.esdihumboldt.hale.io.shp.reader.internal.ShapeInstanceReader)1 ShapeSchemaReader (eu.esdihumboldt.hale.io.shp.reader.internal.ShapeSchemaReader)1