I have a xml schema that contains information that I would like to use to dynamically create input forms in asp.net (c#). Is it possible to dynamic create controls in asp.net by transforming the schema with an xslt stylesheet?
I would like to read a schema into an XmlDocument object (C#) and transform it with an XSLT stylesheet creating ASP.NET controls on the server and use the add method to add the controls to the place holder control. Code below:
XPathDocument xdoc = new XPathDocument(Server.MapPath("Address.xml"));
XslCompiledTransform tr = new XslCompiledTransform();
tr.Load(Server.MapPath("Controls.xslt"));
StringWriter sw = new StringWriter();
tr.Transform(xdoc, xslArg, sw);
string result = sw.ToString();
Control ctrl = Page.ParseControl(result);
phEmployeeAddress.Controls.Add(ctrl);
Instead of the Address.xml
I would be reading a XML schema like so:
Stream strm = Client.OpenRead("DataTypes.xsd");
StreamReader sr = new StreamReader(strm);
//Read the Response Stream using XmlTextReader XmlTextReader
XMLreader = new XmlTextReader(sr);
... apply the transform to the XST and add the controls to the place holder control.