Hi,
I am using ApplicationSchemaConfiguration for parsing a gml3 schema (here:
http://cweb.ksat.no/cweb/schema/geoweb/vessel/wfsvd.xsd) with gt 2.4.1
with a test file, when i launch my code i get a null pointer Exception (got
null schema).
but when i ask configuration.schema(), the schema is not null
any help appreciated


Gersh

test xml:
<?xml version="1.0" encoding="UTF-8"?>
<vd:featureCollection xmlns:vd="
http://cweb.ksat.no/cweb/schema/geoweb/vessel";
                      xmlns="http://www.w3.org/1999/xlink";
                      xmlns:gml="http://www.opengis.net/gml";
                      xmlns:sat="
http://cweb.ksat.no/cweb/schema/geoweb/satellite";
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                      xsi:schemaLocation="
http://cweb.ksat.no/cweb/schema/geoweb/vessel
http://cweb.ksat.no/cweb/schema/geoweb/vessel/wfsvd.xsd";>
    <gml:boundedBy>
        <gml:Envelope srsName="EPSG:4326">
            <gml:lowerCorner>54.5206 14.6195</gml:lowerCorner>
            <gml:upperCorner>58.0398 20.3325</gml:upperCorner>
        </gml:Envelope>
    </gml:boundedBy>
    <vd:featureMember>
        <vd:feature>
            <gml:name>0</gml:name>
            <vd:vesselPosition>
                <gml:Point srsName="EPSG:4326">
                    <gml:pos>54.5206 18.692</gml:pos>
                </gml:Point>
            </vd:vesselPosition>
            <vd:vesselType>ship</vd:vesselType>
            <vd:vesselLength>150</vd:vesselLength>
        </vd:feature>
    </vd:featureMember>
    <vd:featureMember>
        <vd:feature>
            <gml:name>1</gml:name>
            <vd:vesselPosition>
                <gml:Point srsName="EPSG:4326">
                    <gml:pos>54.7206 17.692</gml:pos>
                </gml:Point>
            </vd:vesselPosition>
            <vd:vesselType>ship</vd:vesselType>
            <vd:vesselLength>150</vd:vesselLength>
        </vd:feature>
    </vd:featureMember>
</vd:featureCollection>


java app:
public static FeatureCollection create(InputStream xml) throws IOException,
SAXException, ParserConfigurationException {

        String namespace = "http://cweb.ksat.no/cweb/schema/geoweb/vessel/";;
        String schemaLocation =
FeatureCollectionFactory.class.getClass().getResource("/wfsvd.xsd").toString();
        ApplicationSchemaConfiguration configuration = new
ApplicationSchemaConfiguration(namespace, schemaLocation);
        configuration.schema();
        //org.geotools.xml.Configuration  configuration = new
org.geotools.gml3.GMLConfiguration();
        Parser parser = new Parser(configuration);
        return (FeatureCollection) parser.parse(xml);
    }

    public static void save(FeatureCollection fc, String File){

    }

    public static void main(String args[]){
        InputStream xml = null;
        try {
            xml = new FileInputStream(new
FeatureCollectionFactory().getClass().getResource("/test.xml").getFile());
            FeatureCollection fc = create(xml);
            System.out.println(fc.getDefaultGeometry());
        } catch (IOException ex) {

Logger.getLogger(FeatureCollectionFactory.class.getName()).log(Level.SEVERE,
null, ex);
        } catch (SAXException ex) {

Logger.getLogger(FeatureCollectionFactory.class.getName()).log(Level.SEVERE,
null, ex);
        } catch (ParserConfigurationException ex) {

Logger.getLogger(FeatureCollectionFactory.class.getName()).log(Level.SEVERE,
null, ex);
        } finally {
            try {
                xml.close();
            } catch (IOException ex) {

Logger.getLogger(FeatureCollectionFactory.class.getName()).log(Level.SEVERE,
null, ex);
            }
        }
    }


error log:
Exception in thread "main" java.lang.NullPointerException: got null schema
        at
org.geotools.gml3.ApplicationSchemaConfiguration$1.resolveSchemaLocation(ApplicationSchemaConfiguration.java:132)
        at
org.geotools.xml.impl.ParserHandler.startElement(ParserHandler.java:265)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(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.geotools.xml.Parser.parse(Parser.java:185)
        at org.geotools.xml.Parser.parse(Parser.java:147)
        at
org.geoimage.ksatvds.FeatureCollectionFactory.create(FeatureCollectionFactory.java:33)
        at
org.geoimage.ksatvds.FeatureCollectionFactory.main(FeatureCollectionFactory.java:44)
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to