Search code examples
xmloracle-databaseweb-servicesxsltsoa

How can i remove blank xmlns attribute from thirdparty business service response message


I have third party service. An empty xmlns value is returned in one of the elements of this service

Here is the business service response

enter image description here

As you see, IthalatBeyannameler element has a blank xmlns="" thats why xslt transforming not working.

Here is my xslt

 <xsl:template match="/">
  <tns:KalemMarkaList>
     <xsl:for-each select="/ns0:AntrepoCikisDigerResponse/ns0:AntrepoCikisDigerResult/ns0:IthalatBeyannameler/ns0:IthalatBeyanname">
        <tns:KalemMarka>
           <tns:Sasi/>
           <tns:MaviRef>
              <xsl:value-of select="ns0:MaviRef"/>
           </tns:MaviRef>
           <tns:MusteriIsNo>
              <xsl:value-of select="ns0:MusteriIsNo"/>
           </tns:MusteriIsNo>
           <tns:Yil>
              <xsl:value-of select="ns0:Yil"/>
           </tns:Yil>
        </tns:KalemMarka>
     </xsl:for-each>
  </tns:KalemMarkaList>

how can i solve this problem.


Solution

  • As you see, IthalatBeyannameler element has a blank xmlns="" thats why xslt transforming not working.

    No. Your transformation is not working because you ignore it. You try to select:

    <xsl:for-each select="/ns0:AntrepoCikisDigerResponse/ns0:AntrepoCikisDigerResult/ns0:IthalatBeyannameler/ns0:IthalatBeyanname">
    

    when you should be doing:

    <xsl:for-each select="/ns0:AntrepoCikisDigerResponse/ns0:AntrepoCikisDigerResult/IthalatBeyannameler/IthalatBeyanname">
    

    that is remove the ns0 prefix when addressing elements which are in no-namespace due to the no-namespace declaration.

    For the same reason you need to change:

    <xsl:value-of select="ns0:MaviRef"/>
    

    to:

    <xsl:value-of select="MaviRef"/>
    

    and likewise for the other two xsl:value-of instructions.