xsl-list
[Top] [All Lists]

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

2012-06-12 10:34:34
Hi Michele,
I  have a case where I am migrating code from one format to another. 
Target format is DITA.

Where the <table> elements have a <title>, we output a DITA <table>.
If no <title>, we output a DITA <simpletable>.
I chose to handle this by processing in either of two modes called "table" and 
"simpletable".
The rows in the two cases are either <row> in table or <strow> in simpletable.
Similarly, the names are <entry> and <stentry> for the table cells.

The same "elements" are processed in more than one way.
This is similar to processing the same "nodes" in more than one way as Ihe 
describes, but is not the same case.
I am sure there are other valid cases for using "mode", however, as Ihe says, 
you don't want to use "modes" unless you need to, as they add one more layer to 
your code that the next user will need to understand.

I have chosen to aid the reader in a simple way:
- all uses of those two modes occur within 68 lines of code delimited with:
<!-- START Tables -->
<!-- END Tables -->

Rob



-----Original Message-----
From: Ihe Onwuka [mailto:ihe(_dot_)onwuka(_at_)googlemail(_dot_)com] 
Sent: Monday, June 11, 2012 2:12 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)

On Mon, Jun 11, 2012 at 5:54 PM, Michele R Combs <mrrothen(_at_)syr(_dot_)edu> 
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 have seen modes used to disambiguate template rules where priorities
would have done the job, so the appearance of modes in pre-existing
code may be gratuitous.

My personal preference is to restrict the usage of modes to the use
case where they are necessary, that way the appearance of modes in
code highlights that the nodes in question are  being processed by
more than one template rule and their absence signals they are not. As
Ken usefully pointed out this assumes push style processing.

I find such disciplines useful, it saves you from having to read the
code to find out the same thing.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--