不会通过 XSLT 从 XML 中删除特殊字符
Special Characters will not be removed from XML via XLST
我似乎无法删除一些特殊字符 XML。它们是省略号、双引号和单引号。我正在转义特殊字符并在我的列表中也有一个句点,但它不会删除。除这几项外,其他所有内容都会删除。
这是 XLST:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="/">
<soa:Label identifier="6f109b37-d9d1-4ff3-8e16-7ecffa08be1f" name="To Avid Transcript" description="" instance="b885c5f1-6307-42ff-a79c-42d61bc4464e" signature="00000000-0000-0000-0000-000000000000" xmlns:soa="urn:telestream.net:soa:core">
<soa:Parameter type="string" identifier="32bd5202-f003-4da3-8d1f-2b5a5d324af9" bindable="True" name="Transcript" enabled="true" disableable="false" optionseditable="false">
<xsl:variable name = "apos">'</xsl:variable>
<xsl:value-of select="translate(Transcript, '♪!@#&"<>$%^*()[]{}?/.,:;™-', '')"/>
</soa:Parameter>
</soa:Label>
</xsl:template>
</xsl:stylesheet>
这是 XML 的一部分:
<Transcript>[1:45] JD: : Hi, I’m John Doe, executive vice president. Right now you are tuning in to a very special Program, “Program Name.” seeing in the world today...</Transcript>
目前的转换结果如下所示:
<?xml version="1.0" encoding="utf-16"?>
<soa:Label identifier="6f109b37-d9d1-4ff3-8e16-7ecffa08be1f" name="To Avid Transcript" description="" instance="b885c5f1-6307-42ff-a79c-42d61bc4464e" signature="00000000-0000-0000-0000-000000000000" xmlns:soa="urn:telestream.net:soa:core">
145 JDY Hi I’m John Doe executive vice president Right now you are tuning in to a very special Progra “Program Name” seeing in the world today...
</soa:Parameter>
</soa:Label>
如您所见,这些特定字符并未被删除。任何帮助都会很棒。
您的输入包含 "smart quotes"。要删除这些,请使用:
translate(Transcript, '‘’“”', '')
我无法重现您关于这段时间的问题。
我似乎无法删除一些特殊字符 XML。它们是省略号、双引号和单引号。我正在转义特殊字符并在我的列表中也有一个句点,但它不会删除。除这几项外,其他所有内容都会删除。
这是 XLST:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="/">
<soa:Label identifier="6f109b37-d9d1-4ff3-8e16-7ecffa08be1f" name="To Avid Transcript" description="" instance="b885c5f1-6307-42ff-a79c-42d61bc4464e" signature="00000000-0000-0000-0000-000000000000" xmlns:soa="urn:telestream.net:soa:core">
<soa:Parameter type="string" identifier="32bd5202-f003-4da3-8d1f-2b5a5d324af9" bindable="True" name="Transcript" enabled="true" disableable="false" optionseditable="false">
<xsl:variable name = "apos">'</xsl:variable>
<xsl:value-of select="translate(Transcript, '♪!@#&"<>$%^*()[]{}?/.,:;™-', '')"/>
</soa:Parameter>
</soa:Label>
</xsl:template>
</xsl:stylesheet>
这是 XML 的一部分:
<Transcript>[1:45] JD: : Hi, I’m John Doe, executive vice president. Right now you are tuning in to a very special Program, “Program Name.” seeing in the world today...</Transcript>
目前的转换结果如下所示:
<?xml version="1.0" encoding="utf-16"?>
<soa:Label identifier="6f109b37-d9d1-4ff3-8e16-7ecffa08be1f" name="To Avid Transcript" description="" instance="b885c5f1-6307-42ff-a79c-42d61bc4464e" signature="00000000-0000-0000-0000-000000000000" xmlns:soa="urn:telestream.net:soa:core">
145 JDY Hi I’m John Doe executive vice president Right now you are tuning in to a very special Progra “Program Name” seeing in the world today...
</soa:Parameter>
</soa:Label>
如您所见,这些特定字符并未被删除。任何帮助都会很棒。
您的输入包含 "smart quotes"。要删除这些,请使用:
translate(Transcript, '‘’“”', '')
我无法重现您关于这段时间的问题。