Re: [xsl] Re Numbering

Subject: Re: [xsl] Re Numbering
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 30 Mar 2004 14:22:46 -0500
Hi Mark,

At 01:22 PM 3/30/2004, you wrote:
I don't have specific code for this problem other than a stylesheet I
generated which was 0.5MB in size!  I don't really wish to inflict this on
the newsgroup.

You could certainly send a little snippet, however. Even sanitized for public consumption, it can still illustrate the problem. (In fact such sanitizing is recommended, as it can focus attention on the actual problem.)


For example, if your code had something like:

<xsl:if test="count(child::foo) &gt; 1">
  <xsl:apply-templates select="child::foo"/>
</xsl:if>

...we could tell you to dump the xsl:if wrapper, as it does nothing (and even the nothing that it does, it does in a needlessly complicated way). xsl:apply-templates will not select any children named "foo" to process if there are none there.

(I know this is a brain-dead example but you get what I mean.)

  Anyway this is not a problem specific to one stylesheet.  It
is a general problem that I may have to deal with in a large number of
varying circumstances.  What I was wondering (I suppose) in essence is: is
there some sort of variable storage container for a Stylesheet?  One that
you can write to and read from at various parts of the template.

There are ways of working around this, but the answer is:


1. No
2. This is a good thing, not a bad thing
3. Also, this is mitigated in XSLT 2.0, or by use of the XSLT 1.0 node-set extension function, which can provide (some of) this functionality. (It is still side-effect free, which complicates things.)


An analogy might be a steam engineer looking at an internal combustion engine and asking "so where's the boiler?" The answer is "There is no boiler: no boiler is needed". If steam engines are all you know, you might well think you need a boiler, when what you really need is a means of moving your train down the track.

  Pointers
in the right direction would be appreciated.

There are myriad places to look. Smart searching on terms such as "XSLT processing model", "XSLT 'functional approach'", "XSLT 'side effect free'" should smoke out a few pages on the philosophy of all this.


You mentioned xsl:number.  Do you know where would be the best place to get
info on that?  I failed to find it on www.w3.org.

You need to dig deeper. xsl:number is (as its namespace prefix, in the context of this list, indicates) a standard instruction in XSLT, and is documented in the XSLT spec at http://www.w3.org/TR/xslt, or in any reasonably complete book on the technology.


Cheers,
Wendell


====================================================================== 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