我试图理解xpath在我的案例中是如何工作的。我的问题很简单。我想输出
VATIdentificationNumber
申请人的
梵蒂冈识别号
元素。
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0" version="1.0" xmlns:ns0="http://customerNamespace" xmlns:s0="http://inputNamespace">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<xsl:apply-templates select="/s0:CDM_VATRefundApplication" />
</xsl:template>
<xsl:template match="/s0:CDM_VATRefundApplication">
<ns0:VatRefund>
<GeneralData>
<LineCode>01</LineCode>
<VATIdentificationNumber>
<xsl:value-of select="Applicant/VATIdentificationNumber"></xsl:value-of>
</VATIdentificationNumber>
</GeneralData>
</ns0:VatRefund>
</xsl:template>
</xsl:stylesheet>
我的输入模式结构如下:
根据我对xslt中scope如何工作的理解,我目前在根节点上,因为模板匹配
/
. 因此,我应该能够选择
Applicant
元素,它是根节点的子节点。当我测试代码时
梵蒂冈识别号
元素输出,但没有值。
在这种情况下,正确的xpath是什么?我试过添加名称空间,使用完整路径,但也没用。