- From: G. Ken Holman <gkholman@CanadaMail.com>
- Date: Sat, 12 Sep 1998 08:48:59 -0400
- To: XSL Editors <xsl-editors@w3.org>
Here is a DSSSL fragment that specifies a different list type based on modulo arithmetic: (define (depth nd) ;calculate list depth for node (if (not (gi nd)) ;then not an element 0 ;depth must be zero (+ (if (string=? (gi nd) "LIST" ) 1 ;count it if so 0) ;ignore it if not (depth (parent nd))))) (element li ;a list item (make paragraph space-before: (if (and (not (node-list-empty? (ipreced (current-node)))) (string=? (gi (ipreced (current-node))) "LI" )) 0pt 10pt) start-indent: (* (depth (current-node)) indent-step) first-line-start-indent: (- indent-step) (make line-field field-width: indent-step field-align: 'end (if (string=? (debug (attribute-string "TYPE" (parent (current-node)))) "UL") (literal "˙") ;unordered list uses a dot character (sosofo-append ;ordered list rotates use of numbers (literal (format-number (child-number) (case (modulo (depth (current-node)) 3) ((0) "a") ((1) "i") ((2) "1")))) (literal ")"))) (literal " ")) (process-children))) This numbers the items three different ways, nested, independent of the depth level. In the WD, the following example would be followed: <xsl:choose> <xsl:when test='ancestor(list[attribute(type)="OL"] /list[attribute(type)="OL"])'> <xsl:number format="a"/> </xsl:when> <xsl:when test='ancestor(list[attribute(type)="OL"])'> <xsl:number format="i"/> </xsl:when> <xsl:otherwise> <xsl:number format="1"/> </xsl:otherwise> </xsl:choose> But from what I can tell, everything at 0-based depth of 2 or greater would all have the same "a" format. By adding some kind of repeater to patterns, the following could be done: <xsl:choose> <xsl:when test='ancestor( repeat( list[attribute(type)="OL"] /list[attribute(type)="OL"] /list[attribute(type)="OL"] ) /list[attribute(type)="OL"] /list[attribute(type)="OL"])' > <xsl:number format="a"/> </xsl:when> <xsl:when test='ancestor( repeat( list[attribute(type)="OL"] /list[attribute(type)="OL"] /list[attribute(type)="OL"] ) /list[attribute(type)="OL"])' > <xsl:number format="i"/> </xsl:when> <xsl:otherwise> <xsl:number format="1"/> </xsl:otherwise> </xsl:choose> I think this would change the spec along the lines of the following (but I'll confess I'm not practiced at specifying these kinds of things): [13] AncestorAnchor ::= 'ancestor' '(' ( 'repeat' '(' Pattern ')' )? Pattern ')' When specified the repeated pattern can repeat zero or more times. Alternatively, I suppose one could add this operator more generally to patterns: [1] Pattern ::= OrPattern | RepeatPattern [new] RepeatPattern ::= 'repeat' '(' Pattern ')' ....... Ken -- G. Ken Holman mailto:gkholman@CanadaMail.com Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, V: +1(613)489-0999 Kars, Ontario CANADA K0A-2E0 F: +1(613)489-0995 Training: http://www.CraneSoftwrights.com/s/schedule.htm Resources: http://www.CraneSoftwrights.com/s/resources.htm Shareware: http://www.CraneSoftwrights.com/s/shareware.htm
Received on Saturday, 12 September 1998 08:51:04 UTC