Code example for Document

Methods: getElementsByTagName

0
        SLDClassifier classifier = new SLDClassifier(EMPTY_MAP, command);
         
        Document doc = createDomDocument(classifier.getSLD());
 
        // should retrieve expected tags 
        assertEquals(true, doc.getElementsByTagName("sld:UserLayer").getLength() == 0);
        assertEquals(true, doc.getElementsByTagName("sld:NamedLayer").getLength() != 0);
        assertEquals(true, doc.getElementsByTagName("sld:Rule").getLength() != 0);
        assertEquals(true, doc.getElementsByTagName("ogc:Filter").getLength() != 0);
        assertEquals(true, doc.getElementsByTagName("sld:PolygonSymbolizer").getLength() != 0);  
    } 
     
    private Document createDomDocument(final String content) throws Exception {
        // create xml doc 
        final DocumentBuilderFactory lDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
        final DocumentBuilder lDocumentBuilder = lDocumentBuilderFactory.newDocumentBuilder();
        InputStream stream = new ByteArrayInputStream(content.getBytes());
        Document document = lDocumentBuilder.parse(stream);
        return document;
    } 
Contextual code suggestions in your IDE  Get Codota for Java