RSS要素のこのバグを検出/回避しようとしています。つまり、間違った名前空間宣言を見つけて、その値を正しい名前空間に変更する必要があります。例えば:
xmlns:media="http://search.yahoo.com/mrss"
でなければなりません:
xmlns:media="http://search.yahoo.com/mrss/"
org.w3c.Documentを指定して、どうすればそれを達成できますか?
つまり、特定の名前空間のすべての要素を取得する方法を見つけました。
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
XPathExpression expr = xpath.compile("//*[namespace-uri()='http://search.yahoo.com/mrss']");
Object result = expr.evaluate(d, XPathConstants.NODESET);
if (result != null) {
NodeList nodes = (NodeList) result;
for(int node=0;node<nodes.getLength();node++)
{
Node n = nodes.item(node);
this.log.warn("Found old mediaRSS namespace declaration: "+n.getTextContent());
}
}
そこで、JAXPを介してノードの名前空間を変更する方法を理解する必要があります。