是否有一种方法可以使用XSLT仅替换节点中的部分值
我试图仅替换节点中的一部分值。我在这里读了一些文章,它们似乎取代了整个字符串 这是我所拥有的是否有一种方法可以使用XSLT仅替换节点中的部分值,xslt,Xslt,我试图仅替换节点中的一部分值。我在这里读了一些文章,它们似乎取代了整个字符串 这是我所拥有的 <commands> <command>chmod 550 OLDPATH/system</command> <command>chmod 750 OLDPATH/system/config/home</command> </commands> chmod 550旧路径/系统 chmod 750 OLDPATH/sy
<commands>
<command>chmod 550 OLDPATH/system</command>
<command>chmod 750 OLDPATH/system/config/home</command>
</commands>
chmod 550旧路径/系统
chmod 750 OLDPATH/system/config/home
这就是我想要的
<commands>
<command>chmod 550 NEWPATH/system</command>
<command>chmod 750 NEWPATH/system/config/home</command>
</commands>
chmod 550新路径/系统
chmod 750 NEWPATH/system/config/home
从技术上讲,您不能替换XSLT中任何内容的一部分。但是,当替换节点的整个值时,可以使用字符串函数在构建新值时利用被替换的部分值
例如,将以下模板应用于示例:
<xsl:template match="command">
<xsl:copy>
<xsl:value-of select="substring-before(., 'OLDPATH')" />
<xsl:text>NEWPATH</xsl:text>
<xsl:value-of select="substring-after(., 'OLDPATH')" />
</xsl:copy>
</xsl:template>
新路径
将导致:
<command>chmod 550 NEWPATH/system</command>
<command>chmod 750 NEWPATH/system/config/home</command>
chmod 550新路径/系统
chmod 750 NEWPATH/system/config/home
从技术上讲,您不能替换XSLT中任何内容的一部分。但是,当替换节点的整个值时,可以使用字符串函数在构建新值时利用被替换的部分值
例如,将以下模板应用于示例:
<xsl:template match="command">
<xsl:copy>
<xsl:value-of select="substring-before(., 'OLDPATH')" />
<xsl:text>NEWPATH</xsl:text>
<xsl:value-of select="substring-after(., 'OLDPATH')" />
</xsl:copy>
</xsl:template>
新路径
将导致:
<command>chmod 550 NEWPATH/system</command>
<command>chmod 750 NEWPATH/system/config/home</command>
chmod 550新路径/系统
chmod 750 NEWPATH/system/config/home
从技术上讲,您不能替换XSLT中任何内容的一部分。但是,当替换节点的整个值时,可以使用字符串函数在构建新值时利用被替换的部分值
例如,将以下模板应用于示例:
<xsl:template match="command">
<xsl:copy>
<xsl:value-of select="substring-before(., 'OLDPATH')" />
<xsl:text>NEWPATH</xsl:text>
<xsl:value-of select="substring-after(., 'OLDPATH')" />
</xsl:copy>
</xsl:template>
新路径
将导致:
<command>chmod 550 NEWPATH/system</command>
<command>chmod 750 NEWPATH/system/config/home</command>
chmod 550新路径/系统
chmod 750 NEWPATH/system/config/home
从技术上讲,您不能替换XSLT中任何内容的一部分。但是,当替换节点的整个值时,可以使用字符串函数在构建新值时利用被替换的部分值
例如,将以下模板应用于示例:
<xsl:template match="command">
<xsl:copy>
<xsl:value-of select="substring-before(., 'OLDPATH')" />
<xsl:text>NEWPATH</xsl:text>
<xsl:value-of select="substring-after(., 'OLDPATH')" />
</xsl:copy>
</xsl:template>
新路径
将导致:
<command>chmod 550 NEWPATH/system</command>
<command>chmod 750 NEWPATH/system/config/home</command>
chmod 550新路径/系统
chmod 750 NEWPATH/system/config/home
在您的示例中应用的确切规则是什么?--请同时指出您的XSLT版本。在您的示例中应用的确切规则是什么?--请同时指出您的XSLT版本。在您的示例中应用的确切规则是什么?--请同时指出您的XSLT版本。在您的示例中应用的确切规则是什么?--请指出您的XSLT版本。