如何替换 XSLT 中的选择字符 [英] How to replace select characters in XSLT
本文介绍了如何替换 XSLT 中的选择字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个类似于
<?xml version="1.0" encoding="UTF-8"?>
<Properties>
<Property>
<Name>Email</Name>
<Value>alebbb@hotmail.com</Value>
</Property>
<Property>
<Name>Resposta</Name>
<Value>here "i" have ; to be"" replace by nothing</Value>
</Property>
<Property>
<Name>NPS</Name>
<Value>8</Value>
</Property>
</Properties>
我的地图 XSLT 就像:
and my map XSLT is like:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:strip-space elements="*"/>
<xsl:template match="Properties">
<xsl:variable name="Email" select="/Properties/Property[1]/Value/text()"/>
<xsl:variable name="Resposta" select="/Properties/Property[2]/Value/text()"/>
<xsl:variable name="NPS" select="/Properties/Property[3]/Value/text()"/>
<xsl:value-of select="normalize-space($Email)"/>;<xsl:value-of select="normalize-space($Resposta)"/>;<xsl:value-of select="normalize-space($NPS)"/>
</xsl:template>
</xsl:stylesheet>
如何在我的 XSLT 映射中使用 replace 替换 ;
和 "
和 ""
?
我得到:
How can I replace ;
and "
and ""
by nothing using replace at my XSLT map?
I got:
here "i" have ; to be"" replace by nothing
预期:
here i have to be replaced by nothing
我使用下面的代码代替 ;
:
I'm using the below for substitute the ;
:
<xsl:value-of select="normalize-space(translate($Resposta,';',' '))"/>
推荐答案
鉴于:
<Value>here "i" have ; to be"" replace by nothing</Value>
说明:
<xsl:value-of select="normalize-space(translate(Value, ';"', ''))"/>
将返回:
here i have to be replace by nothing
<小时>
演示:https://xsltfiddle.liberty-development.net/ncdD7mt
这篇关于如何替换 XSLT 中的选择字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文