无法评估具有 [@xsi:type=’ED’] 类型的 Xpath 表达式。

huangapple go评论65阅读模式
英文:

Unable to evaluate Xpath xpression having [@xsi:type='ED'] type

问题

无法评估具有 [@xsi:type='ED'] 类型的 XPath 表达式

XPathFactory xpathFactory = XPathFactory.newInstance();

XPath xpath = xpathFactory.newXPath();
String name = xpath.evaluate("/MCCI_IN200100UV01/PORR_IN049016UV[1]/controlActProcess[@classCode='CACT'][@moodCode='EVN']/subject[@typeCode='SUBJ'][1]/investigationEvent[@classCode='INVSTG'][@moodCode='EVN']/component[@typeCode='COMP'][adverseEventAssessment][1]/adverseEventAssessment[@classCode='INVSTG'][@moodCode='EVN']/subject1[@typeCode='SBJ'][1]/primaryRole[@classCode='INVSBJ']/subjectOf2[@typeCode='SBJ'][observation[id][code[@code='29'][@codeSystem='2.16.840.1.113883.3.989.2.1.1.19']]][1]/observation[@classCode='OBS'][@moodCode='EVN']/outboundRelationship2[@typeCode='PERT'][observation/code[@code='30'][@codeSystem='2.16.840.1.113883.3.989.2.1.1.19']][1]/observation[@classCode='OBS'][@moodCode='EVN']/value[@xsi:type='ED'][1]/text()", doc);

// doc 是通过 build.parse() 解析的 XML 文档;

在将 value[@xsi:type='ED'][1]/text() 更改为 value/text() 后,相同的表达式可以正常工作

示例 XML 内容如下

<outboundRelationship2 typeCode="PERT">
<observation moodCode="EVN" classCode="OBS">
<code code="30" codeSystem="2.16.840.1.113883.3.989.2.1.1.19" codeSystemVersion="2.0" /> 
<value xsi:type="ED">肌痛,背部</value> 
</observation>
</outboundRelationship2>
英文:

Unable to evaluate Xpath xpression having [@xsi:type='ED'] type

XPathFactory xpathFactory = XPathFactory.newInstance();

XPath xpath = xpathFactory.newXPath();
String name = xpath.evaluate("/MCCI_IN200100UV01/PORR_IN049016UV[1]/controlActProcess[@classCode='CACT'][@moodCode='EVN']/subject[@typeCode='SUBJ'][1]/investigationEvent[@classCode='INVSTG'][@moodCode='EVN']/component[@typeCode='COMP'][adverseEventAssessment][1]/adverseEventAssessment[@classCode='INVSTG'][@moodCode='EVN']/subject1[@typeCode='SBJ'][1]/primaryRole[@classCode='INVSBJ']/subjectOf2[@typeCode='SBJ'][observation[id][code[@code='29'][@codeSystem='2.16.840.1.113883.3.989.2.1.1.19']]][1]/observation[@classCode='OBS'][@moodCode='EVN']/outboundRelationship2[@typeCode='PERT'][observation/code[@code='30'][@codeSystem='2.16.840.1.113883.3.989.2.1.1.19']][1]/observation[@classCode='OBS'][@moodCode='EVN']/value[@xsi:type='ED'][1]/text()",doc)

// doc is xml document parsed through build.parse();

Same expression is working after changing value[@xsi:type='ED'][1]/text() to value/text()

Sample xml content like this

<outboundRelationship2 typeCode="PERT">
<observation moodCode="EVN" classCode="OBS">
<code code="30" codeSystem="2.16.840.1.113883.3.989.2.1.1.19" codeSystemVersion="2.0" /> 
<value xsi:type="ED">myalgias, back</value> 
</observation>
</outboundRelationship2>

答案1

得分: -1

尝试将

value[@xsi:type='ED']

替换为

value[@*[local-name()='type' and .='ED']]
英文:

Try to replace

value[@xsi:type='ED']

with

value[@*[local-name()='type' and .='ED']]

huangapple
  • 本文由 发表于 2020年10月13日 14:53:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/64330059.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定