希望用xsl 1.0将div插入到html体中

时间:2014-04-19 18:40:55

标签: xslt-1.0

非常简单:我正在寻找一个简单的XSL来改变

    <body>
      ...
    </body>

    <body>
      ...
      <div>...</div>
    </body>

1 个答案:

答案 0 :(得分:0)

      <xsl:template match="body">
           <xsl:apply-templates />
           <div>...</div>
      </xsl:template>   
      <xsl:template match="*">
            <xsl:variable name="curTagName" select="name()"/>
            <xsl:element name="{$curTagName}">
                <!-- Walk through the attributes -->
                <xsl:apply-templates select="@*">
                    <xsl:sort select="name()"/>
                </xsl:apply-templates>
                <xsl:apply-templates/>
            </xsl:element>
        </xsl:template>

        <xsl:template match="@*">
            <xsl:variable name="curAttName" select="name()"/>
            <xsl:attribute name="{$curAttName}">
                <xsl:value-of select="."/>
            </xsl:attribute>
        </xsl:template>