简体   繁体   English

在OSB中修改命名空间的XSLT - 命名空间前缀奇怪?

[英]XSLT for namespace modify in OSB - namespace prefix oddity?

When running an XSLT transform in Oracle Service Bus 10gR3, the output XML appears differently to how it would appear using a standard XSLT processor. 在Oracle Service Bus 10gR3中运行XSLT转换时,输出XML的显示方式与使用标准XSLT处理器的方式不同。

Input XML: 输入XML:

<given xmlns="http://www.sample.co.uk/version/6">  
  <child>content here</child> 
</given>

XSLT: XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="*" >
    <xsl:element name="{local-name()}" namespace="{concat(substring-before(namespace-uri(), '/6'),'/7')}" >
      <xsl:apply-templates />
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>

Output XML: 输出XML:

<ns1537:given xmlns:ns1537="http://www.sample.co.uk/version/7">
  <ns1538:child xmlns:ns1538="http://www.sample.co.uk/version/7">content here</ns1538:child>
</ns1537:given>

As you can see, each node is being assigned a different incremental prefix? 如您所见,每个节点都被分配了不同的增量前缀? And also, the namespace attribute is included in each different node? 而且,命名空间属性包含在每个不同的节点中? I would have expected the output XML to be as follows: 我原以为输出XML如下:

<given xmlns="http://www.sample.co.uk/version/7">
  <child>content here</child> 
</given>

Can anyone explain why OSB's XSLT processor is producing the output as shown? 任何人都可以解释为什么OSB的XSLT处理器正在产生如图所示的输出? And what can I do to get the expected output wihtout namespace prefixes, etc? 我能做些什么来获得名称空间前缀等的预期输出?

Thanks in advance, PM. PM,提前谢谢。

What difference will it make if it defines the namespace prefix or not. 如果它定义名称空间前缀,它会有什么不同。 As long as the elements are qualified by proper namespace. 只要元素由适当的命名空间限定。 Moreover, namespace prefix makes the life easier for humans to read the xml. 而且,名称空间前缀使人类更容易阅读xml。 Since, there is nothing wrong with the XML created by OSB, no, there is no way you can remove the prefix. 因为,OSB创建的XML没有任何问题,不,你无法删除前缀。 You should read this Namespaces in XML 1.1 . 您应该在XML 1.1中阅读此命名空间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM