xsl-list
[Top] [All Lists]

RE: Clearing up XSL-speak

2003-12-12 10:18:27
-----Original Message-----
From: JCS

SELECT VS. FIND

<snip />
I submit it's better to use select as it's what the syntax is but
one could
describe it as a find, or a query, that uses the syntax "select".


This one is particularly interesting... Compares better with SQL, it
definitely makes sense (to me) to draw this comparison :

<xsl:apply-templates select="foo" />

...

<xsl:template match="foo">
  <!-- do stuff -->
</xsl:template>

This combination means something like (drastically simplified):

SELECT f(foo) FROM sourcedoc WHERE foo=...;

Helps to explain the impossibility to create real-time loops like in
imperative programming languages. In SQL you define the main condition(s) in
the WHERE-clause. Once a record/node satisfies these criteria, it will end
up in the resultset. You can use an if(when;true;false)-expression (--or
decode(val1;val2;val1=val2;val3;val1=val3...;default) for Oracle PL/SQL) in
the SELECT to create subdivisions in the selected data, however these
expressions cannot be used to filter out any more records. It's kind of
analogous to the 'select' in xsl:apply-templates/xsl:for-each.

You _can_ use an xsl:if/xsl:choose inside a template/for-each, but if you
find yourself writing a lot of empty xsl:otherwise's, you need to consider
the possibility of filtering out the nodes beforehand, using XPath, or, if
they're not empty, just write a different template (or a different mode of
the same template).


--
Hating somebody is like burning down a house to get rid of a rat.
-- unknown


A very good one, indeed! :)

Cheers,

Andreas


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list