[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)


Subject: RE: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 11 Jun 2012 13:19:44 -0400

At 2012-06-11 16:54 +0000, Michele R Combs wrote:
Thanks. I should have been clearer in my request. I understand the concept of modes (what they are for) but have been having difficulty putting them into execution, and/or untangling them in pre-existing code. A technical explanation with examples is more what I'm looking for.

I can't think of much more to add to Ihe's summary description ... these are the bullets I talk to in class about what to use when:


===8<---
As a general rule of thumb when deciding how to write a template rule:

- when matching different nodes of different names: no special approach
- modes, context and priority need not come into play when template rules have no overlapping match conditions
- when matching the same node for different results: use different modes
- without modes there would be a template conflict (which may not get reported)
- need to distinguish the different results in templates of different collections that get matched using different modes
- when matching different nodes with the same name: use context and possibly priority
- the use of context distinguishes nodes from each other by their respective ancestors or by respective predicates
- the use of priority distinguishes templates when the implicit template priority is not unique
===8<---


As he says, when the very same node (not two nodes with the same properties) needs to be handled in the push processing style with different template rules, they need to be in different modes.

And his example of processing one node, say a chapter's title element, in two different ways, such as in the table of contents and in the body of the book, using modes ensures that one node is handled differently when pushing it.

There isn't much more to add for a good example of the need to use modes.

I hope this helps.

. . . . . . . . . Ken


-- Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal


Current Thread
Keywords