Actualice el archivo xml llamando a una función de C # en xslt

Tengo un archivo xml y un archivo xslt en el proyecto de mi sitio web.

archivo xml:

<root>
  <employee>
    <firstname>Kaushal</firstname>
    <lastname>Parik</lastname>
  </employee>
  <employee>
    <firstname>Abhishek</firstname>
    <lastname>Swarnkar</lastname>
  </employee>
</root>

xslt:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:Concat="urn:XslSample">
  <xsl:output method="html" indent="yes"/>
  <xsl:template match="root">
      <xsl:for-each select="employee">
        <![CDATA[Concatenated name is ]]>
            <xsl:value-of select="Concat:GetFullName(firstname,lastname)"/>
            <xsl:value-of select="age"/>
        <br />
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

aspx.cs:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Xml;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            MemoryStream objStream = new MemoryStream();
            StreamWriter objWriter = new StreamWriter(objStream, System.Text.Encoding.UTF8);

            XPathDocument doc = new XPathDocument(Server.MapPath("XMLFile.xml"));
            XslCompiledTransform trans = new XslCompiledTransform();
            trans.Load(Server.MapPath("XSLTFile.xslt"));

            //create the XslArgumentList and new BookUtils object
            XsltArgumentList argList = new XsltArgumentList();

            Concat objUtil = new Concat();

            //this tells the argumentlist about BookUtils
            argList.AddExtensionObject("urn:XslSample", objUtil);

            //new XPathNavigator
            XPathNavigator nav = doc.CreateNavigator();

            //do the transform
            trans.Transform(nav, argList, objWriter);
            //objWriter.Flush();
            objStream.Position = 0;
            StreamReader oReader = new StreamReader(objStream);
            string strResult = oReader.ReadToEnd();
            //objWriter.Close();
            //oReader.Close();
            Response.Write(strResult);
        }
        catch (Exception Ex)
        { Response.Write(Ex.Message); }
    }
}

public class Concat
{
    public Concat()
    { }

    public string GetFullName(string firstname, string lastname)
    { return "Mr." + firstname; }
}

Cuando ejecuto el sitio, necesito llamar a la función ac # desde xslt y alterar los valores en el archivo xml ... Estoy agregando un texto (diga "Sr.") delante de cada nombre de pila a través del código ac # ... Después de agregar, escribe el resultado como una respuesta, pero el xml original no se modifica. Quiero que eso se refleje en el archivo xml ...

salida xml necesaria:

<root>
  <employee>
    <firstname>Mr.Kaushal</firstname>
    <lastname>Parik</lastname>
  </employee>
  <employee>
    <firstname>Mr.Abhishek</firstname>
    <lastname>Swarnkar</lastname>
  </employee>
</root>

Además, como paso siguiente, necesito agregar otro nodo en el archivo xml (digamos age) a través de otra función c # ... Tenga en cuenta que la función c # debe llamarse desde mi archivo xslt ... ¿Puede alguien ayudarme? con un código simple para esto ????

Xml final requerido:

<root>
  <employee>
    <firstname>Mr.Kaushal</firstname>
    <lastname>Parik</lastname>
    <age>34</age>
  </employee>
  <employee>
    <firstname>Mr.Abhishek</firstname>
    <lastname>Swarnkar</lastname>
    <age>30</age>
  </employee>
</root>

Respuestas a la pregunta(2)

Su respuesta a la pregunta