删除 XSL 中的双引号 [英] Removing double quotes in XSL

查看:25
本文介绍了删除 XSL 中的双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 XSL 1.0,我有这种 XML-

I am using XSL 1.0, I have this kind of XML-

<ID>"7080"</ID>
<NAME>"Media"</NAME>
<ADDRESS>
    <STREET_1>"400 Street"</STREET_1>
</ADDRESS>

这些值带有双引号.我试图在 XSL 1.0 中删除这些双引号并将我的结果显示为:

The values are coming with Double Quotes. I am trying to remove these double quotes in XSL 1.0 and show up my Result as:

 <ID>7080</ID>
    <NAME>Media</NAME>
    <ADDRESS>
        <STREET_1>400 Street</STREET_1>
    </ADDRESS>

此外,我已经尝试将翻译功能应用于 XML 的根元素,但它不起作用.任何建议都会有所帮助!

Also, I have tried it to apply translate function to the root element of the XML but it isn't working. Any suggestion would help!

推荐答案

您可以使用 translate 将(转义的)双引号替换为空字符.

You can use translate to replace the (escaped) double quote with an empty char.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="*/text()">
        <xsl:value-of select="translate(., '\&quot;', '')"/>
    </xsl:template>

</xsl:stylesheet>

当与上面的身份转换和一个shoutcase XML 根元素包装器一起使用时,返回:

When used with the identity transform above and a shoutcase XML root element wrapper, this returns:

<XML>
    <ID>7080</ID>
    <NAME>Media</NAME>
    <ADDRESS>
        <STREET_1>400 Street</STREET_1>
    </ADDRESS>
</XML>

这篇关于删除 XSL 中的双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