Nhu cầu của tôi chỉ là để trả giá trị thuộc tính của "tên". Nếu thuộc tính này có "mặc định" làm giá trị, nó phải được thay đổi thành "Mới". Phần còn lại mọi thứ nên là bản sao của xml đầu vào. tôi đã thử với các xsl dưới đây tuy nhiên nó không hoạt động.Thay đổi giá trị của một thuộc tính cụ thể
<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>