none
How to remove Namespaces from XML tags when using FOR XML option WITH XMLNAMESPACES RRS feed

  • Question

  • Hello,

    i have a problem with xml formatting using SQL FOR XML structure.

    I have written SQL QUERY which generates XML  string like that:

     

    <asx:abap xmlns:asx="http://www.sap.com/abapxml">
     <asx:values xmlns:asx="http://www.sap.com/abapxml">
      <HEADER xmlns:asx="http://www.sap.com/abapxml">
       <PLANT>LT</PLANT>
       <MSG_NUMBER>24</MSG_NUMBER>
       <IDOC_NUMBER>24</IDOC_NUMBER>
       <EXEC_TYPE>I</EXEC_TYPE>
      </HEADER>
      <ITEM xmlns:asx="http://www.sap.com/abapxml">
       <ZCTX_PLU_ITEM xmlns:asx="http://www.sap.com/abapxml">
        <OPERATION>U</OPERATION>
        <DISPLAY_DESCR>Aprasymas</DISPLAY_DESCR>
        <RECEIPT_DESCR>Aprasymas</RECEIPT_DESCR>
        <MATERIAL_NUMBER>1_ITEM2</MATERIAL_NUMBER>
        <VENDOR_NUMBER>TEST</VENDOR_NUMBER>
        <ORIGIN_COUNTRY>TEST</ORIGIN_COUNTRY>
        <WEIGHTABLE_SCALES>0</WEIGHTABLE_SCALES>
        <PRICE_REQUIRED>0</PRICE_REQUIRED>
        <BASE_UNIT />
        <BASE_UNIT_QUANTITY>0.00000000000000000000</BASE_UNIT_QUANTITY>
        <FB_DEPARTMENT>1</FB_DEPARTMENT>
        <WEIGHTABLE_POS>X</WEIGHTABLE_POS>
        <TAX_CODE>0.00000000000000000000</TAX_CODE>
       </ZCTX_PLU_ITEM>
      </ITEM>
     </asx:values>
    </asx:abap>
    

     

    SQL query uses option 

     

    ;WITH XMLNAMESPACES('http://www.sap.com/abapxml' as asx)
    

     


    to add XML namespaces.

    Here is an example of SQL code, which formats XML string:

     

    ;WITH XMLNAMESPACES('http://www.sap.com/abapxml' as asx)
    select (--abap
    	select (--values
    		.....
    		FOR XML PATH('HEADER'), type),
    .....
    
    FOR XML PATH(''), root('ITEM'), type
    )
    	FOR XML PATH('asx:values'), type ) 
    FOR XML PATH('asx:abap'), type
    

    But i do not need to add automatically  namespaces on the <ITEM/> and <ZCTX_PLU_ITEM/> tags. 

    Is any option to prevent adding namespaces to those tags?


     

     

    Monday, July 25, 2011 3:19 PM

Answers