省略姓名元素"申请人"

时间:2016-02-22 17:46:46

标签: xml xslt

我有一个结构文件:

<root>
    <stuff>...</stuff>
    <whatever>
        <Applicant Aha="blah" />
        <Applicant />
        <Applicant />
    </whatever>
</root>

长期要求是空(无内容或属性)申请人节点消失。

但是,我当前的挫败感是我的转换没有按照我的预期去做,这完全省略了申请人的节点。

转换1(identity.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"/>
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

转换2(applicant.xsl):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xsl:import href="identity.xsl"/>   
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="Applicant" />
</xsl:stylesheet>

目前,这会输出源文件中的所有内容,包括恶意的申请者节点。为什么?

0 个答案:

没有答案
相关问题