【问题标题】:wso2 xslt mediator with namespaces带有命名空间的 wso2 xslt 调解器
【发布时间】:2017-03-23 09:27:48
【问题描述】:

我们想使用一个 xslt 中介器来转换一个 xml。 我们有这个肥皂信息。

  <?xml version = "1.0" encoding="ISO-8859-1"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.es">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:reception>
         <ws:xml>
           <message>Data messsage to send</message>
         </ws:xml>
      </ws:reception>
   </soapenv:Body>
</soapenv:Envelope>

我们想要这条消息作为结果。

  <?xml version = "1.0" encoding="ISO-8859-1"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.es">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:reception>
         <ws:xml>
           <![CDATA[<message>Data messsage to send]]></message>
         </ws:xml>
      </ws:reception>
   </soapenv:Body>
</soapenv:Envelope>

我们正在使用这个 xslt 模板

<?xml version = "1.0" encoding = "ISO-8859-1"?> 
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">

   <xsl:template match = "//ws:xml"> 
    <xsl:copy>
        <xsl:text disable-output-escaping="yes"> &lt;![CDATA[</xsl:text>
             <xsl:copy-of select="*"/>
         <xsl:text disable-output-escaping="yes"> ]]&gt;</xsl:text>
    </xsl:copy>   
    </xsl:template>  
</xsl:stylesheet>

但它不起作用。

谁能帮助我们??

提前致谢。

【问题讨论】:

    标签: wso2 wso2esb


    【解决方案1】:

    您的两个文件是相同的。但如果我的想法是正确的,你想改变

    <message>Data messsage to send</message>
    

    进入

    <message><![CDATA[Data messsage to send]]></message>
    

    如果是这样,请尝试以下操作:

    (代码已被编辑以反映更新的问题)

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="message">
        <xsl:text disable-output-escaping="yes"> &lt;![CDATA[</xsl:text>
        <message>
            <xsl:value-of select="//message"/>
        </message>
        <xsl:text disable-output-escaping="yes"> ]]&gt;</xsl:text>      
    </xsl:template>
    

    请注意,Michael Kay 会因为你使用disable-output-escaping 而对你大喊大叫

    【讨论】:

    • 对不起。我们想要 消息数据]]>
    • 好的,谢谢。但是,如果我们在消息 xml 标签中包含一个 xml 标签,这个模板会删除标签,它只显示标签的内容,如 data ]]>..,它应该显示.....data]]>....
    • 好的,如果我使用 xsl:copy-of 而不是 xsl:value-of,我们就有了我们想要的。非常感谢您的快速回答和关注。
    猜你喜欢
    • 2012-05-26
    • 1970-01-01
    • 2016-04-27
    • 2021-10-24
    • 1970-01-01
    • 2018-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多