【问题标题】:How to remove "tns:" and "xmlns:" from xsl:stylesheet in a JDeveloper SOA XSLT?如何从 JDeveloper SOA XSLT 中的 xsl:stylesheet 中删除“tns:”和“xmlns:”?
【发布时间】:2020-10-30 20:17:54
【问题描述】:

我有以下代码,由 SOA JDeveloper 中的 XSLT 转换创建:

<xsl:stylesheet version="1.0"
            xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
            xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
            xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/dbSelectStores"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
            xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
            xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
            xmlns:oracle-xsl-mapper="http://www.oracle.com/xsl/mapper/schemas"
            xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
            xmlns:oraxsl="http://www.oracle.com/XSL/Transform/java"
            xmlns:ns0="http://www.xxxxx.it/BO/transformation/types"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:tns="http://www.xxxxx.it/bo/dataexchange"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            exclude-result-prefixes="xsd oracle-xsl-mapper xsi xsl ns1 ns0 tns mhdr oraext xp20 xref socket dvm oraxsl"
            xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
            xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
            xmlns:ns2="http://xmlns.oracle.com/pcbpel/adapter/db/IntegrationBackOffice/BOTransformations/dbSelectStores"
            xmlns:client="http://xmlns.oracle.com/IntegrationBackOffice/BOTransformations/TransformationBPEL"
            xmlns:ns3="http://xmlns.oracle.com/pcbpel/adapter/ftp/IntegrationBackOffice/BOTransformations/ftpCEDETLReference"> <xsl:param name="StoresInvoke_OutputVariable.dbSelectStoresOutputCollection"/><xsl:template match="/">
  <tns:VSBODataExchange>
  <tns:Import ImportId="{/ns0:input/ns0:flowId}" ImportDate="{xp20:current-date ( )}">
    <tns:Stores>
      <xsl:for-each select="$StoresInvoke_OutputVariable.dbSelectStoresOutputCollection/ns1:dbSelectStoresOutputCollection/ns1:dbSelectStoresOutput">
        <tns:Store Operation="IU" ItemNo="{position ( )}">
          <tns:StoreId>
            <xsl:value-of select="oraext:right-trim(ns1:BS1000)"/>
          </tns:StoreId>
        </tns:Store>
      </xsl:for-each>
    </tns:Stores>
  </tns:Import>
</tns:VSBODataExchange>
</xsl:template> </xsl:stylesheet>

这是输出:

<?xml version="1.0" encoding="UTF-8"?>
<VSBODataExchange xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:ns2="http://xmlns.oracle.com/pcbpel/adapter/db/IntegrationBackOfficeToshiba/BOTransformations/dbSelectStores" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:ns3="http://xmlns.oracle.com/pcbpel/adapter/ftp/IntegrationBackOfficeToshiba/BOTransformations/ftpCEDETLReference" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:client="http://xmlns.oracle.com/IntegrationBackOfficeToshiba/BOTransformations/TransformationBPEL" xmlns:tns="http://www.gabriellispa.it/bo/toshiba/dataexchange" xmlns="http://www.gabriellispa.it/bo/toshiba/dataexchange">
    <tns:Import ImportId="420036" ImportDate="2020-07-07">
        <tns:Stores>
            <tns:Store Operation="IU" ItemNo="1">
                <tns:StoreId>401</tns:StoreId>
            </tns:Store>
        </tns:Stores>
    </tns:Import>
</VSBODataExchange>

但我的输出必须在元素标记中没有“tns:”,并且可能在 xsl 样式表中没有“xmlns:”,如下所示:

<?xml version="1.0" encoding="UTF-8" ?>
<VSBODataExchange>
<Import ImportId="5" ImportDate="2018-08-06">
<Stores>
<Store Operation="IU" ItemNo="1">
    <StoreId>1</StoreId>
</Store>
</Stores>
</Import>

如何替换标记元素中的“tns:”并从输出的样式表中删除所有“xmls:...”? 提前致谢。

【问题讨论】:

    标签: xml xslt soa


    【解决方案1】:

    您在词法输出方面考虑的太多,而不是样式表生成的节点的 XDM 树。您需要考虑结果树中元素的扩展名称(扩展名称是命名空间 URI 加上本地名称),并让序列化自行处理。

    您在输出中获得命名空间声明和前缀名称,因为您在非空命名空间中创建元素。要修复它,您需要生成无命名空间元素。实现这一目标的第一步是从样式表中的所有文字结果元素中去掉“tns:”前缀。这可能就是您需要做的所有事情:很难说。

    我猜你在样式表中声明了 20 个(大部分)未使用的命名空间是有原因的,但这不是一个好习惯。你不能假设它们被简单地忽略了。

    【讨论】:

      猜你喜欢
      • 2015-12-31
      • 1970-01-01
      • 2015-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多