OpenImmo_1_2_3 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void downgradeBadElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:bad[@BIDET or @PISSOIR]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; node.removeAttribute("BIDET"); node.removeAttribute("PISSOIR"); } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testDowngradeBadElements() { try { Document doc = buildTransferDocumentForDowngrade(); int count; count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:bad[@BIDET or @PISSOIR]", doc); Assert.assertEquals( "3 convertable <bad> elements available before conversion.", 3, count); new OpenImmo_1_2_3().downgradeBadElements(doc); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:bad[@BIDET or @PISSOIR]", doc); Assert.assertEquals( "0 convertable <bad> elements available after conversion.", 0, count); } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_3.downgradeBadElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_3.downgradeBadElements failed!"); } }