0
votes

How to get the value of <xsl> element for 'maa' type in below XSL file?

<xsl:stylesheet version="3.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eu="http://europa.eu.int" xmlns:xlink="http://www.w3c.org/1999/xlink"> 
   <xsl:template mode="agency"> 
    <xsl:choose>
        <xsl:when test="@code='AT-BASG'">Austria - BASG- Austrian Federal Office for Safety in Health Care / Austrian Medicines and Medical Devices Agency</xsl:when>
     </xsl:choose>
   </xsl:template>
   <xsl:template mode="submission">
    <xsl:choose>
        <xsl:when test="@type='maa'">Marketing Authorisation</xsl:when>
    </xsl:choose>
   </xsl:template>
</xsl:stylesheet>   

I tried like below:

        string emp = "@type='maa'";
        XmlDocument xslDoc = new XmlDocument();
        xslDoc.Load(IndexFTPLocation);
        //ReadXElement(indexXele, sequenceName, ApplicationName, IndexFTPLocation, 1);
        XmlNamespaceManager nsMgr = new XmlNamespaceManager(xslDoc.NameTable);
        nsMgr.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");
        XmlNode usrNode = xslDoc.SelectSingleNode("/xsl:stylesheet/xsl:template[@mode='submission']/xsl:choose/xsl:when[@test='@type='maa'']", nsMgr);  

But, i'm unable to get "Marketing Authorisation" when type="maa". Can you Please help me to solve this problem?

Thanks in Advance!!

Edit: Getting Error : '/xsl:stylesheet/xsl:template[@mode='submission']/xsl:choose/xsl:when[@test='@type='maa'']' has an invalid token.

1
Please show a minimal reproducible example including an input and expected result.michael.hor257k

1 Answers

1
votes

You could use " instead ' in xsl:when[@test='@type='maa''], like the following code :

XmlDocument xslDoc = new XmlDocument();
xslDoc.Load(IndexFTPLocation);

XmlNamespaceManager nsMgr = new XmlNamespaceManager(xslDoc.NameTable);
nsMgr.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");

XmlNode usrNode = xslDoc.SelectSingleNode("/xsl:stylesheet/xsl:template[@mode='submission']/xsl:choose/xsl:when[@test=\"@type='maa'\"]", nsMgr);
string text = usrNode?.InnerText;

Demo

Console.WriteLine(text);

Result

Marketing Authorisation

I hope you find this helpful.