I have dynamic generated XML as below which populate node values in run-time.
<?xml version="1.0" encoding="utf-8" ?>
<master>
<child>
<category1>Category1_A</category1>
<category2>Category2_B </category2>
</child>
</master>
I have a category code configuration key in my web.config as below
<add key="Code" value="A1|A2" />
Below is my XSLT & i know this is not well formatted.
And I have following issues in this XSLT
- How I can pass config key in below function since it’s not in XML.
- If this method return false then I wants to return String message from XSLT attribute like “Sorry, Combination doesn't match.”
I know it’s pretty bit confusing but I know this is much interesting.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts"> <msxsl:script language="C#" implements-prefix="user"> <![CDATA[ public string checkCategory (string category1,string category2) { if( (category1=="Category1_A" && category1==" Category2_B") && ConfigurationManager.AppSetting["Code"].contains("A1")) return true; else return false; } ]]> </msxsl:script> <xsl:template match="master"> <child> <circumference> <xsl:value-of select="user: checkCategory (category1,category2)"/> <!--if method return false then : return Sorry, Combination doesn’t match.”--> </circumference> </child> </xsl:template> </xsl:stylesheet>