根据条件提取特定元素

时间:2019-03-02 11:15:17

标签: xml xslt-2.0

我有一个xml文件,它包含该xml文件中的多个名称空间,当我在其中添加条件时,我必须复制一个包含text = Cash的元素。然后输出什么也不会产生,请帮帮我。 1.我必须提取只有文本= Cash的元素。

<link:linkbase xmlns:link="http://www.xbrl.org/2003/linkbase"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd">
    <link:roleRef xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        roleURI="http://fasb.org/us-gaap/role/label/axisDefault"
        xlink:href="us-roles-2018-01-31.xsd#axisDefault" xlink:type="simple"/>
    <link:labelLink xmlns:xlink="http://www.w3.org/1999/xlink"
        xlink:role="http://www.xbrl.org/2003/role/link" xlink:type="extended">
        <link:label id="lab_Cash_label1_en-US" xlink:label="lab_Cash"
            xlink:role="http://www.xbrl.org/2003/role/label" xlink:type="resource" xml:lang="en-US"
            >Cash</link:label>
        <link:loc xlink:href="us-gaap-2018-01-31.xsd#us-gaap_AOCIAttributableToParentAbstract"
            xlink:label="loc_AOCIAttributableToParentAbstract" xlink:type="locator"/>
        <link:label id="lab_Cash_label2_en-US" xlink:label="lab_Cash"
            xlink:role="http://www.xbrl.org/2003/role/label" xlink:type="resource" xml:lang="en-US"
            >Cash</link:label>

        <link:label id="lab_AOCIAttributableToParentAbstract_label_en-US"
            xlink:label="lab_AOCIAttributableToParentAbstract"
            xlink:role="http://www.xbrl.org/2003/role/label" xlink:type="resource" xml:lang="en-US"
            >AOCI Attributable to Parent [Abstract]</link:label>
        <link:labelArc order="1.0" xlink:arcrole="http://www.xbrl.org/2003/arcrole/concept-label"
            xlink:from="loc_AOCIAttributableToParentAbstract"
            xlink:to="lab_AOCIAttributableToParentAbstract" xlink:type="arc"/>
        <link:label id="lab_Cash_label_en-US" xlink:label="lab_Cash"
            xlink:role="http://www.xbrl.org/2003/role/label" xlink:type="resource" xml:lang="en-US"
            >Cash</link:label>
    </link:labelLink>
</link:linkbase>

XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:link="http://www.xbrl.org/2003/linkbase"
    xmlns:xlink="http://www.w3.org/1999/xlink" 
    xlink:href="us-roles-2018-01-31.xsd#axisDefault"
    xlink:role="http://www.xbrl.org/2003/role/link"
    xml:lang="en-US"
    xlink:type="resource"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:template match="link:*[text()='_Cash']">
        <xsl:copy-of select="."/>
    </xsl:template>
</xsl:stylesheet>

0 个答案:

没有答案
相关问题