@Override
	public List<Namespace> getNamespacesInherited() {
		if (getParentElement() == null) {
			ArrayList<Namespace> ret = new ArrayList<Namespace>(getNamespacesInScope());
			for (Iterator<Namespace> it = ret.iterator(); it.hasNext();) {
				Namespace ns = it.next();
				if (ns == Namespace.NO_NAMESPACE || ns == Namespace.XML_NAMESPACE) {
					continue;
				}
				it.remove();
			}
			return Collections.unmodifiableList(ret);
		}

		// OK, the things we inherit are the prefixes we have in scope that
		// are also in our parent's scope.
		HashMap<String,Namespace> parents = new HashMap<String, Namespace>();
		for (Namespace ns : getParentElement().getNamespacesInScope()) {
			parents.put(ns.getPrefix(), ns);
		}

		ArrayList<Namespace> al = new ArrayList<Namespace>();
		for (Namespace ns : getNamespacesInScope()) {
			if (ns == parents.get(ns.getPrefix())) {
				// inherited
				al.add(ns);
			}
		}

		return Collections.unmodifiableList(al);
	}