Let's put your Input XML in a root node as below:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<MyInfo isSurname="true">
<name sysid="0">Google</name>
</MyInfo>
</Root>
The solution in XSLT 1.0, can be:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="/Root/MyInfo">
<xsl:choose>
<xsl:when test="@isSurname = 'true'">
<xsl:copy>
<xsl:attribute name="surname">
<xsl:value-of select="'Drive'" />
</xsl:attribute>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/Root/MyInfo[@isSurname = 'true']/name/text()">
<xsl:value-of select="concat(.,' Drive')" />
</xsl:template>
There's a check based on the isSurname attribute.
- If it is
true, then the Output XML given by you will be populated.
- If it is
false, then the Input XML will be displayed as it is.