http://www.ibm.com/developerworks/xml/library/x-nmspccontext/index.htmlをフォローしようとしています
UniversalNamespaceResolver
XML に対する XPath 評価の名前空間を解決する例。私が遭遇した問題は、以下の lookupNamespaceURI 呼び出しが XML で null を返すことです。
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document dDoc = builder.parse(new InputSource(new StringReader(xml)));
String nsURI = dDoc.lookupNamespaceURI("h");
XML:
<?xml version="1.0"?>
<h:root xmlns:h="http://www.w3.org/TR/html4/">
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>`
</h:root>
「 http://www.w3.org/TR/html4/ 」が返されることを期待していますが。