SoapMessageFormatter implements MessageFormatter { public String removeXsiFromNulls(String xml) { Pattern p = Pattern.compile(REMOVE_NIL_PATTERN); Matcher matcher = p.matcher(xml); if (matcher.find()) { return matcher.replaceAll(REMOVE_NIL_REPLACE_PATTERN); } return xml; }  @Override boolean formattingNeeded(String message); @Override String format(String message); String prettyFormat(String input, int indent, boolean omitXmlDeclaration); String removeXsiFromNulls(String xml); String removeMultiRefs(String message); String prettyFormat(String input); @Override String getName(); @Override String getDescription(); @Override String getPluginableId(); @Override int getApiVersion(); boolean isRemoveMultiRefs(); void setRemoveMultiRefs(boolean removeMultiRefs); boolean isRemoveXsiForNilElements(); void setRemoveXsiForNilElements(boolean removeXsiForNilElements); static final String REMOVE_NIL_PATTERN; static final String REMOVE_NIL_REPLACE_PATTERN; static final String XML_VERSION_1_0_ENCODING_UTF_8; }
@Test public void removeXsiFromNulls() throws Exception { String soap = IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("soap/soapWithNull.xml")); String expected = IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("soap/soapWithNull.formatted.xml")); String removeMultiRefs = formatter.removeXsiFromNulls(soap); System.out.println(removeMultiRefs); AssertJUnit.assertEquals(expected, removeMultiRefs); }
@Test public void removeXsiFromNullsFragment(){ String s = formatter.removeXsiFromNulls("<errorListArray xmlns:ns3=\"http: System.out.println(s); System.out.flush(); AssertJUnit.assertEquals("<errorListArray/>", s); }