Transform XML Visually
Posted January 12, 2004
Visual XSLT 2.0 is a multifunctional add-in to VS.NET for developing XML transformations and XPath queries. It integrates so well into the VS.NET environment that it's hard to tell where ActiveState's features start and Microsoft's leave off. After installation, a new Visual XSLT project type becomes available, and several new menu items appear, including XPath Workshop, Schema Mapper, and Template Matches. You can launch other features, such as the Visual XSLT debugger and output view, from existing IDE menus.
This tool can save you hours of the reference-lookup, development, and debugging time you'd spend performing some XML transformations by hand. Visual XSLT pops up lists of valid tag names, attributes, and values as you type, similar to VS.NET's code editor. You can type </ to close any element, and the appropriate end tag appears. You can locate a matching end tag by positioning your cursor (using the keyboard) before the opening < to show the closing > in bold. You can change the syntax-highlight colors to whatever scheme suits you. Some of these features aren't switched on by default in the IDE, but the Visual XSLT tutorial shows how to enable them.
The Schema Mapper starts a transformation by inferring the schema, based on your "before" and "after" sample XML content (see Figure 1). For example, if you want to move several element nodes in the source to attributes in the resulting file, you point the Schema Mapper to samples, drag the elements from the existing schema, and drop them onto attributes in the new schema. This saves lots of time and is easy to use, although moving and deleting mappings is tricky until you learn where to position the mouse on the design screen.
You can use VS.NET's Start Without Debugging feature to build transformations. If the output isn't right, you can put a breakpoint into the XSLT page and step through its code with the debuggerexactly as you would do with a .NET-supported language.
Another component, XPath Workshop, is a highly capable and interactive query designer. You can use it to drill down into your XML file, select a node, and let the tool formulate an expression that retrieves the value from the node. Or, you can try out expressions by entering them in the textbox to see the resulting node set.
Visual XSLT 2.0 is an excellent XSL package that works smoothly inside VS.NET. Unfortunately, its accompanying documentation needs an overhaul. The presentation appears unpolished because of its unnumbered procedural steps, cluttered layout, distracting "Things to Note" entries, and excessive copyright notices. ActiveState should provide quality, context-sensitive help that meshes seamlessly with Microsoft's user-assistance format.
About the Author
Ken Cox is a VB.NET developer in Toronto building e-commerce Web applications and XML Web services. Ken is a former broadcast journalist and a Microsoft MVP for ASP.NET. Reach him at firstname.lastname@example.org.
Visual XSLT 2.0
Quick Facts: VS.NET add-in for visual design and debugging of XML transformations and for creating XPath queries.
Pros: Well-designed, interactive, and integrated tools; easy to use; many time-saving features.
Cons: Documentation is unpolished and cluttered.
Back to top