use of aQute.libg.sax.filters.ElementSelectionFilter in project bnd by bndtools.
the class TestSAXFilters method testSelectionFilter.
public void testSelectionFilter() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
ElementSelectionFilter filter = new ElementSelectionFilter() {
@Override
protected boolean select(int depth, String uri, String localName, String qName, Attributes attribs) {
return !"e".equals(qName);
}
};
XMLReader reader = SAXUtil.buildPipeline(new StreamResult(output), filter);
reader.parse(new InputSource(new ByteArrayInputStream(SAMPLE4.getBytes())));
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><root c=\"3\"><a><b><c><d/></c></b></a></root>", output.toString());
}
Aggregations