【问题标题】:Remove CDATA from XML in DataPower在 DataPower 中从 XML 中删除 CDATA
【发布时间】:2016-07-29 10:59:16
【问题描述】:

当我试图从我的请求中删除 CDATA 时,我遇到了一个有线问题。它在我的本地 IDE 中运行良好,但在 DataPower 中却不行。要求是如果它在 XML 中找到一个 CDATA 标记,它应该删除它,否则它不应该做任何事情。 输入 XML:

<response status="200">
    <CustomELearningVO>
        <ClassListVO>
            <![CDATA[
<CLASS_TAB_OBJ>
<CLASS_TAB>
<CLASS_OBJ>
<ClassId>123456</ClassId>
<ClassName>Sample Class1</ClassName>
<Status>Not Attempted</Status>
<Link>link</Link>
<PlayEnable>Y</PlayEnable>
</CLASS_OBJ>

<CLASS_OBJ>
<ClassId>56789</ClassId>
<ClassName>Sample Class2</ClassName>
<Status>Failed</Status>
<Link>link2</Link><PlayEnable>Y</PlayEnable>
</CLASS_OBJ>

<CLASS_OBJ>
<ClassId>56788</ClassId>
<ClassName>Sample Class3</ClassName>
<Status>Failed</Status>
<PlayEnable>N</PlayEnable>
<PlayMessage>"Course cannot be played as Certfication subscribed to Course has Expired"</PlayMessage>
</CLASS_OBJ>

</CLASS_TAB>
</CLASS_TAB_OBJ>
]]>

        </ClassListVO>
        <eBSErrorCode>0</eBSErrorCode>
        <eBSErrorMessage>SUCCESS</eBSErrorMessage>
    </CustomELearningVO>
</response>

我用来删除 CDATA 的 XSL:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output 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="." disable-output-escaping="yes" />
</xsl:template>

</xsl:stylesheet>

【问题讨论】:

  • 您尝试过其他样式表吗?做他们的工作 ?可能是这里的选项之一stackoverflow.com/questions/3708055/extract-cdata-using-xslt ?
  • 我也试过这个,但到目前为止没有运气:(
  • 您的处理器很可能不支持disable-output-escaping - XSLT 规范并不要求这样做。
  • 但如果我删除禁用输出转义 更改为 < >
  • 好吧,那么它确实支持disable-output-escaping(或者至少不会忽略它)。那么究竟是什么问题呢?它是否保留 CDATA 标记?

标签: xslt ibm-datapower


【解决方案1】:

使用适用于 XML 序列化数据的样式表解决了该问题。

【讨论】:

    猜你喜欢
    • 2014-10-05
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 1970-01-01
    • 1970-01-01
    • 2013-07-01
    • 1970-01-01
    相关资源
    最近更新 更多