我正在尝试对XML文档进行转换。我的XML变换可导致两种不同类型的底座元件的取决于特定元素的值:空白xmlns =“”来自导入的属性
<StructureA xmlns="http://...">
StructureA &:
<xsl:template match="/">
<xsl:choose>
<xsl:when test="/databean/data[@id='pkhfeed']/value/text()='200'">
<xsl:call-template name="StructureA">
<xsl:with-param name="structure" select="//databean" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="StructureB">
<xsl:with-param name="structure" select="//databean" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
StructureA或StructureB然后用自己的命名空间和schemaLocations创建B共享一些共同的元素,因此这些元素被定义在一个名为“xmlcommon.xslt”的单独文件中,这两个结构都包含来自这些模板的文件。这个xmlcommon文件没有定义默认名称空间,因为我希望它可以从StructureA或StructureB中定义的名称空间使用。但是,当我跑我的改造,任何模板空白的xmlns从普通文件结果拉到属性:
<StructureA xmlns="http://...">
<SharedElement xmlns="">Something</SharedElement>
</StructureA>
验证时,空白的命名空间则用来代替正确的父之一。 有谁知道我可以通过添加这些空白xmlns属性来阻止我的公共文件中的模板吗?
下面是从普通文件的片段:
<xsl:stylesheet version="1.0" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="ControlledListStructure">
<xsl:param name="xmlElem" />
<xsl:param name="structure" />
<xsl:element name="{$xmlElem}">
<!-- Blah blah blah -->
</xsl:element>
</xsl:template>
</xsl:stylesheet>
很好的解释,埃文。没有更多要补充的。从我+1。欢迎来到SO。 – 2009-04-30 13:29:42