O'Reilly logo

Dreamweaver 8: The Missing Manual by David Sawyer McFarland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Advanced XSLT Tricks

XSLT is a complex language with lots of bell and whistles—and just as many pitfalls. It's all too easy to head ambitiously into Code view and, with just a few keystrokes, completely break your XSLT style sheet. But since Dreamweaver's XSLT tools take you only so far, you'll undoubtedly find yourself wanting to dip into the code. Here are a couple of examples to help your explorations go a little more smoothly.

Sorting Data in a Repeat Region

The Repeat Region feature normally works by spitting out data that it retrieves from an XML document in the order it appears in the XML file. But what if you want that information sorted in a particular way—employees listed in alphabetical order, for example. Dreamweaver doesn't have a visual tool to let you accomplish this common goal. Fortunately, adding the code yourself is pretty easy:

  1. Click inside a repeat region and then click the "Code" or "Split" buttons in the document window's toolbar.

    Alternatively you can choose View Code or View Code and Design. Doing so drops you into the scary world of XSLT code; don't look too hard—you might go blind.

  2. Locate the beginning of the repeat region.

    What you're looking for is something like this: <xsl:for-each select="company-Info/employeeList/employee">, where the stuff in quotes after "select" is the XPath expression pointing to the repeating tag. You need to add your new code directly after this tag.

  3. Click immediately after the closing bracket (>), hit Enter, and then type ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required