BYTE.com
RSS feed

Newsletter
Free E-mail Newsletter from BYTE.com
Email Address
First Name
Last Name




 
    
             
BYTE.com > Tangled in the Threads > 2002 > April

XSLT Explorations

By Jon Udell

April 1, 2002

(XSLT Explorations :  Page 1 of 1 )



The Protean Power of Textual Transformation

When I started developing for the Web, I was astonished to see how easily I could conjure applications seemingly out of thin air, by transforming patterns of text into other patterns of text. I'm still amazed by this phenomenon, though perhaps it shouldn't be so surprising. Life itself springs from a textual data structure (DNA), which transformative processes turn into other textual data structures (proteins). A programming language designed expressly to transform structured text is therefore, by definition, a really powerful tool. So despite my reservations about Extensible Stylesheet Transformations (XSLT), which to my mind awkwardly straddles the worlds of procedural and declarative programming, I find myself using it more and more often for things I used to do in parser-equipped scripting languages such as Perl or Python.

In his End Tag column for XML Magazine, Adam Bosworth — former Microsoft XML evangelist and now BEA Systems' VP of Engineering — called for a post-XSLT solution:

We need a language that can natively support XML as a data type and yet can gracefully integrate with the world of objects (Java or otherwise) and can take advantage of the self-describing nature of XML by supporting querying of its own variables. This language as used by humans will look like a programming language, not an XML grammar.

This sounds good to me. But I lack the imagination to see clearly what that language should be. If it's going to exist, we'll have to bootstrap our way into it. Using XSLT for all it's worth is probably the best way to do that. In that spirit, here are some things I've done lately with XSLT, and some reflections on doing them.

The Muench Method Is the Schwartzian Transform of XSLT

I recently had to transform a dataset like this:

<recordset>
<record>
  <id>153</id>
  <label>USA</label>
</record>
<record>
  <id>155</id>
  <label>USA
</label>
</record>
<record>
  <id>156</id>
  <label>VENEZUELA</label>
</record>
</recordset>

Into this result:

USA        2
VENEZUELA  1

Here is the XSLT solution:

<?xml version="1.0
	


 Page 1 of 1 


BYTE.com > Tangled in the Threads > 2002 > April
Dr. Dobb's Media Center
BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE: Volume 2 - Heuristic Algorithms
The Best of BYTE: Volume 2 - Heuristic Algorithms
In this volume of Best of BYTE, we explore the emergence of some heuristic algorithms. Although we have only scratched the surface of this intriguing subject, we hope we've suggested the potential of the synthesis of heuristics and algorithms.

© 2008 Think Services, Privacy Policy, Terms of Service, United Business Media Limited
Site comments: webmaster@byte.com
Web Sites: BYTE.com, dotnetjunkies.com, Dr. Dobb's Journal, SD Expo, Sys Admin, sqljunkies.com, Unixreview



MarketPlace
Try Numara FootPrints 9, The ITSM software that Delivers Real Value, Flexibility and Results.
Sign Up & Get Full Access To The Definitive Online Book Collection With SkillSoft's Books24x7�.
Fast online exception analysis. Capture customer crash data online.
One Stop to Buy All Your Business IT Solutions. Browse Through Dell's Best Deals Online Now!
Understand C/C++ code in less time. A new team member ? Inherited legacy code ? Get up to speed faster with Crystal Flow for C/C++. Code-formatting improves readability. Flowcharts are integrated with code browser. Export flowcharts to Visio.
Wanna see your ad here?
 

web2