Re: [xsl] XSLT Hello World

Subject: Re: [xsl] XSLT Hello World
From: Liam R E Quin <liam@xxxxxx>
Date: Mon, 24 Mar 2014 17:54:55 -0400
On Mon, 2014-03-24 at 12:05 -0400, Wendell Piez wrote:
> 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.

It's a common assumption - I encounter people on pretty much a daily
basis who use text() thinking it gets the "text contents" of an element.

Someone today asked,
   Would this text() function return all the text of the document or
just with in the inside?
             dl/dt[contains(text(),' Information')]

The difficulties are (1) it looks like a function, and (2) the name of
it, especially to people who have encountered DOM but also to others, is
strongly suggestive of "it gets the text", i.e. the string value.

The use of text(), like the use of xsl:value-of, is a warning sign that
the person writing the expression might have been confused.

But overall XPath isn't the sort of language where you can just guess at
stuff and have it come out right. It shares this with many other
functional and declarative languages. In PHP you can just copy/paste
fragments of code without understanding them, and people do the same
with JavaScript.

Similarly XSLT; someone familiar with procedural programming might come
to XSLT and say, "when I see the Poem start tag I want to put out a
<div> tag, and when I see the Poem end tag I want a </p> tag"

This is because they do not yet have the X-Fu. They are quite correct in
describing what they want, one must imagine, but they are looking at
their problem in a way that's not compatible with XSLT. So they need
some new insights, and perhaps should attend one of Wendell's
courses :-)


Liam Quin - XML Activity Lead, W3C,
Pictures from old books:
Ankh: freenode/#xml

Current Thread