我们最近将数据库从Oracle 11gR1
升级到11gR2
。之后,javax.xml.xpath.XPath.evaluate()
未提供预期的输出 -
// SAVING YOU FROM ALL UNWANTED CODE - I've queried for data and returned to ResultSet object
java.sql.Blob blobObj = rs.getBlob("DOCBODY");
InputStream inpStr = new java.io.ByteArrayInputStream(blobObj.getBytes(1L,
(int) blobObj.length()));
javax.xml.parsers.DocumentBuilderFactory domFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true);
javax.xml.parsers.DocumentBuilder builder = domFactory.newDocumentBuilder();
org.w3c.dom.Document doc = builder.parse(new org.xml.sax.InputSource(inpStr));
doc.getDocumentElement().normalize();
org.w3c.dom.Node infoTag = (org.w3c.dom.Node) xPath.evaluate("sc:configuration/sc:info", doc,
javax.xml.xpath.XPathConstants.NODE); // configuration is one of the <parent_tags> and
info is <configuration> tag's <child_tag>
我肯定知道这几件事 -
doc.getElementsByTagName()
(返回org.w3c.dom.NodeList
)代替xpath.evaluate()
,我得到了。xpath.evaluate()
预期产出。这让我只想到一个事实 - 升级后的数据库中javax.xml.xpath.XPath xPath = javax.xml.xpath.XPathFactory.newInstance().newXPath();
xPath.setNamespaceContext(new MyNamespaceContext()); //MyNamespaceContext is just an inner class that extends javax.xml.namespace.NamespaceContext
// Retrieving information available in the XML file
org.w3c.dom.Node infoTag = (org.w3c.dom.Node) xPath.evaluate("sc:configuration/sc:info", doc, javax.xml.xpath.XPathConstants.NODE);
if (null != infoTag) {
org.w3c.dom.NodeList docNodeList = (org.w3c.dom.NodeList) xPath.evaluate("sc:documents/sc:document", infoTag, javax.xml.xpath.XPathConstants.NODESET); //documents is a child tag of info tag and document is a child tag of documents tag
if (null != docNodeList) {
...
...
for (int i = 0; i < docNodeList.getLength(); i++) {
/* We are supposed to enter this condition, but since something is wrong with "doc" object
because docNodeList.getLength() is returning 0, we are not able to do so after the Oracle
DB upgrade. Before we upgraded to 11.2.0.4, this part of code was working as expected.
However, it still works as expected when I go with doc.getElementsByTagName().*/
}
...
...
}
...
...
}
private static class MyNamespaceContext implements NamespaceContext {
public String getNamespaceURI(final String prefix) {
if ("sc".equals(prefix)) {
return "http://www.dummyurl.com/configuration";
}
return null;
}
public String getPrefix(final String namespaceURI) {
return null;
}
public Iterator getPrefixes(final String namespaceURI) {
return null;
}
}
API与BLOB对象的行为。
我在数据库升级后尝试查找此API的兼容性问题。有关这方面的更多信息将会有很大帮助。
更新
position: fixed;
z-index: 1000;
我非常想知道可能导致这种行为的原因。