My code was unable to return a value from the input XML. The variable name is mapped in a separate xml based on a string.
我的代码无法从输入XML返回值。变量名在一个基于字符串的单独的xml中映射。
Step 1: I need to extract the XML tag from the another mapping XML. (This I got it)
步骤1:我需要从另一个映射XML中提取XML标记。(这我明白了)
Step 2: XML tag is saved in a variable and using the root tag, I am not able to get the value
步骤2:XML标记被保存在一个变量中,使用根标记,我无法获得该值
This is the XSLT:
这是XSLT:
<xsl:template match="SUBSCRIBER">
<xsl:variable name="expiry_date" select="$docStringAccountMapping/STRING_ACCOUNTS_LIST/STRING_ACCOUNTS_INFO[NSN_STRING='ThirdAccount']/AEXPIRY_DATE"/>
<!-- this returns a string "EXPIRY_DATE_1" -->
<xsl:value-of select="SUBSCRIBER/$expiry_date"/>
</xsl:template>
This is the XML:
这是XML:
<SUBSCRIBER>
<EXPIRY_DATE_1>2014-07-09 23:59:59</EXPIRY_DATE_1>
</SUBSCRIBER>
1 个解决方案
#1
4
First, you probably do not want to select "SUBSCRIBER
...anything" if your template is matching SUBSCRIBER
. The current node will be a SUBSCRIBER
element, so start your XPath from there. Then...
首先,您可能不想选择“订阅者……”任何“如果您的模板匹配订阅者”。当前节点将是一个订阅者元素,因此从这里开始XPath。然后……
If $expiry_date
includes the full element name including the namespace component:
如果$expiry_date包含包括名称空间组件的完整元素名称:
<xsl:value-of select="*[name()= $expiry_date]"/>
If $expiry_date
includes only the element's local name excluding the namespace component:
如果$expiry_date只包含元素的本地名称,但是不包括命名空间组件:
<xsl:value-of select="*[local-name()= $expiry_date]"/>
#1
4
First, you probably do not want to select "SUBSCRIBER
...anything" if your template is matching SUBSCRIBER
. The current node will be a SUBSCRIBER
element, so start your XPath from there. Then...
首先,您可能不想选择“订阅者……”任何“如果您的模板匹配订阅者”。当前节点将是一个订阅者元素,因此从这里开始XPath。然后……
If $expiry_date
includes the full element name including the namespace component:
如果$expiry_date包含包括名称空间组件的完整元素名称:
<xsl:value-of select="*[name()= $expiry_date]"/>
If $expiry_date
includes only the element's local name excluding the namespace component:
如果$expiry_date只包含元素的本地名称,但是不包括命名空间组件:
<xsl:value-of select="*[local-name()= $expiry_date]"/>