[xsl] Controlling process flow in a stylesheet?

Subject: [xsl] Controlling process flow in a stylesheet?
From: "dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Aug 2014 15:58:16 -0000
Most of the time I can let the stylesheet just react to elements found and
trigger a given template and that works great.

There are other times where I have content that has variable sections (my
or may not be there) but I need to add information in that section or
create a new one.

I'm looking for a generic foolproof way to process content like this. The
content/DTD is complex enough that there might be many optional elements
defined but never really used by our writing group. My problem is that in
sampling the content to be processed I may not find the one or two uses of
an optional section.

So what I've been doing in situations like this is review the some of the
content and the DTD and determine which sections I need to worry about.
this works as long as I have an accurate sample of the content or I have
analyzed all the possible structure possibilities. So not only are some
sections optional but they might repeat in various combinations.

So what techniques do you use to handle a situation like this? My hard
coded structuring only works in the less complicated situations, is there
a better way?

One thought might be to have the template that treats the content
immediately following the section I want to touch test to see if there was
a section output. I might be able to write a generic template that
processes all elements and have it check to see if there was one of these
sections in the input, if not output one. I'd then have to keep track of
the fact I've created the section, a tunnel parameter might handle the
tracking. I'm not sure what sort of overhead that might put on the overall
processing time.

.dan

Current Thread