本文整理了Java中org.geotools.xml.Parser.setFailOnValidationError()
方法的一些代码示例,展示了Parser.setFailOnValidationError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.setFailOnValidationError()
方法的具体详情如下:
包路径:org.geotools.xml.Parser
类名称:Parser
方法名:setFailOnValidationError
[英]Sets the flag which controls how the parser handles validation errors.
When this flag is set, the parser will throw an exception when it encounters a validation error. Otherise the error will be stored, retreivable from #getValidationErrors().
The default behavior is to set this flag to false
. So client code should explicitly set this flag if it is desired that the exception be thrown when the validation error occurs.
[中]设置控制解析器如何处理验证错误的标志。
设置此标志后,解析器在遇到验证错误时将引发异常。否则将存储错误,可从#getValidationErrors()检索。
默认行为是将此标志设置为false
。因此,如果希望在发生验证错误时引发异常,客户端代码应该显式设置该标志。
代码示例来源:origin: org.geoserver.csw/csw-core
@SuppressWarnings("unchecked")
public Object read(Object request, Reader reader, Map kvp) throws Exception {
Parser parser = new Parser(configuration);
parser.setValidating(true);
parser.setFailOnValidationError(true);
parser.setStrict(true);
Object parsed;
try {
parsed = parser.parse(reader);
} catch (Exception e) {
throw new ServiceException("Could not parse XML request.", e);
}
if (!parser.getValidationErrors().isEmpty()) {
ServiceException exception = new ServiceException("Invalid request",
"InvalidParameterValue");
for (Exception error : (List<Exception>) parser.getValidationErrors()) {
LOGGER.warning(error.getLocalizedMessage());
exception.getExceptionText().add(error.getLocalizedMessage());
}
}
return parsed;
}
}
代码示例来源:origin: org.geoserver.csw/gs-csw-core
@SuppressWarnings("unchecked")
public Object read(Object request, Reader reader, Map kvp) throws Exception {
Parser parser = new Parser(configuration);
parser.setValidating(true);
parser.setFailOnValidationError(true);
parser.setStrict(true);
parser.setEntityResolver(resolverProvider.getEntityResolver());
Object parsed;
try {
parsed = parser.parse(reader);
} catch (Exception e) {
throw new ServiceException("Could not parse XML request.", e);
}
if (!parser.getValidationErrors().isEmpty()) {
ServiceException exception =
new ServiceException("Invalid request", "InvalidParameterValue");
for (Exception error : (List<Exception>) parser.getValidationErrors()) {
LOGGER.warning(error.getLocalizedMessage());
exception.getExceptionText().add(error.getLocalizedMessage());
}
}
return parsed;
}
}
代码示例来源:origin: org.geoserver/wcs1_1
public Object read(Object request, Reader reader, Map kvp) throws Exception {
//create the parser instance
Parser parser = new Parser(configuration);
parser.setValidating(true);
parser.setFailOnValidationError(true);
parser.setStrict(true);
// parse
Object parsed;
try {
parsed = parser.parse(reader);
} catch(Exception e) {
throw new WcsException("Parsing failed, the xml request is most probably not compliant to the wcs schema", e);
}
return parsed;
}
}
代码示例来源:origin: org.geoserver/gs-wcs1_0
public Object read(Object request, Reader reader, Map kvp) throws Exception {
// create the parser instance
Parser parser = new Parser(configuration);
parser.setValidating(true);
parser.setFailOnValidationError(true);
parser.setStrict(true);
parser.setEntityResolver(resolverProvider.getEntityResolver());
// parse
Object parsed;
try {
parsed = parser.parse(reader);
} catch (Exception e) {
throw new WcsException(
"Parsing failed, the xml request is most probably not compliant to the wcs schema",
e);
}
return parsed;
}
}
代码示例来源:origin: org.geoserver/gs-wcs1_1
public Object read(Object request, Reader reader, Map kvp) throws Exception {
// create the parser instance
Parser parser = new Parser(configuration);
parser.setValidating(true);
parser.setFailOnValidationError(true);
parser.setStrict(true);
parser.setEntityResolver(resolverProvider.getEntityResolver());
// parse
Object parsed;
try {
parsed = parser.parse(reader);
} catch (Exception e) {
throw new WcsException(
"Parsing failed, the xml request is most probably not compliant to the wcs schema",
e);
}
return parsed;
}
}
代码示例来源:origin: org.geoserver.csw/csw-core
try {
Parser parser = new Parser(new OGCConfiguration());
parser.setFailOnValidationError(true);
parser.setValidating(true);
parser.getNamespaces().declarePrefix("ogc", OGC.NAMESPACE);
代码示例来源:origin: org.geoserver.csw/gs-csw-core
try {
Parser parser = new Parser(new OGCConfiguration());
parser.setFailOnValidationError(true);
parser.setValidating(true);
parser.setEntityResolver(resolverProvider.getEntityResolver());
内容来源于网络,如有侵权,请联系作者删除!