Xslt Transformations and Xslt Intellesense within the .NET IDE
With xml and xslt transformations becoming alarge part of many business applications it would be benificial to havethis functionality in the .NET IDE. Following are the instructions foradding xslt transformations and intellesense to xslt documents to the.NET IDE.
This additional functionalityis achieved by implementing a macro written in VB.NET and a schema thatdepicts the hierachical relationship of the xslt syntax. The firstsection gives instructions on how to load the macro into a demo projectand transform some sample xslt against a sample xml file. The secondsection gives detailed instructions on what to do with the included xsdfile to get intellesense when working with xslt documents.
About the zip file:
Download dotnetxslt.zip
The zip file included with this article contains a series of files thatgive the IDE its new functionality. The xsltfunctions.vsmacro file isthe macro we will discuss first and the rest of the files are for thesecond part of the article.
Part 1 Loading and Using the Macro
1. Creating a demo project.

Open the .NET IDE and select a console application with the name of MyXsltSample.
For simplicity we will use a console application to demonstrate thisnew functionality, however you could use any type of project youdesire.

2. Navigate to the Tools`Macros`Load MacroProject menu item as shown above and open the macro project included inthe zip file called XsltFunctions.

3. You should now see a macro project in yourmacro explorer named XsltFunctions as shown above with a child nodenamed xsltTransform. The macro is now ready to run by double clickingthe xsltTransform node, however we must add an xslt file to the projectso we have something to transform.

4. Navigate to the .NET solution explorer andright click on the project to get the menu shown above and select AddExisting Item. Next select the xslt file included in the zip file namedsampleXslt.xslt this will add the file to the current project.

5. Finally, navigate to the Macro Exploreragain (as shown above) and double click on the XslTransform node thiswill bring up a file dialog box. You need to select an xml sourcedocument for the transformation, for this demo navigate to the includedfile named sample.xml and click open. If all went well you should nowsee a new window in the IDE with the newly transformed xml document.
Part 2 Adding xslt Intellesense to the .NET IDE.
Now that we know we can transform xsltdocuments inside the .NET IDE it would be nice to get intellesense whenworking with xslt documents.
The schema required to achieve thisfunctionality was originally developed by the people athttp://www.fesersoft.com/dotNet/ and more information can be foundthere in regards to this functionality.
The zip file is outlined at the top of thisarticle please refer to that section for a description of which filesrelate to part one of the article and which files relate to part two.The following steps outlined come directly from the ReadMe.txt file inthis directory.
1.Locate your Microsoft Visual Studio.Netinstallation folder. (The default location is Program Files\MicrosoftVisual Studio .NET)
2.Place the XSD files in the Common7\Packages\schemas\xml directory.
3.The following step is optional, the only difference is for people whoprefer the xslt template to contain the xsl: prefixes, you will need tomodify the xslt files that ship with VS.NET.
4.Place the xslt file in the Common7\IDE\NewFileItems directory. Thiswill also fix the existing stylesheet (it was missing the xsl prefix).A backup has been provided with the zip file.
5.You may also have to go find two other locations that the xslt file may be placed:
a.If you have VB.NET installed, you will need to also replace the xsltfile in the Vb7\VBWizards\XSLTFile\Templates\xxxx folder. xxxx beingany numbered folder, 1033 is the us folder and so on. If you havemultiple folders, you will need to replace the item in each of thosefolders.
b.If you have C# installed, you will need to also replace the xslt file in the VC#\CSharpProjectItems folder.
Now when you add an xslt file to a project aswe did in the beginning of this article and you begin to type your xsltstatements you will see intellesense drop downs appear as shown below.

In summary the .NET IDE is veryextendable via macros and schemas if you use them to their fullestpotential. This article was intended to demonstrate how easy it is toadd needed functionality like xslt transformations to the .NET IDE. Alogical next step would be to make the macro into an add-in to allowfor added features like enhanced UI for a better user experience.
Doug Doedens is a senior software consultantliving in San Diego specializing in .NET, Visual Basic 6, Java, andenterprise development. Doug can be reached at ddoedens@hotmail.com




15. Jan, 2007 by 







No comments yet... Be the first to leave a reply!