- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试从标签获取值属性:
<pip:property name="release-name" value="2018 November Release"/>
我的 xml 是:
<pip:object-group id="id-6b940c81-ed37-45ec-ac85-68ae13a6c6a0" target-object-uri="http://doc.test.com/us/hlrp/topic/c64a80ee742330778d018b0505cda195">
<pip:properties>
<pip:property name="release-name" value="2018 November Release"/>
</pip:properties>
<pip:store id="id-93379bb2-e837-42b9-8316-aef393f1e034" object-uri="http://doc.test.com/us/hlrp/topic/c64a80ee742330778d018b0505cda195.htm" aspect="content" path="documents/c64a80ee742330778d018b0505cda195/c64a80ee742330778d018b0505cda195.htm"/>
<pip:store id="id-99a5d375-2084-4f82-b30c-c932bb4bbb31" object-uri="http://doc.test.com/us/hlrp/topic/c64a80ee742330778d018b0505cda195.rdf" aspect="metadata" path="documents/c64a80ee742330778d018b0505cda195/meta.rdf"/>
</pip:object-group>
我在Java中获取值(value)的方法是:
private String getReleaseFolder(String manifestFolder, String procedureId) throws Exception {
String releaseFolder = new String();
XPathExpression expr;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = (Document) builder.parse(manifestFolder);
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
xpath.setNamespaceContext(new NamespaceContext() { //minimalist
public String getNamespaceURI(String prefix) {
if (prefix.equals("pip")) {
getLogger().info("I am in the first branch");
return "http://schema.wolterskluwer.com/pci/interface-protocol-v4.0/";
}
if (prefix.equals("xsi")){
getLogger().info("I am in the second branch");
return "http://www.w3.org/2001/XMLSchema-instance";
} else {
getLogger().info("I am in the third branch");
return null;
}
}
public String getPrefix(String namespaceURI) {
return null;
}
public Iterator<String> getPrefixes(String namespaceURI) {
return null;
}
});
expr = xpath.compile("//pip:properties[following-sibling::pip:store[contains(@path,\"" + procedureId +"\")]]/pip:property[@name=\"release-name\"]/@value");
NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
if (nl.getLength() == 0) {
String emailBody = CsbConstants.EMAILBODY_MANIFEST + procedureId + CsbConstants.EMAILBODY_MANIFEST_PART;
getLogger().info(emailBody);
// here we send an email
// here we throw a new Exception
Exception e = new Exception(emailBody);
throw e;
}
releaseFolder = nl.item(0).getNodeValue();
return releaseFolder;
}
但是,我的 NodeList:nl.getLength() 是 0。您能帮忙吗?预先感谢您。
最佳答案
您需要告诉 DocumentBuilderFactory 解析 namespace :
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
关于java - XPathExpression Evaluate 在 java 中返回一个空 NodeList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52747098/
我被卡住了,请重新审视这个问题。 我正在与其他人的意大利面条式代码一起工作,这些代码不再存在,并且有很多时间弄清楚他们正在评估什么。 在查询转储中,我看到
真实世界Haskell的第8章 globToRegex' (c:cs) = escape c ++ globToRegex' cs 这个函数不是尾递归的,它说答案依赖于 Haskell 非严格(惰性)
来自 Haskell,我正在阅读 Idris 关于懒惰(非严格)的故事。我翻了翻最近的发行说明,还有 found code类似于以下 myIf : (b : Bool) -> (t : Lazy a)
我正在读这个帖子 A custom find function并指出了这一点 有趣的结果。请注意,Evaluate 与 Application.Evaluate 相同,并且所需时间大约是 Active
R包裹mice带有以下示例: library("mice") imp <- mice(nhanes) fit <- with(data=imp,exp=lm(bmi~hyp+chl)) 我想要一个灵活
我正在尝试使用 PHPUnit 3.6.4 对我的 Zend Framework 应用程序进行单元测试。当我在命令提示符中尝试此命令时,出现以下错误。 C:\xampp\htdocs\testsamp
我希望函数的结果是: 所有值的计算结果均为 False(无、0、空字符串)-> True 所有值的计算结果为 True -> True 所有其他情况 -> 错误 这是我的尝试: >>> def con
我可以使用 puppeteer 导航到一个页面但后来page.evaluate没有返回任何响应。此外,我无法在 page.evaluate 内部进行调试。任何一个。我在 Debug模式下运行脚本( n
from surprise import Reader, Dataset, SVD from surprise import evaluate ----------------------------
使用 PhantomJS 考虑以下代码片段: var reloadAfterLogin = false; function(user, pass, debug){ // step 3 submit L
我知道流是惰性的,直到在流上调用终端方法。我所知道的是,在调用终端方法之后,所有中间方法都按调用顺序执行。 但是对于下面的程序,我无法理解流是如何工作的。这是代码,我试过了。 import java.
最近我开始研究 VS2012。 当我调试代码(这是 SharePoint 2013 应用程序)并尝试获取变量的值时 - 我一次又一次收到消息: Function evaluation disabled
我正在阅读 David Flanagan 的《JavaScript:权威指南》,这可能是世界上最厚的 JavaScript 书。在简要描述数组初始值设定项时,弗拉纳根说“每次数组初始值设定项时都会评估
在 puppeteer 截取屏幕截图之前,我试图让代码执行等待所有图像加载完毕。当调用 initData() 函数时,我的 DOM 被填充,该函数在客户端 js 文件中定义。延迟或超时是一种选择,但我
对国际通用标准有一些批评,如 [Under-attack]。 1 您认为使用 CC 开发 IT 产品的利弊是什么? 最佳答案 我是 BSI(德国)和 NIAPP(美国)计划的通用标准评估员。我有一些经
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 11 年前关闭。 Improve this
在非严格求值语言中,使用按名称调用与通过宏扩展调用有何区别和优点/缺点? 您能否提供一个示例来解释这两种评估策略? 谢谢! 最佳答案 按姓名调用: 按名称调用是一种求值策略,其中函数的参数在调用函数之
我真的无法在 Modelica 规范中找到任何答案,所以我想问问你们。规范指出如果表达式的值不影响结果(例如, bool 表达式的短路评估),工具可以自由地求解方程、重新排序表达式和不计算表达式。 I
我想尝试惰性表达式评估,但我现在不想深入研究 Haskel。拜托,你能帮忙找出其他语言有这个功能吗? 最佳答案 你可以用多种语言模拟它。 this例如,是 C++ 的通用惰性求值器。正如文章所说,它也
关注,据说foldl'是 foldl 的严格版本. 但是我很难理解,strict 是什么意思?意思是?? foldl f z0 xs0 = lgo z0 xs0 where
我是一名优秀的程序员,十分优秀!