Re: [xsl] When to use conditional constructions?

Subject: Re: [xsl] When to use conditional constructions?
From: Graydon <graydon@xxxxxxxxx>
Date: Mon, 31 Mar 2014 23:22:51 -0400
On Mon, Mar 31, 2014 at 07:33:42PM +0200, Abel Braaksma (Exselt) scripsit:
> On 31-3-2014 18:32, Graydon wrote:
> > <xsl:template
> > match="section[heading][body/table][body/para[following-sibling:table]][not(body/para[preceding-sibling:table])]">....</xsl:template>
> >
> > <xsl:template
> > match="section[heading][body/table][body/para[following-sibling:table]][body/para[preceding-sibling:table]]">....</xsl:template>
> >
> > <xsl:template
> > match="section[heading][body/table][not(body/para)]]">....</xsl:template>
> Just a suggestion, but wouldn't this become more readable if you split
> it using templates? Something like the following (not tested):

It sure would.

What I'm doing at the moment is trying to think of ways to suffer less
if I ever have to do that again, and one of the problems was false
expectations that there weren't very many odd cases, so that combining
the regularization and conversion steps was a sensible thing to do.

(There were, inevitably, a whole lot of special cases, and multiple
programmers working on different sets of input with the same code base,
and it got very awkward.)

I am now of the strong belief that you *never* do that, that if you need
to regularize the input so all the sections have the same structure, you
do that, and then you feed that result into the conversion step.  (and
you might just give up and have the regularization done by people, to
avoid nasty issues of meaning.)

I am certainly taking away that I really missed an opportunity with
functions as tests, and will be remembering that for next time.

-- Graydon

Current Thread