Subject: Re: [xsl] Re Numbering From: "Mark Williams" <mark@xxxxxxxxxxx> Date: Tue, 30 Mar 2004 19:22:10 +0100 |
Hi Wendell and thanks for the reply. 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. 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. Pointers in the right direction would be appreciated. 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. Thanks for any info Mark ----- Original Message ----- From: "Wendell Piez" <wapiez@xxxxxxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, March 30, 2004 5:52 PM Subject: Re: [xsl] Re Numbering > Hi Mark, > > At 08:14 AM 3/30/2004, you wrote: > >I have a requirement in an xslt stylesheet to set numbered headings for > >various parts of the stylesheet. Certain parts are included within > >conditional statements and are omitted if the conditions are not met. This > >has knock on consequences for the remainder of the numbered headings so, fo > >example, if there are 12 parts and part 10 is omitted, parts 11 and 12 > >become parts 10 & 11. > > Okay. > > >To achieve this I am wrapping every numbered heading in conditional > >statements. These statements apply the same conditionality that results or > >may result in the omission of an earlier part and sets the number of the > >heading accordingly. This works, but is very cumbersome. > > There may be more succinct ways to do this. xsl:apply-templates and > xsl:for-each instructions can easily include conditional logic, so when > they are in play (and when are they not? ;-), explicit conditionals > (xsl:choose / xsl:if) can often be avoided. (Show us your code.) > > >Does xsl support some sort of marker that can be incremented as you go > >along, so that after the first header is rendered the marker can be > >incremented by 1 or if there is a conditional statement the marker can be > >incremented/decremented as required. > > No, but > > (a) using techniques similar to those just mentioned, you can often avoid > using a counter -- there are other, XSLT-simpler ways to achieve the same > thing. For example, the xsl:number instruction takes a match pattern in its > 'count' attribute. Since match patterns can include predicates, conditional > logic can easily be included to filter the things you are counting. > > (b) when or if those techniques really fail, there are workarounds possible: > * processing the data in two passes can make the problem go away > * in really tight situations, "counters" or what passes for counters can be > implemented by hand, though this is almost never really necessary > > But what is actually possible depends on the particular conditions for > which you need to test. > > One complication of this problem is that XSLT is declarative, and is > designed so the programmer does not (generally) need to be concerned with > the specifics of flow control. As long as the output comes out as > specified, you never know: your processor could be going in reverse from > what you think. > > >I have had a quick look at the fo:marker and I'm not sure whether it is the > >sort of tool for what I need, but anyway it must be the descendant of a > >fo:flow and this causes me a problem as my marker needs to be carried over > >from one flow to another. > > I am not sure the problem belongs on the formatting layer: it sounds like > an XSLT problem to me. (Without seeing the specifics I can't be really > certain.) > > >I hope the above is not too confusing. I should probably also add that I am > >using FOP. > > It never hurts! > > Show us a bit of code: I'm sure someone can help. > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re Numbering, Wendell Piez | Thread | Re: [xsl] Re Numbering, Wendell Piez |
RE: [xsl] new thread... difference , M. David Peterson | Date | RE: [xsl] new thread... difference , M. David Peterson |
Month |