本文整理了Java中org.geotools.xml.Parser.setValidating()
方法的一些代码示例,展示了Parser.setValidating()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.setValidating()
方法的具体详情如下:
包路径:org.geotools.xml.Parser
类名称:Parser
方法名:setValidating
[英]Sets the flag controlling wether the parser should validate or not.
[中]设置控制解析器是否应验证的标志。
代码示例来源:origin: org.geoserver.extension/wps-core
@SuppressWarnings("unchecked")
public Object read(Object request, Reader reader, Map kvp) throws Exception {
Parser parser = new Parser(configuration);
parser.setValidating(true);
Object parsed;
try {
parsed = parser.parse(reader);
} catch(Exception e) {
throw new WPSException("Could not parse XML request.", e);
}
if (!parser.getValidationErrors().isEmpty()) {
WPSException exception = new WPSException("Invalid request", "InvalidParameterValue");
for(Exception error : (List<Exception>)parser.getValidationErrors()) {
LOGGER.warning( error.getLocalizedMessage() );
exception.getExceptionText().add(error.getLocalizedMessage());
}
}
return parsed;
}
}
代码示例来源:origin: org.geoserver.extension/gs-wps-core
@SuppressWarnings("unchecked")
public Object read(Object request, Reader reader, Map kvp) throws Exception {
Parser parser = new Parser(configuration);
parser.setValidating(true);
parser.setEntityResolver(resolverProvider.getEntityResolver());
Object parsed;
try {
parsed = parser.parse(reader);
} catch (Exception e) {
throw new WPSException("Could not parse XML request.", e);
}
if (!parser.getValidationErrors().isEmpty()) {
WPSException exception = new WPSException("Invalid request", "InvalidParameterValue");
for (Exception error : (List<Exception>) parser.getValidationErrors()) {
LOGGER.warning(error.getLocalizedMessage());
exception.getExceptionText().add(error.getLocalizedMessage());
}
}
return parsed;
}
}
代码示例来源:origin: org.geoserver/gs-wfs
public static void initRequestParser(Parser parser, WFSInfo wfs, GeoServer geoServer, Map kvp) {
// check the strict flag to determine if we should validate or not
Boolean strict = (Boolean) kvp.get("strict");
if (strict == null) {
strict = Boolean.FALSE;
}
// check for cite compliance, we always validate for cite
if (wfs.isCiteCompliant()) {
strict = Boolean.TRUE;
}
parser.setValidating(strict.booleanValue());
WFSURIHandler.addToParser(geoServer, parser);
Catalog catalog = geoServer.getCatalog();
// "inject" namespace mappings
parser.getNamespaces().add(new CatalogNamespaceSupport(catalog));
}
代码示例来源: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/gs-wfs
parser.setValidating(strict.booleanValue());
WFSURIHandler.addToParser(geoServer, parser);
代码示例来源:origin: org.geoserver/wfsv
parser.setValidating(true);
代码示例来源: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-wms
/**
* Validates a document against the
*
* @param dom
* @param configuration
*/
@SuppressWarnings("rawtypes")
protected void checkWms13ValidationErrors(Document dom) throws Exception {
Parser p =
new Parser(
(Configuration)
Class.forName("org.geotools.wms.v1_3.WMSConfiguration")
.newInstance());
p.setValidating(true);
p.parse(new DOMSource(dom));
if (!p.getValidationErrors().isEmpty()) {
for (Iterator e = p.getValidationErrors().iterator(); e.hasNext(); ) {
SAXParseException ex = (SAXParseException) e.next();
System.out.println(
ex.getLineNumber() + "," + ex.getColumnNumber() + " -" + ex.toString());
}
fail("Document did not validate.");
}
}
代码示例来源:origin: org.geoserver.extension/wps-core
/**
* Validates a document against the
* @param dom
* @param configuration
*/
protected void checkValidationErrors(Document dom, Configuration configuration) throws Exception {
Parser p = new Parser(configuration);
p.setValidating( true );
p.parse( new DOMSource( dom ) );
if ( !p.getValidationErrors().isEmpty() ) {
for ( Iterator e = p.getValidationErrors().iterator(); e.hasNext(); ) {
SAXParseException ex = (SAXParseException) e.next();
System.out.println( ex.getLineNumber() + "," + ex.getColumnNumber() + " -" + ex.toString() );
}
fail( "Document did not validate.");
}
}
代码示例来源:origin: org.geoserver.csw/csw-core
/**
* Validates a document against the
*
* @param dom
* @param configuration
*/
protected void checkValidationErrors(Document dom, Configuration configuration)
throws Exception {
Parser p = new Parser(configuration);
p.setValidating(true);
p.parse(new DOMSource(dom));
if (!p.getValidationErrors().isEmpty()) {
for (Iterator e = p.getValidationErrors().iterator(); e.hasNext();) {
SAXParseException ex = (SAXParseException) e.next();
System.out.println(ex.getLineNumber() + "," + ex.getColumnNumber() + " -"
+ ex.toString());
}
fail("Document did not validate.");
}
}
代码示例来源:origin: org.geoserver/gs-wfs
@Test
public void testInvalid() throws Exception {
Parser parser = new Parser(configuration());
parser.setValidating(true);
parser.parse(getClass().getResourceAsStream("GetFeature-invalid.xml"));
assertTrue(parser.getValidationErrors().size() > 0);
}
}
代码示例来源:origin: org.geoserver/gs-wcs2_0
/**
* Validates a document against the
*
* @param dom
* @param configuration
*/
@SuppressWarnings("rawtypes")
protected void checkValidationErrors(Document dom) throws Exception {
Parser p = new Parser(new WCSConfiguration());
p.setValidating(true);
p.parse(new DOMSource(dom));
if (!p.getValidationErrors().isEmpty()) {
for (Iterator e = p.getValidationErrors().iterator(); e.hasNext(); ) {
SAXParseException ex = (SAXParseException) e.next();
System.out.println(
ex.getLineNumber() + "," + ex.getColumnNumber() + " -" + ex.toString());
}
fail("Document did not validate.");
}
}
代码示例来源: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/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.csw/csw-core
Parser parser = new Parser(new OGCConfiguration());
parser.setFailOnValidationError(true);
parser.setValidating(true);
parser.getNamespaces().declarePrefix("ogc", OGC.NAMESPACE);
Filter filter = (Filter) parser.parse(new StringReader(constraint));
代码示例来源:origin: org.geoserver.csw/gs-csw-core
Parser parser = new Parser(new OGCConfiguration());
parser.setFailOnValidationError(true);
parser.setValidating(true);
parser.setEntityResolver(resolverProvider.getEntityResolver());
parser.getNamespaces().declarePrefix("ogc", OGC.NAMESPACE);
代码示例来源:origin: org.geoserver/gs-wfs
@Test
public void testValidCapabilitiesDocument() throws Exception {
print(getAsDOM("wfs?service=WFS&version=2.0.0&request=getCapabilities"));
InputStream in = get("wfs?service=WFS&version=2.0.0&request=getCapabilities");
Parser p = new Parser(new WFSConfiguration());
p.setValidating(true);
p.validate(in);
for (Exception e : (List<Exception>) p.getValidationErrors()) {
System.out.println(e.getLocalizedMessage());
}
assertTrue(p.getValidationErrors().isEmpty());
}
内容来源于网络,如有侵权,请联系作者删除!