我试图从我的 xml 文件中获取空值,如下所示
<top:kadastroParselFeature gml:id="KADASTRO_PARSEL.1">
<top:olcek xsi:nil="true" />
</top:kadastroParselFeature>
但是我的解析器抛出了这样一个异常:
java.lang.RuntimeException: Parsing failed for kadastroParselFeature: java.lang.NullPointerException
at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:164)
at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:220)
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)
我的解析器配置是这样的:
org.geotools.xml.Configuration configuration = new org.geotools.gml2.GMLConfiguration();
org.geotools.xml.Parser parser = new org.geotools.xml.Parser( configuration );
parser.setFailOnValidationError(false);
HashMap<Object, Object> parsedMap = (HashMap<Object, Object>) parser.parse( isx);
如果我xsi:nill="true"
从元素中删除它返回 ""(空字符串) 但我需要 null 。
在http://docs.geotools.org/stable/userguide/library/xml/geometry.html有我的解析器的用法