Question

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.

Input XML:

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

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:

<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:

<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? And what can I do to get the expected output wihtout namespace prefixes, etc?

Thanks in advance, PM.

Was it helpful?

Solution

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. Since, there is nothing wrong with the XML created by OSB, no, there is no way you can remove the prefix. You should read this Namespaces in XML 1.1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top