Click here to Skip to main content
Click here to Skip to main content

XSLT Transformations and XSLT Intellisense within the .NET IDE

, 28 Jan 2003
Rate this:
Please Sign up or sign in to vote.
Demonstrates the implementation of XSLT Intellisense in Visual Studio .NET using macros

Introduction

With XML and XSLT transformations becoming a large part of many business applications it would be beneficial to have this functionality in the Visual Studio .NET IDE. Following are the instructions for adding XSLT transformations and Intellisense to XSLT documents to the Visual Studio .NET IDE.

This additional functionality is achieved by implementing a macro written in VB.NET and a schema that depicts the hierarchical relationship of the XSLT syntax. The first section gives instructions on how to load the macro into a demo project and transform some sample XSLT against a sample xml file. The second section gives detailed instructions on what to do with the included xsd file to get intellisense when working with XSLT documents.

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 this new functionality, however you could use any type of project you desire.

  2. Navigate to the Tools->Macros->Load Macro Project menu item as shown above and open the macro project included in the zip file called XsltFunctions.

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

  4. Navigate to the .NET solution explorer and right click on the project to get the menu shown above and select Add Existing Item. Next select the XSLT file included in the zip file named sampleXslt.xslt this will add the file to the current project.

  5. Finally, navigate to the Macro Explorer again (as shown above) and double click on the XslTransform node this will bring up a file dialog box. You need to select an xml source document for the transformation, for this demo navigate to the included file named sample.xml and click open. If all went well you should now see a new window in the IDE with the newly transformed xml document.

Adding xslt Intellisense to Visual Studio .NET

Now that we know we can transform XSLT documents inside the Visual Studio .NET IDE it would be nice to get Intellisense when working with XSLT documents.

The schema required to achieve this functionality was originally developed by the people at http://www.fesersoft.com/dotNet/ and more information can be found there in regards to this functionality.

The zip file is outlined at the top of this article please refer to that section for a description of which files relate to part one of the article and which files relate to part two. The following steps outlined come directly from the ReadMe.txt file in this directory.

  1. Locate your Microsoft Visual Studio .NET installation folder. (The default location is Program Files\Microsoft Visual 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 who prefer the XSLT template to contain the xsl: prefixes, you will need to modify the XSLT files that ship with Visual Studio .NET.
  4. Place the XSLT file in the Common7\IDE\NewFileItems directory. This will 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:
    1. If you have VB.NET installed, you will need to also replace the XSLT file in the Vb7\VBWizards\XSLTFile\Templates\xxxx folder. xxxx being any numbered folder, 1033 is the us folder and so on. If you have multiple folders, you will need to replace the item in each of those folders.
    2. 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 as we did in the beginning of this article and you begin to type your XSLT statements you will see Intellisense drop downs appear as shown below:

Conclusion

In summary the Visual Studio .NET IDE is very extendable via macros and schemas if you use them to their fullest potential. This article was intended to demonstrate how easy it is to add needed functionality like XSLT transformations to the Visual Studio .NET IDE. A logical next step would be to make the macro into an add-in to allow for added features like enhanced UI for a better user experience.

History

  • First revision - 28th January, 2003.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Doug Doedens

United States United States
Doug Doedens is a senior software architect specializing in consulting on enterprise applications and is living in San Diego.

Comments and Discussions

 
GeneralThe W3C and XML PineditorHeath Stewart19-Feb-03 2:12 
GeneralRe: The W3C and XML PinmemberDoug Doedens19-Feb-03 9:19 
GeneralRe: The W3C and XML PineditorHeath Stewart19-Feb-03 10:25 
GeneralVery useful PinmemberDmitriyZ4-Feb-03 3:33 
GeneralRe: Very useful PinmemberAnna-Jayne Metcalfe4-Feb-03 4:00 
GeneralRe: Very useful PinmemberLoki3-Apr-03 18:17 
GeneralRe: Very useful PinmemberAnna-Jayne Metcalfe3-Apr-03 19:22 
Generalawesome stuff Pinmember.S.Rod.28-Jan-03 19:00 
GeneralRe: awesome stuff PinmemberPaul Selormey28-Jan-03 20:48 
GeneralRe: awesome stuff Pinmember.S.Rod.28-Jan-03 21:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 29 Jan 2003
Article Copyright 2003 by Doug Doedens
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid