4. Introducing XSLT
How would you perform the above conversion, taking an article in your "mini"
XML language and turning it into HTML?
The essential question is: How do you transform one set of XML tags and
content to another set of XML tags and content?
One way to do that would be to write your own XML parser, and do the
appropriate conversion of the tags and content. There are various
pros and cons to this method, but the big con I want to focus on
here is that this method requires that you know how to write code.
XSLT provides a way to perform XML->XML conversion without having
to write your own XML parser, making it more accessible for
non-programmers. For programmers, XSLT saves you from having
to write
yet another special-purpose XML parser (think
of XSLT as somewhat like
lex and
yacc of the XML world -
why write your own if you don't have to?).
Ironically, the
XSLT
reference at
the
W3C is (in my opinion)
the most technically complicated of the other major references in this
area (
HTML,
CSS,
XML), which I think would tend to scare away a lot
of people that otherwise could make good use of it. Of course, the W3C
documents are
specifications, not manuals, but sometimes they
aren't the easiest source to learn from.
One of my motivations in writing these articles is to help others
get started by showing easy ways to do basic things, and
slowly adding complexity over time.