My input XML is as below:
<MessageOutput Status="2">
<Source>External</Source>
<Error>Server not reachable</Error>
<LineNo>0</LineNo>
</MessageOutput>
My requirement is to write XSLT and check if <Error> tag has value "Server not reachable" and if yes then change the Status attribute value to "3".
I wrote below code but getting error:
"XSLT Error: Open quote is expected for attribute "{1}" associated with an element type "Status"."
Please assist.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="ISO-8859-1"/>
<xsl:variable name="Des" select="'Server not reachable'"/>
<xsl:variable name="Err" select="MessageOutput/Error"/>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="/MessageOutput">
<xsl:choose>
<xsl:when test="$Des=$Err">
<MessageOutput Status="3">
<xsl:apply-templates/>
</MessageOutput>
</xsl:when>
<xsl:otherwise>
<MessageOutput Status=<xsl:value-of select="@Status"/>>
<xsl:apply-templates/>
</MessageOutput>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>