[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] XSLT Hello World


Subject: Re: [xsl] XSLT Hello World
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxx>
Date: Mon, 24 Mar 2014 16:34:35 -0400

Hi Ihe,

You write:
> It's part of a languages PR that the small subset of the language
> that is exercised most frequently doesn't contain surprises.

Assuming we accept this to be true (as I am willing to do), then the
question in that-other-thread-over-there (not the OP's question, but
one you raised implicitly) might be recast as whether 'text()' is or
should be in the part of the language that is exercised most
frequently.

I don't think it is, or should be, which is part of the reason for
this-thread-here, and I think that developers who think it is are
either mistaken (they would be better off using other means to get the
job done), or they have special reasons and use cases that account for
their different perception (in which case they're mistaken about how
typical their use cases are, and they would benefit from a wider
understanding of where, how and why XSLT is used out here in the big
world).

In particular, in my view, there's no good case for using 'text()'
anywhere in an XSLT Hello World, unless you count where it appears
(once) among the built-in templates, which yes beginners should be
using. This is irrespective of whether the purpose of the Hello World
is to illustrate syntax, or just offer a place to start turning the
crank.

Cheers, Wendell

On Mon, Mar 24, 2014 at 12:53 PM, Ihe Onwuka <ihe.onwuka@xxxxxxxxx> wrote:
> Just want to make sure this is absolutely clear because I think this
> might blur the message I was trying to convey.
>
> What Wendell has quoted is what I would do if my objective was to do a
> hatchet job on XSLT to people not familiar with it. It's part of a
> languages PR that the small subset of the language that is exercised
> most frequently doesn't contain surprises. If it does it will either
> turn people away from your language (price of admission too high for
> them)  and/or those with an antagonistic agenda to the language will
> leverage that to achieve their aim.
>
> People also try to disparage Java and portray it as verbose and
> cumbersome by showing how much palaver it is to write Hello World
>
> e.g from http://programmers.stackexchange.com/questions/141175/why-is-verbosity-bad-for-a-programming-language
>
> class HelloWorldApp {
>     public static void main(String[] args) {
>         System.out.println("Hello World!");
>     }
> }
>
> ... with Ruby's:
>
> puts 'Hello World!'
>
> unfortunately they were unsuccessful.
>
> On Mon, Mar 24, 2014 at 4:05 PM, Wendell Piez <wapiez@xxxxxxxxxxxxxxx> wrote:
>> Hi,
>>
>> Over in that other thread, Ihe said:
>>
>>> Extracting text from an XML document is the hello world of XSLT.
>>> text() would appear to be an obvious way of doing that and it's really
>>> important that it entails no surprises. If I were an XSLT antagonist
>>> that is exactly the sort of thing I would  home in on to portray the
>>> language as arcane, difficult to use and not suitable for my project.
>>
>> I find this really quite interesting.
>>
>> One thing I stress to beginners is that if they're starting to learn
>> the language using only a syntax reference plus whatever they might
>> know about Perl, Python or Java, they are heading for a world of hurt.
>>
>> It's not like your granddaddy's programming language, and when you
>> assume things like "text() is the way to get my data into the output,
>> because it says 'text'" ... ouch.
>>
>> Indeed, the Hello World I like to use looks like this:
>>
>> <xsl:stylesheet version="2.0"
>>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>
>> </xsl:stylesheet>
>>
>> I.e., a stylesheet with no templates at all. (You can also write it as
>> an empty element if you prefer.)
>>
>> After having acknowledged our astonishment at the results of running
>> this, we can talk about the built-in templates. And then we start
>> writing templates of our own ... matching elements, not text nodes. We
>> do this with a source document with mixed content (such as <doc>Hello
>> <who>World</who></doc> ), (so we can try a few things out such as
>> matching elements in line), and then a slightly more elaborate
>> instance (perhaps including some comments or processing instructions
>> so we can illustrate aspects of the data model, such as text nodes) .
>>
>> Take in a few points of fact, practice for an hour or two, and get a
>> good night's sleep, and you no longer run the risk that you will be
>> surprised by 'text()' in XSLT.
>>
>> Talking about the processing model in the context of documents with
>> mixed content also gives us an early opportunity to start thinking
>> about XSLT's purposes, strengths and weaknesses.
>>
>> I know this approach may reinforce the impressions of some programmers
>> that XSLT is, as Ihe says, "arcane, difficult to use and not suitable
>> for my project". To this my only answer is in the doing of it.
>> Assuming your problem is in fact in XSLT's sweet spot, showing how
>> powerful and easy XSLT is ... once you have a clue ... answers the
>> critique by itself.
>>
>> If your problem isn't in XSLT's sweet spot, I ask why are you
>> interested in it. Yes, XSLT is generally very powerful, and can be
>> used for problems often quite different from the kinds of document
>> processing for which it was designed. But please please don't expect
>> an easy time trying to tackle one of those in XSLT before you have a
>> feel for templates and traversals.
>>
>> The thing about "arcane" is also relative. Indeed, if you aren't
>> naturally a curious sort with a reasonable tolerance for the arcane,
>> one wonders why you expect to do well with programming at all.
>>
>> Cheers, Wendell
>>
>>
>> --
>> Wendell Piez | http://www.wendellpiez.com
>> XML | XSLT | electronic publishing
>> Eat Your Vegetables
>> _____oo_________o_o___ooooo____ooooooo_^
>



-- 
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^


Current Thread
Keywords