我有这个xml文件

<?xml version="1.0" encoding="UTF-8"?>
<bo:C837ClaimParent xsi:type="bo:C837ClaimParent"     
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
xmlns:bo="http://somelongpathHere/process/bo">
<claimAux>
...
</claimAux>
<enterpriseClaim>
...
    <patientAccountNumber>data to capture here</patientAccountNumber>
</enterpriseClaim>

我需要匹配<!> lt; patientAccountNumber <!> gt;里面的数据,它位于<!> lt; enterpriseClaim <!> gt;里面,里面是<!> lt; bo:C837ClaimParent <! > GT;     我已经尝试了所有我能想到的xsl:template匹配的值,我无法匹配该节点,它找不到它,或者匹配整个xml文件,我的xsl文件如下所示:

    <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="2.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <html>
....
<div>
  <xsl:value-of select="C837ClaimParent/enterpriseClaim/patientAccountNumber" /></div>

我需要在xsl:template和my xsl:value-of上指定什么?

另外,对于同一个文件,我将匹配其他值,一切都在主节点<!> lt; bo:C837ClaimParent中,所以我需要使用什么才能有效地匹配整个文件中的节点? / p>

有帮助吗?

解决方案

您似乎缺少bo前缀的命名空间声明。除非使用local-name()

,否则此命名空间可能必须出现在您的解决方案中

编辑(在命名空间出现后!

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:bo="http://somelongpathHere/process/bo">
    <xsl:output method="xml" version="2.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <html>
....
<div>
  <xsl:value-of select="bo:C837ClaimParent/enterpriseClaim/patientAccountNumber" /></div>

您确定enterpriseClaimC837ClaimParent

位于不同的命名空间中吗?

其他提示

<xsl:stylesheet ... xmlns:bo="http://www.bo.org">
   ...
   <xsl:value-of select="/bo:C837ClaimParent/enterpriseClaim/patientAccountNumber" />
   ...
</xsl:stylesheet>

一般来说,我的建议是阅读XML和XPath中的命名空间。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top