Re: [xsl] Suggestions for naming files based on starting node?

Subject: Re: [xsl] Suggestions for naming files based on starting node?
From: Chris von See <chris@xxxxxxxxxxxxx>
Date: Thu, 17 Apr 2008 08:19:31 -0700
I tried inserting <xsl:number> into the template where the file names are generated, but I couldn't get it to give me anything but the same number over and over again - I'm not totally sure why. I tried several combinations of level and count settings, but got the same result each time. Sometimes the output was zero, sometimes another number, but it was always the same number over and over.

There are a few factors that might have come into play to cause this:

-- The template that generates the file names is separate from the one that actually creates the files using <xsl:result-document> so that it can be called from any location where it's necessary to determine what XHTML file a given node will be in. This includes not only the bit that actually contains <xsl:result-document>, but the TOC generator, the hyperlink resolver, the note/annotation/index/ glossary cross-reference resolvers, etc. This file name generator template (I'll probably convert it to a function at some point) has a "mode" attribute to restrict processing.

-- The template that generates file names matches on "*", not just on the elements that need numbering, because of the need to determine what file an arbitrary node is (or will be) in. There is a bit of logic in this template (the actual file name generation part) which is executed only for the nodes that need numbering, and that's where I put the <xsl:number>, but since the numbering was wonky I wondered if the generic template match confused the XSLT processor. I could separate this logic into two templates - one for the nodes that need numbering and one for the nodes that don't - and I'll probably try this at some point just to see if it makes a difference.

-- The template that generates file names is heavily recursive, and uses internal logic to determine when to recurse. I wouldn't think this would really be a factor, but it might be.

I freely admit that my lack of experience writing really complicated XSLT may be my worst enemy here. If you have suggestions on how to handle situations like this (breaking long XML documents into multiple XHTML with cross-linking - not exactly an uncommon scenario!) or can point me to reference material that gives examples of techniques for doing this, I'd appreciate it.


Thanks Chris

On Apr 17, 2008, at 12:04 AM, David Carlisle wrote:


I incorporated <xsl:number> into a pre-process template that created
new identifier attributes for each element, a

If you need two passes anyway this is a good idea, but you shouldn't need two passes just for xsl:number should you?

David

Current Thread