cancel
Showing results for 
Search instead for 
Did you mean: 

Remove xmlns in xml file

Former Member
0 Kudos

Hi All,

how to remove xmlns in input xml. Because it's bring empty value when i call this in atoms

I find following xslt. Where i will use below xslt  in atom

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:template match="*">

        <xsl:element name="{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

    <!-- template to copy attributes -->

    <xsl:template match="@*">

        <xsl:attribute name="{local-name()}">

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

        </xsl:attribute>

    </xsl:template>.

This is my xml file.

?xml version="1.0" encoding="UTF-8"?>

<orders xmlns="http://www.fhjfsj.com/xml/duu/order/2010-10-31">

    <order order-no="EU_325278">      

        <invoice-no>679900</invoice-no>

        <customer>

</orders>

</order>

Output in next atom like that below

<orders>

    <order order-no="EU_325278">      

        <invoice-no>679900</invoice-no>

        <customer>

</orders>

Accepted Solutions (1)

Accepted Solutions (1)

pierrecanali
Active Participant
0 Kudos

Hi Narain,

try with this:


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns="http://www.fhjfsj.com/xml/duu/order/2010-10-31" xmlns:b1e="urn:com.sap.b1i.sim:b1event" xmlns:b1ie="urn:com.sap.b1i.sim:b1ievent" xmlns:b1im="urn:com.sap.b1i.sim:b1imessage" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:utils2="com.sap.b1i.bpc_tools.Utilities" xmlns:vpf="urn:com.sap.b1i.vplatform:entity" xmlns:xci="urn:com.sap.b1i.xcellerator:intdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" bfa:force="" vpf:force="" jdbc:force="" rfc:force="" b1ie:force="" b1e:force="" xci:force="" sim:force="" utils2:force="" b1im:force="">

    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

    <xsl:param name="atom"/>

    <xsl:param name="sessionid"/>

    <xsl:variable name="msg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;S&apos;]"/>

    <xsl:variable name="vpSender" select="/vpf:Msg/vpf:Header/vpf:Sender/@Id"/>

    <xsl:variable name="vpObject" select="/vpf:Msg/vpf:Header/vpf:Sender/@ObjId"/>

    <xsl:variable name="vpReceiver" select="/vpf:Msg/vpf:Header/vpf:ReceiverList/vpf:Receiver[./@handover=&apos;P&apos;]/@Id"/>

    <xsl:template match="/">

        <Msg xmlns="urn:com.sap.b1i.vplatform:entity">

            <xsl:copy-of select="/vpf:Msg/@*"/>

            <xsl:copy-of select="/vpf:Msg/vpf:Header"/>

            <Body>

                <xsl:copy-of select="/vpf:Msg/vpf:Body/*"/>

                <Payload Role="R" id="{$atom}">

                    <xsl:call-template name="transform"/>

                </Payload>

            </Body>

        </Msg>

    </xsl:template>

    <xsl:template name="transform">

        <xsl:apply-templates select="$msg/*"/>

    </xsl:template>

    <xsl:template match="@* | node()">

        <xsl:choose>

            <xsl:when test="string-length(namespace-uri()) > 0">

                <xsl:element name="{local-name()}" xmlns="">

                    <xsl:apply-templates select="@* | node()"/>

                </xsl:element>

            </xsl:when>

            <xsl:otherwise>

                <xsl:copy>

                    <xsl:apply-templates select="@* | node()"/>

                </xsl:copy>

            </xsl:otherwise>

        </xsl:choose>

    </xsl:template>

</xsl:stylesheet>

Sender's Payload:


<?xml version="1.0" encoding="UTF-8"?>

<orders xmlns="http://www.fhjfsj.com/xml/duu/order/2010-10-31">

    <order order-no="EU_325278">    

        <invoice-no>679900</invoice-no>

      </order>

</orders>

result Message:


