Html xsl替换字符串中的特定字符
我正在学习XSL,我对替换字符串中的特定字符有疑问 我们有xml文件Html xsl替换字符串中的特定字符,html,xml,xslt,xls,Html,Xml,Xslt,Xls,我正在学习XSL,我对替换字符串中的特定字符有疑问 我们有xml文件 <family> -<familyid id="first"> --<name>smith</name> --<image>fatherpic\myfather.jpg</image> - --史密斯 --fatherpic\myfather.jpg 我想得到插入图片的图像路径 例如,我们有路径“fatherpic\myfather.jpg” 然后我
<family>
-<familyid id="first">
--<name>smith</name>
--<image>fatherpic\myfather.jpg</image>
-
--史密斯
--fatherpic\myfather.jpg
我想得到插入图片的图像路径
例如,我们有路径“fatherpic\myfather.jpg”
然后我想选择“fatherpic/myfather.jpg”
这意味着我想将“/”改为“\”
我试着使用translate函数。但它不起作用
有人能举个例子吗?谢谢正如您在帖子中所说,您可以使用翻译功能
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" />
<xsl:template match="text()" />
<xsl:template match="image">
<xsl:value-of select="translate(., '\', '/')" />
</xsl:template>
</xsl:stylesheet>
下面的样式表提取图像值的值,并在执行所描述的字符串转换后将其作为文本输出。这只是一个如何使用translate函数的示例
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" />
<xsl:template match="text()" />
<xsl:template match="image">
<xsl:value-of select="translate(., '\', '/')" />
</xsl:template>
</xsl:stylesheet>
希望有帮助。正如您在帖子中所说,您可以使用翻译功能
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" />
<xsl:template match="text()" />
<xsl:template match="image">
<xsl:value-of select="translate(., '\', '/')" />
</xsl:template>
</xsl:stylesheet>
下面的样式表提取图像值的值,并在执行所描述的字符串转换后将其作为文本输出。这只是一个如何使用translate函数的示例
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" />
<xsl:template match="text()" />
<xsl:template match="image">
<xsl:value-of select="translate(., '\', '/')" />
</xsl:template>
</xsl:stylesheet>
希望对您有所帮助。以下xslt将打印图像元素中的“\”替换为“/”,并将打印xml文件的其余部分,不作更改
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<xsl:template match="image">
<image>
<xsl:value-of select="translate(., '\', '/')" />
</image>
</xsl:template>
</xsl:stylesheet>
以下xslt将打印图像元素中的“\”替换为“/”,并将打印xml文件的其余部分,保持不变
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<xsl:template match="image">
<image>
<xsl:value-of select="translate(., '\', '/')" />
</image>
</xsl:template>
</xsl:stylesheet>
我们可以申请每个循环吗?您想循环什么?我们可以申请每个循环吗?您想循环什么?