[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] randlist followed by randlist with different indents


Subject: Re: [xsl] randlist followed by randlist with different indents
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Dec 2003 19:48:43 -0500

At 2003-12-29 15:23 -0500, Norma Yeazell wrote:
I have 3 randlist in a row within a paragraph, the first should be at left the next two indented diffently. Can anyone give me a clue how to get this accomplished?
...
<step1 id="step1-6">
<title>step1 title</title>
<para>This is a step 1.
<randlist id="randlist-6">
<item>Be careful not to short out battery terminal. </item>
<item>Do not smoke or use open flame near batteries. </item>
<item>Batteries may explode from spark.</item>
</randlist>
<randlist id="randlist-7">
<item>Sub-unordered list items start with a bullet indented 7mm for the left type limit.</item>
<item>The items within a sub-unordered list shall not be separated with a blank line.</item>
</randlist>
<randlist id="randlist-8">
<item>Subsub-unordered list items start with a bullet indented 14mm for the left type limit.</item>
<item>The items within a sub-unordered list shall not be separated with a blank line.</item>
</randlist>
</para>
<step2 id="step2-2">
<title>This is a sample title for a step 2</title>
<para>This is a step 2.</para>
</step2>
</step1>

This turns out to be simpler than originally thought. Provided your subordinate display relationship is based on a sibling source relationship, you can take advantage of XSL-FO's support of expressions as follows:


<xsl:template match="randlist">
  <list-block start-indent="{count(preceding-sibling::randlist)} * 7mm">
    <xsl:apply-templates/>
  </list-block>
</xsl:template>

<xsl:template match="item">
  <list-item provisional-distance-between-starts="1cm">
    <list-item-label end-indent="label-end()">
      <block>1</block>
    </list-item-label>
    <list-item-body start-indent="body-start()">
      <block><xsl:apply-templates/></block>
    </list-item-body>
  </list-item>
</xsl:template>

In the above you are indenting 7mm for each list after the first list by counting the number of preceding sibling randlist elements and multiplying that count by 7mm.

I hope this helps.

................................ Ken

--
North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-02-09
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords