File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XSLT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "XSLT" Watch "XSLT" New topic
Author

XSLT

Trina Thach
Greenhorn

Joined: Jun 12, 2001
Posts: 18
I know that XSLT uses to convert the XML documents to HTML documents. But what I don't understand is: why? why we have to convert them??? why not simply using Dreamweaver or HTML editors to create them. Could someone help please?
Peter Gragert
Ranch Hand

Joined: Jan 16, 2001
Posts: 421
A XML file is 'only' the description (in tree form + ...) of some data.
You have to manipulate to make the content of the XML usable for a WAP-telephone and have to do the same thing a little bit differently for a HTML document.
And I think XSLT is a way to 'program' different sorts of transformation of your 'information tree'. E.g. reordering is too to be programmed (following the rules of your wishes or needs of some application) and can not be done just by an editor.
Imagine you have lots of XML files which should undergo all similar 'transformations'.
I look at XML as follows: It is input uniquely defined, which is 'easily' understood by man and program, a program used to manipulate the data, put it in a form you really want.
I hope I am correct (a bit newbie too ).
Trina Thach
Greenhorn

Joined: Jun 12, 2001
Posts: 18
Thanks for your replying. However, I still am confusing...
The thing is, we can always use the scripts to manipulate the XML docs and output the results with the desire look and feel, selected data and of course much more handly than XSLT - don't you think?.

------------------
T.T
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
It is possible to do the same with script languages, true. But XSLT and languages, like JavaScript, differ in that with script languages you have to specify how the result should be obtained: what operations, in which order... XSLT is so-called functional language: you only specify what you want (in terms of XPath expressions) and processor itself decides how to get the result. Why is it better? Because: 1) you do not need to check if your algorithm is correct � you do not provide any algorithm 2) processor can choose the most effective (optimal) way to get you what you want, again, because it is the processor who choose the algorithm, not you!
Thus, XSLT is one level �higher� than script languages.

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Joseph Rank
Greenhorn

Joined: May 03, 2001
Posts: 7
I agree with Mapraputa's response, but I'd also add a little.
Not only is XSLT good for on-the-fly translation of XML docs, but with it you can *conditionally* include or exclude document fragments, elements, attributes, etc. in your transformed document. That's part of the XSLT language--you don't have to put any logic in your program to check whether to include or exclude some node in your transformed document. XSLT enables sorting, numbering, and wholesale copying. Chaining stylesheets makes it really easy to adapt your processing as data formats evolve.
I just recently discovered XSLT, and am blown away with how useful it's been (I do a lot of order processing for e-commerce). I think it's one of the more readable specs at the W3C, and I only wish I'd known about it (and XPath!) earlier.
Cheers.
------------------

[This message has been edited by Joseph Rank (edited June 20, 2001).]
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 333
When someone suggested you could get the same effect using a scripting language. The whole point of the DOM however, is exactly that: parsing!
The DOM works great with XSLT. You can parse with the DOM and then XLST in Javascript or java quite nicely. This works when you have a task that is too complex for XSLT by itself.
For example: I'm working on specifying the prerequisites and outlines for all the coures I teach. If I specify this in XML, I can use the DOM and XSLT to display the outline as a form (questionair) to find out which topics the candidate client or candidate students are interested in. I can display it as a simple outline. If there are questions under each topic as well, I can use it for pre and post tests as well.

------------------
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
If to speak about an alternative �XSLT vs. DOM programming�, then the only case when XSLT may be less-than-perfect solution is when processing logic is too complex. Huge XSLT stylesheets become unreadable and unmaintainable, even with all <xsl:include> and <xsl:import> tricks. In this case OO languages, such as Java, may be better choice, since they were specially designed to fight complexity. Script languages are not a good choice for complex tasks, IMHO.
Trina Thach
Greenhorn

Joined: Jun 12, 2001
Posts: 18
I've got the message. Thank you all very much.
:-)

------------------
T.T
 
 
subject: XSLT
 
Threads others viewed
HTML to XSLT and vice versa generation
XSL and XSLT
converting HTML to XML
Is Javaranch RSS Enabled?
Installing XSLT processor
IntelliJ Java IDE