Why use XSLT?

A

arfinmail

When I read about XSLT for the first time I thought it was a cool toy,
but then I asked myself why use XSLT over ASP?

Can someone give a real world example where XSLT would be the best
choice and why?
 
M

Martin Honnen

When I read about XSLT for the first time I thought it was a cool toy,
but then I asked myself why use XSLT over ASP?

I don't see that as using XSLT instead of ASP, rather you can use XSLT
within ASP (or PHP or JSP) as a nice tool to transform XML to HTML or
text or XML.
 
D

David Carlisle

When I read about XSLT for the first time I thought it was a cool toy,
but then I asked myself why use XSLT over ASP?

XSLT is a transformation language typically but not always from one xml
vocabulary to another xml vocabulary or html.

ASP is a framework for server side programming of content for a web
server.

So these aren't really comparable. people do all sorts of programming
called from an ASP page, including running XSLT if that is appropriate.
Can someone give a real world example where XSLT would be the best
choice and why?

If you had to convert (any) XML document into html I think it
would almost always be preferable to use XSLT rather than one of the
languages more commonly called from asp eg vbscript or javascript.
But choice of language is more to do with personal prefernce than
anything else.

If you were not using XSLT, how would _you_ get from

http://www.w3.org/TR/1999/REC-xslt-19991116.xml
to
http://www.w3.org/TR/1999/REC-xslt-19991116

for example?

David
 
A

Arfin

But since you can do the transformation with ASP/PHP/JSP with the same
effort, why use XSLT?

So far I think it's one of those things to have "stashed" just in case
you need it one day...
 
D

David Carlisle

But since you can do the transformation with ASP/PHP/JSP with the same
effort, why use XSLT?

Again ASP is just a calling convention. If you are going to transform an
XML file to something most people will find it _much_ easier to use a
programming language that's designed to do transformations than one that
isn't. If you are more familiar with **P and want to program the
the transfomration directly in some low level code that walks over a DOM
or some such structure than fine no one is stopping you doing that but
(apart from unfamiliarity with the language) it would almost certainly
be much easier and more maintainable in XSLT. An awful lot of XSLT
processing is totally unconnected with web server programming, so your
repeated comparison to **P seems rather strange.

So far I think it's one of those things to have "stashed" just in case
you need it one day...

I'm sure it is true that the vast majority of the world's population
will quite happily survive without ever needing to use XSLT, so that may
be stashed for a long time.


David
 
P

Peter Flynn

When I read about XSLT for the first time I thought it was a cool toy,
but then I asked myself why use XSLT over ASP?

Can someone give a real world example where XSLT would be the best
choice and why?

a) XSLT is specifically designed to transform XML. It's the right tool
for the job (assuming transforming XML is what you want to do). ASP,
PHP, and JSP know nothing about XML (they have hooks into it, but that
isn't the same thing at all).

b) ASP is Microsoft-specific. There *is* a version for Linux, but it
requires you to use a vendor-supplied custom precompiled binary
of Apache, which no server operator in their right mind would do.
Seeing that most web servers run Linux nowadays, ASP looks like a
rather poor recommendation.

c) ASP is a scripting language for web serving. XSLT has nothing to do
with web serving, so comparing them is probably misleading anyway.

d) I have used ASP, PHP, and JSP to serve pages where the transformation
was done using XSLT, so they are actually complementary.

///Peter
 
G

Guest

But since you can do the transformation with ASP/PHP/JSP with the same
effort, why use XSLT?

Same effort? Some people might find XSLT easier, (well, for more complex
XML docs anyway)
So far I think it's one of those things to have "stashed" just in case
you need it one day...

XSLT can come in handy if you wanted to write a general purpose application
to transform XML to a native format, for example, suppose your application
expects

<plant>
<fruit type="apple" />
</plant>

But someone hands you a:

<menu>
<item type="fruit" name="apple" />
</menu>

Your application could accept as a parameter, a stylesheet to transform the input
document to something you can understand.

Another reason to use it is because it's "standard", if you were a consumer of
a web application and wanted to transform the XML to something else, XSLT is
a standard sort of wedge, they don't need to know PHP or ASP. (or perhaps
as may be the case with java, you don't want them to have the source)

I myself don't use XSLT very often.

Jamie
 

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,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top