Re: [xsl] Combining XSL's

Subject: Re: [xsl] Combining XSL's
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 12 Aug 2011 19:31:25 -0400
Mark,

Goodness, there are lots of ways to do this; but it's going to be tricky
as long as everything is a big pull.

For example (only one obvious way I can think of) a set of stylesheets
calling the same modules can each process the nodes in a different
order, calling the same set of templates to do so only changing the
order of their calls.

Or one stylesheet, with a parameterized conditional to determine which
order is used.

Or a stylesheet that processes a driver XML, which you or your users modify to configure what outputs appear where. (This is most flexible and versatile, maybe too much so.)

Your HTML infrastructure (the 'head' element, 'body' element and so
forth) can be generated by a single template in a module that is always
used.

Please don't consider using disable-output-escaping for that: it's
neither necessary nor wise! The way you "split the open and close tags" here (which is a poor way of conceptualizing what is happening) is to emit the entire html, head and body elements from the correct template(s), then apply templates from inside them. (See?)


Instead, start by refactoring your code into templates, and then see if
that by itself doesn't give you some ideas. (Or pick a method I've
suggested and ask again.)

Cheers,
Wendell

On 8/12/2011 6:01 PM, Mark Anderson wrote:
Hi All

I'm trying to take a very large XSL with multiple sections and split
it into several smaller xsl's that can be combined in any order. Its
transforming XML to HTML for job ticket. Because of the nature of the
doc it uses pull processing: basically and HTML page with lots of
xsl:value-of, etc.

The full XSL has

Header Sect 1 Sect 2 Sect 3 Sect 4 Footer

Some user want to see Header Sect1 Sect2 Footer

Others Want to see Header Sect4 Footer

Etc.

Essentially each section is a fragment of HTML with xsl processing
instructions.

Sect 4, for example, may be raw materials:

<table> <xsl:for-each select="material"> <tr> <td><xsl-value-of
select="name"/></td> </tr> </table>

That's a really over-simplified example, as that could easily be done
apply-templates and a match on materials, which could easily be
included. In reality, each section relies on variables setup
elsewhere in doc, and has to get data from many different locations.


I could make umpteen copies and easily cut out the bits I don't want, but then if the header changes I need to edit umpteen XSL's

What I really want to do is have "shell" XSL that combines the
relevant bits

Include header Include sect 1 Include Sect 4 Include footer

The big problem I see is that the header will have the<html>
and<body>  tags and footer needs to have the</body>  and</html>  tags
so neither the header of footer could be valid xml, xsl, etc. (I know
I could use&gt; and disable output escaping)

Is there any way to do this?

Regards

mark



-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread