Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (5)
    As of 2014-12-26 22:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (176 votes), past polls