Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Twice in the last week, and many times before, I have seen a question about XML answered by a short post saying in essence just use an XSLT stylesheet.

This irks me to no end, and, after thinking a bit about it, I thought it deserved a meditation.

My first comment would be: show me the code! Here on Perlmonks we tend to answer questions with Perl code, showing ways to solve the poster's problem. For some reason, invoking XSLT seems to absolve people from doing so. Please, if it is so easy to use XSLT, then show us how. After all most questions here ould be answered with a short "just use Perl" comment. Or "just use assembly language" for what matters. Posting some code would indeed show how easy it would be to use XSLT to solve the problem... or not. XSLT is not an appropriate tools for all XML transformations. It would also educate us about XSLT, and generally be a lot more useful than just waving the magical XSLT wand.

I also have a problem with the word stylesheet. It might be the usual designation for a piece of XSLT, but I think it hides the fact that XSLT is code. XSLT is a programing language and you code in it. Stylesheet is a great word for PHBs to use: it implies that the task is simple, should take very little time, and that the skill level involved is minimal. As programers I think we should consider it a very dangerous word. A long time before XML even existed, there was a language called FOSI, used to format SGML documents. My company used it to format aircraft manual. It was a real tough battle to get the powers that be to admit that writing a proper FOSI stylesheet for a complex manual took about a month. After all it was only a stylesheet. Don't let this happen to you.

Finally, my, admittedly limited, experience with XSLT is that it doesn't offer much that Perl + a good module would: on the plus side it leads to safe, side-effect free code, that is easy to reuse. On the minus it is very verbose, the language gets in the way a lot more than Perl, both syntactically (processing XML with an XML syntax is a sure way to lead to delimiter collision) and semantically (as a drawback of the no-side-effect philosophy) and it lacks the wealth of modules that CPAN offers. Overall the select-with-XPath => transform pattern is very similar in XSLT and in XML::LibXML, XML::XPath or XML::Twig code.

In short, yes coding in XSLT can be an option for XML transformation, but if you want to recommend it, then just prove it!


In reply to Just use an XSLT stylesheet by mirod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found