我有一个输入xml,在我的xsl中我调用了一个模板.模板内的第一个标签显示为空的xmlns属性,如下所示
<Section xmlns="">
可以在xslt中消除此属性吗?
请在这件事上给予我帮助..
Input.xml文件:
<?xml version="1.0" encoding="utf-8"?> <List> <Sections> <Section> <Column>a</Column> <Column>b</Column> <Column>c</Column> <Column>d</Column> <Column>e</Column> </Section> </Sections> </List>
Stylesheet.xsl
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="List"> <report xmlns="http://developer.com/"> <Views> <xsl:call-template name="Page"/> </Views> </report> </xsl:template> <xsl:template name="Page"> <Content> <xsl:for-each select="./Sections/Section"> <Columns> <xsl:for-each select="./Column"> <Column> <xsl:attribute name="value"> <xsl:value-of select="."/> </xsl:attribute> </Column> </xsl:for-each> </Columns> </xsl:for-each> </Content> </xsl:template>
output.xml看起来像
<?xml version="1.0" encoding="UTF-8"?> <report xmlns="http://developer.com/"> <Views> <Content xmlns=""> <Columns> <Column value="a"/> <Column value="b"/> <Column value="c"/> <Column value="d"/> <Column value="e"/> </Columns> </Content> </Views>
我需要< report>中的xmlns属性标签但不在< Content>中标签.这个xmlns属性的出现是因为我调用了一个模板,并且该模板的第一个标记添加了该属性.