XML & XSLT Video Highlights

  • Creating XSL transformation files
  • Adding constructs to XSLT pages
  • Previewing XSLT output
  • Rendering XSLT output on a page
  • Using hierarchical controls with XML

Evaluate Visual Studio

Introduction

Welcome to this product comparison video overview showing the differences between the latest Web design tools available from Microsoft and Macromedia. Namely, Microsoft’s Visual Studio 2005 and Macromedia’s Dreamweaver Version 8. In this video we will examine XML and XSLT. XML offers a fantastic way to store data, and XSLT allows a fine degree of control over the data presentation.

Dreamweaver Section

As you are editing XML in Dreamweaver Version 8, if a DTD or a schema has been included in the document, then the code hints feature is enhanced to list the specific elements and attributes available in that particular part of the document. As well, the Tag Inspector panel allows you to edit available attributes. With an HTML file open, you can reference File / Convert / XSLT, and Dreamweaver will use that HMTL document as a starting point to create a simple XSLT file.

A new feature in Dreamweaver 8 is the inclusion of binding XML through XSLT to any Web page. From the Application panel, going to the Bindings tab, you can get XML schema from a document or URI which can assist as you create an XSLT file. By dragging and dropping the fields from the bindings onto the design surface, simple XSLT code is written. By selecting the XSLT option from the Insert Tool Bar, repeating regions using “foreach” and conditional regions using “if” can easily be included in the XSLT you create. XSLT can be applied to local XML files or XML feeds referenced with a URI. For example, the RSS feed from a blog contains the entire text of each post. To render only a list of summaries and links, this XSLT file can be used.

So far the results of our examples have been shown in a preview window. Another way to use XML in Dreamweaver is to create code that can be used with other server-based technologies such as ASP.NET. While editing an ASPX page, from the Application Panel, select Server Behaviors, and using this plus button, add in an XSL transformation. You can specify an XSLT file and XML URI, and optionally parameters as well. The code that is placed in the ASPX file utilizes a class and the custom Macromedia assembly and causes the server to parse the XSLT.

Visual Studio 2005 Section

When programming with .NET, in addition to having programmatic access to a powerful XML parser, two new ASP.NET server controls in Visual Studio 2005 can directly make use of XSL transformations, or XSLT. The first is the XML control, which allows you to specify an XML document and an XSLT file that will get rendered as part of the page. In this example, a list of grouped items in this XML file will be rendered into a table with a separate column for each group. Looking at this sample XML file, you can see these items are grouped into three sections. If we wanted to display this data in a table format, we could choose to display either each group of data as a row in a table, or as a column in the table. This XSLT file defines a recursive rule to pivot the results into columns. Visual Studio 2005 makes it easy to write these more complex kinds of XSL transformations by providing syntax colorization and Intellisense. Previewing the page, we can the output of our XML data in a table, with each of our groups of data in a single column.

The other new control that works with XML is the XmlDataSource, which works in a similar way to the XML control by reading an XML document or XML from a stream and transforming it with an XSLT file. But instead of directly placing the results in the rendered HTML, it can be bound to a hierarchical control such as the TreeView control. These controls allow you to easily control site navigation aids or a menu. In this example, we’ll use the same XML data file as our first example, and use a new XSLT that will transform the data for use in a TreeView. Here is the XSLT file. Now, using the XML data source Smart Tag, we can define the XML data file and the XSLT file. Then, using the Smart Tag of the TreeView control, we can choose its data source to be the XML data source control that we just defined. Running the page, we see both of our examples – the original table that displays our XML data in columns, and the TreeView, that displays our data in a TreeView control. It’s important to remember that the data for both of these controls is the same XML file. Going back to our XML file, we can add another node to our Menu data. Then returning to the page, we see that simply refreshing the page will redraw our table and TreeView control with the new data.

Conclusion

This concludes our analysis of features to support XML and XSLT in Dreamweaver 8 and Visual Studio 2005.