Re: [xsl] grouping + global variable (?) (was re: regexs,

Subject: Re: [xsl] grouping + global variable (?) (was re: regexs,
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 12 Aug 2004 18:16:30 -0400
Bruce,

At 06:07 PM 8/12/2004, you wrote:
I'm using XSLT 2.0; therefore, let me see if the light is dawning:

My pass1 mode is going to create an exact copy of the source bibliographic collection, with the only difference being that the year strings get the proper suffix appended.

That's right. Pass one can do all kinds of useful enhancements of your data. This is why multiple passes get to be more and more useful (more and more unavoidable) as your processing requirements encroach on "up-conversion". XSLT 1.0 is designed mainly for down-conversions -- when all necessary info is explicit in the markup of the source. Once you start getting into inferencing, data-massaging and such, you're entering a different realm.


Then when I run the second pass through my template that says has <xsl:value-of select="$year"/> I end up with the original year plus the suffix.

Well it would depend on what $year was bound to. One thing to keep in mind when doing multiple passes in a single stylesheet is that references to the source tree (for example using absolute location paths) will still be to the original source tree, forcing you do things like $intermediate-result/date/year. It can require some care. (Relative location paths will still be relative to the context node, whatever it is, of course.)


So, yes, if you're processing an intermediate result whose 'year' value has been enhanced by a near-identity first pass, the processor can pick up that enhanced value, sort with it, etc.

Is that the idea?

It is.


I had gotten confused because I was thinking that somehow I'd be creating an element or attribute with, say, the generated suffix, and accessing those with some sort of xpath expression; e.g. <xsl:value-of select="$biblist//mods[@id=$thisid]/suffix"/>.

You can do this if you like: in fact you can create fragments of intermediate results as you go if you like, though I wouldn't recommend doing that until you're very clear on what's happening. For one thing, given XSLT's side-effect-free processing model, which David was describing earlier in another thread (assume everything's happening in parallel), doing much of this might make your brain explode.


That's the wrong way to think about it; correct?

It would depend, in this instance, on what $biblist was bound to. If it's a node set in the original source, having an intermediate result somewhere doesn't help. If it's a node set in an intermediate result it might be just what you want.


If you're unsure of how the pipeline works, it's probably smart to do a single global pipeline (as I outlined it) rather than many smaller local pipes (a pipe-organ?), and even model your initial cut in two separate stylesheets, combining them into one stylesheet only when everything's working.

Enjoy!

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