XSLT as a programming language - is this for real?

D

Derek Fountain

I've been wading through the O'Reilly XSLT book. All seemed OK and sensible
until I got to the "programming" bit - variables, loops, conditions and so
on.

Do people actually use this stuff for real work? I can the advantages of,
say, being able to number pages or something, but surely to do any real
work with this syntax is very difficult?

The concepts don't really intimidate me. I've done a little functional-style
programming, and fully understand how all the examples work. But the syntax
is awful - just about unreadable even for the simple stuff that's in the
book.

I'm wondering if this is an example of computer science gone mad, where
features have been added to the point of idiocy "because we can", or
whether people really use this stuff. Is it really easier - with real world
problems - to write XSLT "scripts" rather than find another way to do it,
using say Perl (or a "conventional" XML-friendly scripting language of your
choice)?
 
D

Derek Fountain

Mariusz said:
I don't think that treating XSLT as next programming
language is good approach.
XSLT is perfect for XML transformation, and there is
hidden its all power. Stuff like variables, loops
are helpful while writing more complex transformation.

Begin to use xslt in practice and you'll see, that it's
a very good solution for XML

Yes, I learnt the basics a year or so back, but changed project and didn't
get to use it much. I'm now having another more detailed look.

I've no doubt that it's a great tool. To be honest, my doubt was whether I
need to learn all that horrible syntax and structure for calling functions,
passing parameters and so on. My inclination was not to bother; just make
myself aware of what might be possible in a pinch and move on.

I note the distinct lack of people screaming "it's invaluable! learn it
thoroughly and immediately!" so I'm currently inclined to go with my
instincts and skim those chapters.
 
M

Mariusz Sieraczkiewicz

I started using XSLT while exploring Cocoon and XML publishing.
It's most innovative set of tools I've met since I began to
write software (4 years ago).
Well designed XML documents and XSLT stylesheets gave me a great
opprtunity to create reusable XML 'components' (sic!)
(I mean XSLT+XML), so that with predesigned patterns for creating
HTML forms for editing, reading, adding or deleting data from DB,
making complex data driven sites is a really pleasant thing.
I really love it, it made me think efficiently.

Regards, Mariusz Sieraczkiewicz
 
A

Andy Fish

If you do any serious XSLT work, sooner or later you will come across a
requirement that will need you to write programming style constructs (find
and replace for more than one character in a string for instance)

now you have two choices, either introduce another stage before or after the
XSL processing, or write that function in XSL. This will depend on how much
programming-style stuff you have to do. sometimes it will turn out better to
bite the bullet and introduce a whole new non-xsl process in the pipeline,
but definitely some of the time you'll find it's easier to code the function
in XSL (or find a fragement on the web) and have the advantages of a purer
system architecture.

Andy
 
A

Andy Dingley

If you do any serious XSLT work, sooner or later you will come across a
requirement that will need you to write programming style constructs (find
and replace for more than one character in a string for instance)

IMHO, that's time for a Javascript extension. XSLT works OK with
nodes, but I don't use it to work within a node (like slicing a single
string)
 
B

Brett Gossage

I've been wading through the O'Reilly XSLT book. All seemed OK and
sensible
until I got to the "programming" bit - variables, loops, conditions and so
on.

Do people actually use this stuff for real work? I can the advantages of,
say, being able to number pages or something, but surely to do any real
work with this syntax is very difficult?
Yes, there exist people who do real work with XSLT.
The concepts don't really intimidate me. I've done a little functional-style
programming, and fully understand how all the examples work. But the syntax
is awful - just about unreadable even for the simple stuff that's in the
book.
Perhaps your perception of XSLT as a functional/procedural language is part
of the problem. XSLT gets its simplicity and power from its *declarative*
constructs. If you recognize it as more akin to expert system languages
like CLIPS, its nature will seem clearer. The procedural loop constructs
are more natural for many, but the declarative, rule-based approach is often
more elegant and easier to maintain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top