我在.xsl文件中声明了一个变量.现在我想用新值更新旧值.例如:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<Document>
<xsl:variable name="topLevelHeadings" select = "//w:body/w:p[w:pPr[w:pStyle[@w:val='Heading1']]]"/>
<xsl:variable name="beforeHeading" select="false()"/>
<xsl:choose>
<xsl:when test="$beforeHeading">
<xsl:apply-templates select="//w:body/w:p">
<xsl:with-param name="scope" select="count(//w:body/child::*)-1"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$topLevelHeadings">
<xsl:variable name="beforeHeading" select="true()"/>
<xsl:apply-templates select="$topLevelHeadings">
<xsl:with-param name="scope" select="count(//w:body/child::*)-1"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="//w:body/w:p[w:r[w:t]]">
<xsl:with-param name="scope" select="count(//w:body/child::*)-1"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</Document>
</xsl:template>
<xsl:template match="w:body/w:p">
<xsl:param name = "scope"/>
<xsl:variable name ="index" select="count(preceding-sibling::*)"/>
<xsl:if test = "$index <= $scope">
<Paragraph>
<xsl:attribute name="index">
<xsl:value-of select="$index" />
</xsl:attribute>
<xsl:apply-templates select=".//w:r/w:t"/> …Run Code Online (Sandbox Code Playgroud)