Formatting lists: Numbers and Positions


Applications

Formatting an ordered list (e.g. in HTML <OL>): Counting the elements. Seperate the list items by a comma, except the last item which should get no comma!
  1. Flour
  2. Sugar
  3. Butter
Flour, Sugar, Butter

Methods

1. Numbering

(child-number snl)

"Returns the child number of snl. The child number of an element is one plus the number of element siblings of the current element that precede in tree order the current element and that have the same generic identifier as the current element."
Child-number counts the preceding siblings of snl. I.e. child-number counts the children of a single element.
(In contrast element-number counts all nodes with the same gi.)
Use child-number for numbering a list.

(element-number snl)

"Returns the number of elements before or equal to snl with the same gi as snl."
Element-number counts all elements before snl with the same gi in the grove.
Use element-number for numbering elements in an mixed-up document. E.g. counting all <H1> elements in an HTML-Document.

Example: The child-number of the second <C> is 1, because this is the first child of <A> with gi "C".
But the element-number of this second <C> is 2, because it's the second node with gi "C" in the document.


2. Positions

Note: The boolean values in DSSSL/Scheme are: True=#t False=#f

(first-sibling? ndl)

"Returns #t if snl has no preceding sibling that is an element with the same generic identifier as itself, and otherwise returns #f."
"that is an element" means that data is ignored.

(absolute-first-sibling? ndl)

"Returns #t if snl has no preceding sibling that is an element, and otherwise returns #f."

(last-sibling? ndl)

"Returns #t if snl has no following sibling that is an element with the same generic identifier as itself, and otherwise returns #f."

(absolute-last-sibling? ndl)

"Returns #t if snl has no following silbing that is an element, and otherwise returns #f."

Example

The values of each method are displayed for each single node (#t = true, #f = false).

You need a java-enabled browser!!!


Stylesheets


Next: Query node-lists.
Index