1

我对这个 XSLT 脚本有疑问。我想重命名我的标签,并且我有一个包含新名称标签元素的表。我正在使用 Talend 获取每一行并将名称存储在两个变量“generic”中,其中包含新名称和另一个包含完整路径 (arbre) 的变量。

   <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8" 
         doctype-public="-//W3C//DTD HTML 4.01//EN" 
         doctype-system="" indent="yes" />
    
    <xsl:param name = "generique" />
    <xsl:param name = "arbre" />
    
    <xsl:variable name="vXpath"  select= "$arbre" />
    
    <xsl:template match= "/">
       <xsl:value-of select="$vXpath"/>
       <xsl:element name ="{$generique}">
         <xsl:apply-templates select="child"/>
       </xsl:element>
    </xsl:template>
    
    <xsl:template match="@*|node()" priority="0">
    <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    </xsl:template>
    
    </xsl:stylesheet>

该脚本无法按我的意愿工作。

4

1 回答 1

1

你说的哪里<xsl:apply-templates select="child"/>,我怀疑你想要<xsl:apply-templates/>的。

您编写它的方式仅适用于以 . 开头的文档<child>...</child>

请注意,缺席select=暗示select="child::node()"这很可能是您认为自己在说的话。

于 2013-08-22T15:39:26.370 回答