Re: [xsl] nested templates?

Subject: Re: [xsl] nested templates?
From: Alex Black <enigma@xxxxxxxxxxxxxxxx>
Date: Wed, 16 May 2001 11:55:13 -0700
> 
>> The above seems to be illegal, though I can't think of a good reason why.
> 
> It is clearly illegal, what would you want it to mean?
> I suspect that xsl:template does not operate the way you imagine.

apparently not.

>> is it possible to construct an xslt stylesheet that is more similar to a
>> "complete" page, i.e. with nested templates:
> 
> It is possible to design a "complete page" this is what is sometimes
> called the pull method, in fact if you are doing that, you don't need
> any xsl;template instructions at all, see the XSLT spec for an example
> (or the FAQ for this list).

I've seen that faq and _all_ of the examples are:

xsl:stylesheet

xsl:template
xsl:apply-templates

xsl:template

xsl:template

.. ad infinum.

-- this is the "lots of little bits" method, which is not useful for
production.

> 
>> (btw, this is not syntactically complete, but you get the idea :)
> 
> No, I can't imagine what the idea is! I think you are trying to
> do something like xsl:for-each but with an illegal use of xsl:template.
> It would be clearer if you said what you wanted to happen rather than
> posting some code you know to be wrong and then asking us to guess
> what you want it to do!

I actually did say, quite explicitly:

Is it possible to nest templates, i.e. to create templates for elements, and
nest them within on another, so I can effectively build a complete page,
with some xsl sprinkled in to take care of value-of selection.

I have been unable to find a good example of this syntax structure in XSL.

I _have_ been able to find many, many examples of

template
    apply-templates
/template

template
    apply-templates
/template

template
    apply-templates
/template

where the first is
<html> etc

the second is a master layout:
<div align="center>
<ul>
apply-templates
</ul>
</div>

and the third is an "item":
<li>value-of select</li>

Which is not useful to me.

I would prefer the following:

template
    template
        <stuff>
    /template
    apply-templates
/template

which is much more true to the hierarchical structure of XML and indeed all
markup.

If you can provide some good links to complex, real-world examples of XSL
stylesheets, I'd be grateful, because everything I've found is either an
Xpath tutorial or "hello world" kind of stuff. :)


-alex



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


Current Thread