I faced a strange problem working with XSLT and XML. I am creating an MVC application that reads an XSLT file containing templates and variables and process their contents. After the processing I saw that many changes were made to some nodes that would not have to be touched.
At some point in the XSLT file, I have a variable which content is
<xsl:choose>
<xsl:when test="@resCurrPage = 1">1</xsl:when>
<xsl:when test="@resCurrPage > 4">3</xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose>
but when the processing is finished the sedond <xsl:when> is transformed into<xsl:when test="@resCurrPage > 4">3</xsl:when>.
I figured it out that the transformation from > into > seems to be happened when the
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(templateFile);
XmlNodeList nodeList = xDoc["xsl:stylesheet"].ChildNodes;
is called. (templateFile is a string containing the XSLT file)
My question is why is this transformation happening? and how could I avoid it?
<el att=">">and<el att=">">are exactly the same XML, if a comparison considers them different then the comparison is buggy and those bugs are going to cause some other problem anyway so needs to be fixed.