12

我有一个这样的 xml 文件。

<RootTag>
    <Form>
        <Section>
             <Annex>
                <Group>
                        <Label value = "Name"></Label>
                        <Text Value = "Enter Name"></Text>
                </Group>
                <Group>
                        <Label value = "Gender"></Label>
                       <Radio Value = "Male||Female"></Text>
                </Group>
            </Annex>
        </Section>
    </Form>
</RootTag>

现在在我的 xsl 中,我必须检查标签是否为<Text>or并根据该结果<Radio>生成标签。<input>

有什么我可以使用的<xsl:if>吗?像<xsl:if test = 'node = <Text>'>

4

1 回答 1

24
<xsl:if test="name() = 'Form'">

但是,还有其他可能更好的方法:

一种是对这个项目使用模板;XSLT 引擎将自动执行测试,如果您想这样看的话。

<xsl:template match="Form">

另一种是使用self::

<xsl:for-each select="self::Form">
于 2013-02-21T06:17:50.043 回答