About time I started posting something on here really! Here goes, well, its a start anyway.
There are various techniques for transforming XML with XSL. For starters this assume you have an understanding of the basic principles and techniques of XSL - if not - see W3 Schools and for a reference (the holy bible of XSL as it were) see Mulberry Technologies for more information. Its the best source for all things XSL and XPATH.
First, it depends of if the XML is local or external. Ifs local you have a few options, the quickest and easiest way to transform is is to use an ASP XML control on the page, you can then transform and bind the data from design mode or code behind.
[code]
Add XML control to the page and bind at design level:
<asp:Xml ID="xml_Control" runat="server" TransformSource="App_Data/SomeXMLDoc.xml" DocumentSource="XSL/SomeXSLDoc.xsl" />
OR add XMLDoc and XSLDoc from code behind:
<asp:Xml ID="xml_Control" runat="server" />
CODE BEHIND:
me.xml_Control.DocumentSource = "~/App_Data/SomeXML.xml"
me.xml_Control.TransformSource = "~/XSL/SomeXSLDoc.xsl"
me.xml_Control.DataBind()
[/code]
The code above is the quickest way to do this. In DotNet 2.0 they say use their new compiled transform method (which is very useful for assigned the returned data from the XML/XSL transform to a StringBuilder) as inconsistancies in XSL recursion (I'm sure many XSL gurus will know the joy of XSL recursion) can occur - however for everything else the above method works fine.
What about XML Transform Arguments List?
To add an XML arguments list to be used in the XSL you need to add this to the XML control from the code behind. This arguments list are refered to as parameters in your XSL document which you can use as you require (getting a specific node by attribute value, i.e. an ID value).
Another extremely power aspect of DotNet with XML and XSL is being able to pass in an ExtensionObject which allows you to create a namespace in the XSL which you can use to reference methods in a class you have created (such as XSLFunctions etc...)
[code]
Dim xmlArgs As New System.Xml.Xsl.XsltArgumentList
Dim XSL_NS As New XSLFunctions 'a class I have created contained methods/functions
xmlArgs.AddParam("ParamName1", "", "Param1Value")
xmlArgs.AddParam("ParamName2", "", "Param2Value")
So the full code would now be (assuming you are doing this ALL in the code behind):
me.xml_Control.DocumentSource = "~/App_Data/SomeXML.xml"
me.xml_Control.TransformSource = "~/XSL/SomeXSLDoc.xsl"
me.xml_Contro.TransformArgumentList = xmlArgs
me.xml_Control.DataBind()
[/code]
Depending upon how much you use XML/XSL transforms you should really look at a class that contains all the methods to do this for you, returning a simple string/boolean valued error message (or some other object response) to inform the user of whats going on - either display the data or let them know (in a friendly way) that there has been an error - of course DotNet allows you so much control in error handling - but thats a different matter.
NB: always use Try, Catch, Finally & End :)