Returns all namespaces defined in the root element of this page. The default namespace has a key of an empty string. @return all namespaces defined in the root element of this page
()
| 2332 | * @return all namespaces defined in the root element of this page |
| 2333 | */ |
| 2334 | public Map<String, String> getNamespaces() { |
| 2335 | final org.w3c.dom.NamedNodeMap attributes = getDocumentElement().getAttributes(); |
| 2336 | final Map<String, String> namespaces = new HashMap<>(); |
| 2337 | for (int i = 0; i < attributes.getLength(); i++) { |
| 2338 | final Attr attr = (Attr) attributes.item(i); |
| 2339 | String name = attr.getName(); |
| 2340 | if (name.startsWith("xmlns")) { |
| 2341 | int startPos = 5; |
| 2342 | if (name.length() > 5 && name.charAt(5) == ':') { |
| 2343 | startPos = 6; |
| 2344 | } |
| 2345 | name = name.substring(startPos); |
| 2346 | namespaces.put(name, attr.getValue()); |
| 2347 | } |
| 2348 | } |
| 2349 | return namespaces; |
| 2350 | } |
| 2351 | |
| 2352 | /** |
| 2353 | * {@inheritDoc} |
no test coverage detected