try {
Parser parser = new Parser( config );
reader = new FileReader(file);
Object object = parser.parse( reader );
if( object instanceof StyledLayerDescriptor){
StyledLayerDescriptor sld = (StyledLayerDescriptor) object;
return sld;
}
else if ( object instanceof NamedStyle ){
NamedStyle style = (NamedStyle) object;
StyledLayerDescriptor sld = createDefaultSLD( style );
return sld;
}
}
catch(Exception ignore){
// we are ignoring this error and will try the more forgiving option below
UiPlugin.trace(SLDs.class,"SLD 1.1 configuration failed to parse "+file, ignore);
}
finally {
if( reader != null){
reader.close();
}
}
// parse it up
SLDParser parser = new SLDParser(styleFactory);
try {
parser.setInput(file);
StyledLayerDescriptor sld = parser.parseSLD();
return sld;
} catch (FileNotFoundException e) {
return null; // well that is unexpected since f.exists()
}
}