Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 为什么这个xpath返回一个空节点集?_Xml_Xslt_Xpath - Fatal编程技术网

Xml 为什么这个xpath返回一个空节点集?

Xml 为什么这个xpath返回一个空节点集?,xml,xslt,xpath,Xml,Xslt,Xpath,以下是XML: <recordTarget> <patientRole> <patient> <religiousAffiliationCode code="1013" displayName="Christian (non-Catholic, non-specific)" codeSystem="2.16.840.1.113883.5.1076" codeSystemName="HL7

以下是XML:

    <recordTarget>
        <patientRole>
          <patient>
           <religiousAffiliationCode code="1013" displayName="Christian (non-Catholic, non-specific)" codeSystem="2.16.840.1.113883.5.1076" codeSystemName="HL7 Religious Affiliation"/>
   </patient>
</patientRole>
</recordTarget>

这是我的xpath语句(n1是名称空间)


根据XML评估XPath的结果取决于您没有告诉我们的因素

这取决于

  • 当前上下文,因为它是相对的 XPath
  • n1
    名称空间前缀的定义 在XML和承载 XPath。看
  • recordTarget
    patientRole
    的命名空间, 等等,如果没有看到它们的全部遗产就无法确定

检查
宗教事务代码的拼写


(顺便说一句,防止路径表达式中拼写错误的唯一真正防御措施是使用XSLT 2.0中的模式感知功能,如果您正确利用这些功能,就可以在编译时检查路径对模式是否有意义。这在使用诸如HL7之类的词汇表时尤其重要,其中名称为10我只包含了少量的XML,但当前的上下文是正确的,名称空间n1已经定义。Michael Kay有敏锐的眼睛。这是一个拼写错误。我的朋友,你们有敏锐的眼睛。谢谢!
<xsl:variable name="religion" select="n1:recordTarget/n1:patientRole/n1:patient/n1:religiousAffilliationCode/@displayName"/>