XformResource extends BaseResource<Form> { static String removeRelationshipNodes(String xml) throws IOException, SAXException { Document doc = XmlUtils.parse(xml); removeBinding(doc, "patient_relative"); removeBinding(doc, "patient_relative.person"); removeBinding(doc, "patient_relative.relationship"); for (Element relative : elementsIn(doc .getElementsByTagNameNS("", "patient_relative"))) { removeNode(relative); } for (Element label : elementsIn(doc .getElementsByTagNameNS(XFORMS_NAMESPACE, "label"))) { Element parent = (Element) label.getParentNode(); if (eq(XFORMS_NAMESPACE, parent.getNamespaceURI()) && eq(parent.getLocalName(), "group") && eq(label.getTextContent(), "RELATIONSHIPS")) { removeNode(parent); break; } } return XformsUtil.doc2String(doc); } XformResource(); static Collection<Form> getXformForms(FormService formService);  }
@Test public void removeRelationshipNodes() throws Exception { String input = getStringResource(getClass(), "relationships-original-form1.xml"); String expected = getStringResource(getClass(), "relationships-result-form1.xml"); String actual = XformResource.removeRelationshipNodes(input); assertXmlEqual(expected, actual); }