<Msg xmlns="urn:com.sap.b1i.vplatform:entity" MessageId="15101115591055522913C0A8087A2239" BeginTimeStamp="20151011155910" logmsg="0000" SubMessageId="" status="success" owntst="true" test="true">

    <Header>

        <IPO Id="vPlatform_Test"/>

        <Sender Id="" ObjId="DTL.TestXmlns"/>

        <Receiver Id=""/>

        <ReceiverList>

            <Receiver Id="" handover="P"/>

        </ReceiverList>

        <Identification Ident="Void" IdPar="n.a."/>

        <nsList/>

        <vBIU Id="DTL.TestXmlns" ver="1.0.0" SId="DTL.ImportTdb" filter="" phase=""/>

        <Variables>

            <var id="userid" value=""/>

            <var id="username" value=""/>

        </Variables>

        <Properties/>

        <SysTypeProperties type="B1if" offline="" snd="senderdummy" rcv="receiverdummy" ssystype="" rsystype=""/>

        <LocalProperties type="B1if" biu="DTL.TestXmlns" snd="senderdummy" rcv="receiverdummy" sid="DTL.ImportTdb" offline=""/>

        <VarProperties/>

    </Header>

    <Body>

        <Payload Role="T" Type="Call"/>

        <Payload Role="S">

            <orders xmlns="http://www.fhjfsj.com/xml/duu/order/2010-10-31">

                <order order-no="EU_325278">

                    <invoice-no>679900</invoice-no>

                </order>

            </orders>

        </Payload>

        <Payload Role="R" id="atom0">

            <orders xmlns="">

                <order order-no="EU_325278">

                    <invoice-no>679900</invoice-no>

                </order>

            </orders>

        </Payload>

    </Body>

</Msg>

Hope this helps.

Regards

Pierre

Former Member
0 Kudos

Thanks Pierre

Former Member
0 Kudos

Hi Pierre I have the same scenario, but I cant remove the xmlns="" is there ay way to remove it?

Regards

David

Answers (5)

Answers (5)

Former Member
0 Kudos

Any Help?

Former Member
0 Kudos

Hi

Check this:

xslt - How to &amp;#39;select&amp;#39; from XML with namespaces? - Stack Overflow

then...

modify your stylesheet adding name for your namespace (here 'order') for example like this:


<xsl:stylesheet xmlns:order="http://www.fhjfsj.com/xml/duu/order/2010-10-31" xmlns:b1e="urn:com.sap.b1i.sim:b1event" [other namespaces...] />

then your select should look like this:


<xsl:value-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role='S']/order:orders/order:order/@order-no" />

Kind regards,

Radek

Former Member
0 Kudos

hi Thanks for youre replies. this is also not working for me.

Please any one advice how i include the below code in atom and get result.  The below lines bring output in xml editor. So how i  use this below code in atom

<xsl:template match="*">

        <xsl:element name="{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

   

   

<xsl:template match="@* | text() | comment() | processing-instruction()">

    <xsl:copy/>

  </xsl:template>

Former Member
0 Kudos

Any solutons?

Former Member
0 Kudos

HI

where do you generate the xml file from SAP?

bastian_schaefer
Active Contributor
0 Kudos

Hi,

why are you copying the attributes, if you don't need them?

Just leave your "copy attributes" segment away and the namespace will not be copied.

In case you need some other attributes (not the namespaces) you could alternatively set following attribute xmlns="" into your element.

Best regards

Bastian

Former Member
0 Kudos

hi bastian,

i parse the value from xml. it's show empty. i used below xpath

/vpf:Msg/vpf:Body/vpf:Payload[./@Role='S']/orders/order/@order-no

xml file

?xml version="1.0" encoding="UTF-8"?>

<orders xmlns="http://www.fhjfsj.com/xml/duu/order/2010-10-31">

    <order order-no="EU_325278">      

        <invoice-no>679900</invoice-no>

        <customer>

</orders>

</order>

but when i change xml file and read the data it's comes correctly. So i want remove xmlns.

?xml version="1.0" encoding="UTF-8"?>

<orders>

    <order order-no="EU_325278">      

        <invoice-no>679900</invoice-no>

        <customer>

</orders>

</order>

Former Member
0 Kudos

is this a dmee file?

Former Member
0 Kudos

it's not dmee file.

Former Member
0 Kudos

HI,

is this a DMEE payment file?

regards

sinu