XmlUtils { public static String stripNameSpacePrefixes(String path) { if (path.indexOf(':') == -1) { return path; } StringBuilder sb = new StringBuilder(); for (String s : StringUtils.split(path, '/', false)) { sb.append('/'); int pos = s.lastIndexOf(':'); if (pos == -1) { sb.append(s); } else { sb.append(s.substring(pos + 1)); } } return sb.toString(); } private  XmlUtils(); static String toString(Node node); static String toString(Node node, boolean pretty); static void trimWhiteSpace(Node node); static Document toXmlDoc(String xml); static NodeList getNodeListByPath(Node node, String path); static String stripNameSpacePrefixes(String path); static Node getNodeByPath(Node node, String path, boolean create); static Node createNodeByPath(Document doc, String path); static String getTextValueByPath(Node node, String path); static void setByPath(Node doc, String path, String value); static void removeByPath(Document doc, String path); static void setByPath(Document doc, String path, Node in); static DocumentContext toJsonDoc(Node node); static int getChildElementCount(Node node); static Object toObject(Node node); static Object toObject(Node node, boolean removeNamespace); static Document fromMap(Map<String, Object> map); static Document fromObject(String name, Object o); static List<Element> fromObject(Document doc, String name, Object o); static Document newDocument(); static void addAttributes(Element element, Map<String, Object> map); static Element createElement(Node node, String name, String value, Map<String, Object> attributes); static Document toNewDocument(Node in); static Document toXmlDoc(Object o); static String toXml(Object o);  }
@Test public void testStripNameSpacePrefixes() { assertEquals("/", XmlUtils.stripNameSpacePrefixes("/")); assertEquals("/foo", XmlUtils.stripNameSpacePrefixes("/foo")); assertEquals("/bar", XmlUtils.stripNameSpacePrefixes("/foo:bar")); assertEquals("/bar/baz", XmlUtils.stripNameSpacePrefixes("/foo:bar/foo:baz")); assertEquals("/bar/baz/@ban", XmlUtils.stripNameSpacePrefixes("/foo:bar/foo:baz/@ban")); }