This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: nested templates?


Alex,

At 08:58 PM 5/16/01, you wrote:
>below is a real world example of for-each. (first 'document')
>this works.
>
>which is fine, but I far prefer nested templates, because that implies that
>I can _import_ those templates wherever I like, and build up complex
>documents out of little sub-formatters.

I'm puzzled. Why can't a template that's not nested match just fine, be 
'imported' just fine, whenever you need it?

So
<xsl:template match="/">
   <xsl:apply-templates/>
</xsl:template>

<xsl:template match="bookmark">
   <output>
     <xsl:apply-templates/>
   </output>
</xsl:template>

The second template will match *any* bookmark element that happens to be 
picked up by an apply-templates instruction, it doesn't matter where in the 
tree, how deep, or how many times: it always works the same way. All you 
need to do is make sure that your xsl:apply-templates call it properly 
(which is one reason why the built-in defaults provide for a depth-first 
traversal covering every node). Isn't that exactly what you want?

>I'm warming up to this language rapidly, after you get over the amazing
>verbosity of the syntax, it works quite well, actually :)

If I'm right and you just haven't 'clicked' with the processing model (and 
to be sure, alot is under the surface and you have to learn it's there 
before you can properly see why things work the way they do), you'll soon 
like it even better.

Or to put it in a nutshell, it's not XSLT that's the problem, it's our 
misplaced assumptions, typically drawn from other programming paradigms, 
that are getting in the way.

Sorry I can't help with the Sablotron stuff.

Cheers,
Wendell


======================================================================
Wendell Piez                            mailto:wapiez@mulberrytech.com
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
======================================================================


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]