xml - Replace value of one namespace attributes from many in xslt -


i have input soap message have multiple namespace attributes. want replace 1 attribute value many attributes , keep other attributes same.

my input

<abc:outerblock xmlns:abc="http://www.example1.com/" xmlns:abc2="www.example2.com" xmlns:abc4="http://www.example4.com" >     <abc4:innerblock>         <abc4:entry1>22</abc4:entry1>         <abc4:entry2>xyz</abc4:entry2>     </abc4:innerblock> </abc:outerblock> 

my output should this.

<abc:outerblock xmlns:abc="http://www.changed.com/" xmlns:abc2="www.example2.com" xmlns:abc4="http://www.example4.com" >     <abc4:innerblock>         <abc4:entry1>22</abc4:entry1>         <abc4:entry2>xyz</abc4:entry2>     </abc4:innerblock> </abc:outerblock> 

after trying many solutions on stackoverflow. came solution.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">  <xsl:output omit-xml-declaration="yes" indent="yes"/>  <xsl:strip-space elements="*"/>   <xsl:template match="node()|@*">        <xsl:copy>        <xsl:apply-templates select="node()|@*"/>      </xsl:copy>  </xsl:template>   <xsl:template match="*[namespace-uri()='http://www.example1.com/']">   <xsl:element name="{name(.)}" namespace='http://www.changed.com/'>         <xsl:apply-templates select="node()|@*" />     </xsl:element></xsl:template> </xsl:stylesheet> 

but produce result this.

<abc:outerblock xmlns:abc="http://www.changed.com/">    <abc4:innerblock xmlns:abc="http://www.example1.com/"                     xmlns:abc2="www.example2.com"                     xmlns:abc4="http://www.example4.com">       <abc4:entry1>22</abc4:entry1>       <abc4:entry2>xyz</abc4:entry2>    </abc4:innerblock> </abc:outerblock>  

all tags copied child elements. appreciated.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -