- <Step XPos=600 YPos=1100 AcquireUnit=true>
- <Step XPos=600 YPos=600 AcquireUnit=true>
FIGURE 1: XML READER
This tool takes the raw XML and translates it into an easy-to-read table.
Introduction to XSLT
I recently overheard the following conversation between two automation engineers:
"They want to review the recipes."
"How do they want them?"
"Can you print them out?"
"That'll take a few days."
"Can you export them?"
"I can save them as XML."
"What do I do with that?"
"I don't know."
I'm not sure how this problem was resolved because I couldn't stick around to help them out. Had either of them known about XSLT, they could have transformed those XML recipes into any number of formats. The easiest of these would have been a CSV that could be opened in Excel. Another option (my favorite) would be to transform the recipes into MS Visio drawings. Either of these two tasks could have been accomplished in a few short hours and it would have worked on all 1,500 recipes.
XSLT is a standard for converting XML to something else. The something else is growing rapidly. Most frequently, the something else is XML in a different data structure. This article opened with a problem whose solution was to convert one XML file (with bad code) to another XML file (with good code). Other common formats created by XSLT include HTML and plain text. One of the most popular formats our company creates with XSLT is MS Word documents. Microsoft supports XML as a format for most or all of its Office 2003 applications.
In this series, I also will introduce XSLT as a declarative language. I will describe the transformation process and explain some of the basic XSLT programming elements. The article will also discuss XSLT expressions, match patterns, recursion, templates, default templates, XSLT processors, scripting, and some of the limitations of XSLT. Finally, I'll point you to a number of resources and applications to help you learn more about XSLT and to get up the XSLT learning curve.
Putting It All Together
Learning a new language is not a trivial undertaking. There needs to be a big pay-off if you're going to spend the time to learn new data structures and languages. Rarely has a new language made your life better. This one will.
The final article will provide real world examples of what can be accomplished with XML and XSLT. I'll make sure to point out obstacles that commonly arise and how to over come these. I'll provide XML samples from real automation systems and accomplish tasks that have practical use in the everyday life of an automation engineer.
I hope that once we've finished this series you'll be well armed and ready apply these concepts to your everyday tasks.
|About the Author|
John T. Sever is president and founder of Cascade Controls Inc. Sever has more than 20 years of experience as a process and automation engineer and can be reached at 708/802-6000 or at email@example.com.