List<Exception> validate10(Object input, EntityResolver entityResolver) throws IOException { try (Reader reader = toReader(input)) { final SLDValidator validator = new SLDValidator(); validator.setEntityResolver(entityResolver); return validator.validateSLD(new InputSource(reader)); } }
/** * returns a better formated error message - suitable for framing. There's a more complex * version in StylesEditorAction. * * <p>This will kick out a VERY LARGE errorMessage. * * @param xml * @param errors */ public static String getErrorMessage(Reader xml, List errors) { return SLDValidator.getErrorMessage(xml, errors); }
SLDValidator validator = new SLDValidator(); List errors = null; errors = validator.validateSLD(in); } finally { if (in != null) { throw new ServiceException(SLDValidator.getErrorMessage(in, errors));
@Test public void testInvalid() throws Exception { SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(getClass().getResourceAsStream("invalid.sld")); // showErrors(errors); assertFalse(errors.isEmpty()); }
/** * validates against the SLD schema in the classpath * * @param xml * @param baseUrl GeoServer base URL */ public List validateSLD(InputStream xml) { return validateSLD(new InputSource(xml)); }
SLDValidator validator = new SLDValidator(); List errors = null; errors = validator.validateSLD(in, getMapRequest.getHttpServletRequest().getSession().getServletContext()); } finally { throw new WmsException(SLDValidator.getErrorMessage(in, errors));
@Test public void testValid() throws Exception { SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(getClass().getResourceAsStream("valid.sld")); // showErrors(errors); assertTrue(errors.isEmpty()); }
/** * validates against the SLD schema in the classpath * * @param xml * @param baseUrl GeoServer base URL */ @Deprecated public List validateSLD(InputStream xml, String baseUrl) { return validateSLD(xml); }
SLDValidator validator = new SLDValidator(); List errors = null; errors = validator.validateSLD(in, request .getHttpServletRequest().getSession() .getServletContext()); throw new WmsException(SLDValidator.getErrorMessage(sldUrl .openStream(), errors));
@Override public Void answer() throws Throwable { Object[] args = getCurrentArguments(); InputStream is = (InputStream) args[1]; byte[] input = IOUtils.toByteArray(is); SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory()); parser.setInput(new ByteArrayInputStream(input)); StyledLayerDescriptor sld = parser.parseSLD(); NamedLayer nl = (NamedLayer) sld.getStyledLayers()[0]; assertEquals("foo", nl.getName()); Style style = nl.getStyles()[0]; assertEquals( "A raster style", style.getDescription().getTitle().toString()); assertEquals(1, style.featureTypeStyles().size()); FeatureTypeStyle fts = style.featureTypeStyles().get(0); assertEquals(1, fts.rules().size()); assertThat( fts.rules().get(0).symbolizers().get(0), instanceOf(RasterSymbolizer.class)); // make sure it's valid SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(new ByteArrayInputStream(input)); assertEquals(0, errors.size()); return null; } });
/** * validate a .sld against the schema * * @param xml input stream representing the .sld file * @param baseURL * @param SchemaUrl location of the schemas. Normally use * ".../schemas/sld/StyleLayerDescriptor.xsd" * @return list of SAXExceptions (0 if the file's okay) */ @Deprecated public List validateSLD(InputSource xml, String baseUrl) { return validateSLD(xml); }
public static String getErrorMessage(InputStream xml, List errors) { return getErrorMessage(new InputStreamReader(xml), errors); }
SLDValidator validator = new SLDValidator(); List errors = null; errors = validator.validateSLD(in, request.getHttpServletRequest() .getSession().getServletContext()); throw new WmsException(SLDValidator.getErrorMessage(reader, errors));
SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(new ByteArrayInputStream(input)); assertEquals(0, errors.size());
throw new WmsException(SLDValidator.getErrorMessage( new ByteArrayInputStream(getMap.getSldBody() .getBytes()), errors)); throw new WmsException(SLDValidator.getErrorMessage( input, errors)); } finally {
SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(fs, context); throw new SldException(SLDValidator.getErrorMessage(xml, errors));
/** * validates an sld document. * */ private List validateSld(InputStream input) { // user requested to validate the schema. SLDValidator validator = new SLDValidator(); return validator.validateSLD(input, httpRequest.getSession() .getServletContext()); }
SLDValidator.getErrorMessage( new StringReader(getMap.getSldBody()), errors)); throw new ServiceException(SLDValidator.getErrorMessage(input, errors)); } finally { input.close();