Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:31:02+00:00 2026-05-26T16:31:02+00:00

My need is just to repalce the attribute value of name. If this attribute

  • 0

My need is just to repalce the attribute value of “name”. If this attribute has “default” as the value, It should be changed to “New”. Rest everything should be copy of the input xml. i tried with the below xsl however it is not working.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>

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

   <xsl:template match="SORRegion[@name='default']">
    <xsl:attribute name="name">
    <xsl:value-of select="'New'"/>
    </xsl:attribute>  
     <xsl:copy-of select="child::*"/>
    </xsl:template>

</xsl:stylesheet>

Input xml

<RoutingDetails>
    <Service ServiceName="StatementIndicatorsService">
        <SOR SORname="Globestar">
            <CountryCode Ctrycd="124">
                <SORRegion name="Test">
                    <ConsumerName name="MYCA">
                        <AutomationIds>
                            <PreAutoId>
                                <AutomationId>XA1146A</AutomationId>
                                <AutomationId>XA1146A</AutomationId>
                            </PreAutoId>
                            <DefaultAutoId>
                                <AutomationId>XA1146A</AutomationId>
                            </DefaultAutoId>
                        </AutomationIds>
                    </ConsumerName>
                    <QueueDetails>
                        <QueueManager>MAO1</QueueManager>
                        <ReplyQueueManager>MAO1</ReplyQueueManager>
                        <RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
                        <ReplyQueue>ICS.DP.REPLY</ReplyQueue>
                    </QueueDetails>

                </SORRegion>
                <SORRegion name="default">
                    <ConsumerName name="MYCA">
                        <AutomationIds>
                            <PreAutoId>
                                <AutomationId>XA1146A</AutomationId>
                                <AutomationId>XA1146A</AutomationId>
                            </PreAutoId>
                            <DefaultAutoId>
                                <AutomationId>XA1146A</AutomationId>
                            </DefaultAutoId>
                        </AutomationIds>
                    </ConsumerName>
                    <QueueDetails>
                        <QueueManager>MAO1</QueueManager>
                        <ReplyQueueManager>MAO1</ReplyQueueManager>
                        <RequestQueue>DEFAULT.REQUEST</RequestQueue>
                        <ReplyQueue>ICS.DP.REPLY</ReplyQueue>
                    </QueueDetails>

                </SORRegion>
            </CountryCode>
        </SOR>
    </Service>
</RoutingDetails>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:31:03+00:00Added an answer on May 26, 2026 at 4:31 pm
       <xsl:template match="SORRegion[@name='default']"> 
        <xsl:attribute name="name"> 
          <xsl:value-of select="'New'"/> 
        </xsl:attribute>   
        <xsl:copy-of select="child::*"/> 
       </xsl:template> 
    

    There are a number of problems with this code. The most important problem is that it deletes the current node (the SORRegion element) and replaces it with just an attribute.

    The solution is to match the attribute that should be updated.

    This transformation:

    <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="SORRegion/@name[.='default']">
      <xsl:attribute name="name">
        <xsl:value-of select="'New'"/>
      </xsl:attribute>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <RoutingDetails>
        <Service ServiceName="StatementIndicatorsService">
            <SOR SORname="Globestar">
                <CountryCode Ctrycd="124">
                    <SORRegion name="Test">
                        <ConsumerName name="MYCA">
                            <AutomationIds>
                                <PreAutoId>
                                    <AutomationId>XA1146A</AutomationId>
                                    <AutomationId>XA1146A</AutomationId>
                                </PreAutoId>
                                <DefaultAutoId>
                                    <AutomationId>XA1146A</AutomationId>
                                </DefaultAutoId>
                            </AutomationIds>
                        </ConsumerName>
                        <QueueDetails>
                            <QueueManager>MAO1</QueueManager>
                            <ReplyQueueManager>MAO1</ReplyQueueManager>
                            <RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
                            <ReplyQueue>ICS.DP.REPLY</ReplyQueue>
                        </QueueDetails>
    
                    </SORRegion>
                    <SORRegion name="default">
                        <ConsumerName name="MYCA">
                            <AutomationIds>
                                <PreAutoId>
                                    <AutomationId>XA1146A</AutomationId>
                                    <AutomationId>XA1146A</AutomationId>
                                </PreAutoId>
                                <DefaultAutoId>
                                    <AutomationId>XA1146A</AutomationId>
                                </DefaultAutoId>
                            </AutomationIds>
                        </ConsumerName>
                        <QueueDetails>
                            <QueueManager>MAO1</QueueManager>
                            <ReplyQueueManager>MAO1</ReplyQueueManager>
                            <RequestQueue>DEFAULT.REQUEST</RequestQueue>
                            <ReplyQueue>ICS.DP.REPLY</ReplyQueue>
                        </QueueDetails>
    
                    </SORRegion>
                </CountryCode>
            </SOR>
        </Service>
    </RoutingDetails>
    

    produces exactly the wanted, correct result:

    <RoutingDetails>
       <Service ServiceName="StatementIndicatorsService">
          <SOR SORname="Globestar">
             <CountryCode Ctrycd="124">
                <SORRegion name="Test">
                   <ConsumerName name="MYCA">
                      <AutomationIds>
                         <PreAutoId>
                            <AutomationId>XA1146A</AutomationId>
                            <AutomationId>XA1146A</AutomationId>
                         </PreAutoId>
                         <DefaultAutoId>
                            <AutomationId>XA1146A</AutomationId>
                         </DefaultAutoId>
                      </AutomationIds>
                   </ConsumerName>
                   <QueueDetails>
                      <QueueManager>MAO1</QueueManager>
                      <ReplyQueueManager>MAO1</ReplyQueueManager>
                      <RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
                      <ReplyQueue>ICS.DP.REPLY</ReplyQueue>
                   </QueueDetails>
                </SORRegion>
                <SORRegion name="New">
                   <ConsumerName name="MYCA">
                      <AutomationIds>
                         <PreAutoId>
                            <AutomationId>XA1146A</AutomationId>
                            <AutomationId>XA1146A</AutomationId>
                         </PreAutoId>
                         <DefaultAutoId>
                            <AutomationId>XA1146A</AutomationId>
                         </DefaultAutoId>
                      </AutomationIds>
                   </ConsumerName>
                   <QueueDetails>
                      <QueueManager>MAO1</QueueManager>
                      <ReplyQueueManager>MAO1</ReplyQueueManager>
                      <RequestQueue>DEFAULT.REQUEST</RequestQueue>
                      <ReplyQueue>ICS.DP.REPLY</ReplyQueue>
                   </QueueDetails>
                </SORRegion>
             </CountryCode>
          </SOR>
       </Service>
    </RoutingDetails>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need just a push in the right direction with this. I'm building a multi-language
I'm quite new to develop on GAE. Need just sort out few questions about
I find this selector format cumbersome if I need to use it often: $('[name=someElementName]').val()
I need an expression for PHP preg_replace so just replace [ and ] with
I need a function just like preg_replace but instead of strings I need it
I need just one callback at the and of multiple callbacks. With a simple
I need just dictionary or associative array string => int . There is type
Really need just some guidance : Topological sort by arcs definition (from my question)
first of all, I'm really thankful for all your help. I need just one
I just need a help in configuring hiberclipse for my eclipse indigo version. Install

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.