Background Color:
 
Background Pattern:
Reset
Search
Home Recent Changes Show All Pages

Ordered and Unordered Lists

Not Rated Yet

A list is a sequence of items that arrange their content down the page using either bullets or sequential markers for each inner item.
Scryber supports unlimited nesting of list items, multiple styles of item sequencing, concatenation of the list tree, and also grouping that allows sequences to be remembered and continued in non-contiguous lists

Article Contents

A simple unordered list

The basic list will show bullets against each inner list item with an indentation.

        <pdf:Page id="SimpleList" outline-title="A basic list" >
          <Content>
            
            <!-- the simple list -->
            <pdf:List>
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>
            
          </Content>
        </pdf:Page>
PDFPage pg = new PDFPage();
PDFList list = new PDFList();
Pg.Contents.Add(list);
string[] items = new string[] { “First Item”, “Second Item”, “Third Item”};
foreach(string label in items)
{
	PDFListItem li = new PDFListItem();
	PDFTextLiteral lit = new PDFTextLiteral(label);
	li.Contents.Add(lit);
	list.Items.Add(li);
}

Preview Image

List types and structure

The base class for lists is PDFList, which has 2 sub classes for ordered (PDFListOrdered) and unordered (PDFListUnordered). The xml elements corresponding to these are <pdf:List>,<pdf:Ul> and <pdf:Ol> where the pdf prefix relates to the Scryber.Components namespace.

Any styles that are applied to the type PDFList (applied-type=’pdf:List’) will also be included in the ordered and unordered lists. PDFListOrdered and PDFListUnordered are independent.

Preview Image

Available List types

The following list types are currently supported : Bullet; Decimals; Lowercase Roman; Uppercase Roman; Lowercase Letters; Uppercase Letters and None.

            <!-- a bullet list -->
            <pdf:List styles:number-style="Bullet"  styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- a decimal numeric list -->
            <pdf:List styles:number-style="Decimals" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- a lowercase roman list -->
            <pdf:List styles:number-style="LowercaseRoman" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- an upper case roman list -->
            <pdf:List styles:number-style="UppercaseRoman" styles:margins="10pt">
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- a lower case letter list -->
            <pdf:List styles:number-style="LowercaseLetters" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- an upper case letter list -->
            <pdf:List styles:number-style="UppercaseLetters" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- a list with no numbers or bullets -->
            <pdf:List styles:number-style="None" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

Preview Image

 

NOTE: Whilst the default numbering for an ordered list is Decimals, it is only applied via the base style. It is perfectly possible to apply the None, Bullet or any other style type to any of the list classes, in exactly the same way as other styles.

Becasuse the list and also list items are fully qualified blocks, they fully support all the block style attributes such as background, margins, color etc. and the list items support complex content within each item – images, divs, links, and other lists.

Nesting lists and concatenation

All lists are built and enumerated based on the document level numbering. The numbering supports a hierarchy of increments and can therefore be joined and concatenated with outer lists (by default these are not concatenated).

Prefixes and Postfixes to each of the labels can also be applied to separate values.

            <!-- a list with an inner list -->
            <pdf:List styles:number-style="UppercaseRoman" styles:margins="10pt" styles:number-postfix=".">
              <pdf:Li>First Item
                <pdf:List styles:number-style="LowercaseRoman" styles:number-postfix="." >
                  <pdf:Li >First Inner item</pdf:Li>
                  <pdf:Li >Second Inner item</pdf:Li>
                </pdf:List>
              </pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- a list with an inner concatenated list -->
            <pdf:List styles:number-style="UppercaseRoman" styles:margins="10pt" styles:number-postfix=".">
              <pdf:Li>
                First Item
                <pdf:List styles:number-style="LowercaseRoman" styles:number-prefix=" " styles:number-postfix="." styles:number-concat="true" >
                  <pdf:Li >First Inner item</pdf:Li>
                  <pdf:Li >Second Inner item</pdf:Li>
                </pdf:List>
              </pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

Preview Image

 

The depth of concatenation is not limited, but list items are kept together, so the top level item will always be in a single contiguous block. Layouts could become fragmented as the depth (and height) becomes larger.

Using groups

All list support the use of grouping. This is a key name driven enumeration where the last number and style is remembered, and applied to the next list that declares the same group. They are remembered at the document level, so lists do not need to be in the same section or even template file.

            <!-- a first list in the group -->
            <pdf:List styles:number-style="LowercaseRoman" styles:number-group="increment" styles:number-postfix="."  styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- a second list -->
            <pdf:List styles:number-style="LowercaseRoman" styles:number-group="increment" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>
            
            The lists do not have to be following each other<pdf:Br/> and the style, prefix, postfix will be remembered. 
            <!-- another lowercase roman list - even through the style is not declared -->
            <pdf:List styles:number-group="increment" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

Preview Image

 

The number grouping also works with inner list items, and the depth is not fixed.

            <!-- a first list in the group -->
            <pdf:List styles:number-style="LowercaseRoman" styles:number-group="increment" styles:number-postfix="."  styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

            <!-- a second list -->
            <pdf:List styles:number-style="Decimals" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item
                <pdf:List styles:number-group="increment" styles:margins="10pt" >
                  <pdf:Li >Inner item that continues the group</pdf:Li>
                  <pdf:Li >Second inner item that continues the group</pdf:Li>
                </pdf:List>
              </pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>
            
            The lists do not have to be following each other<pdf:Br/> and the style, prefix, postfix will be remembered. 
            <!-- another lowercase roman list - even through the style is not declared -->
            <pdf:List styles:number-group="increment" styles:margins="10pt" >
              <pdf:Li>First Item</pdf:Li>
              <pdf:Li>Second Item</pdf:Li>
              <pdf:Li>Third Item</pdf:Li>
            </pdf:List>

Preview Image

Advanced styling options

All previous examples have used inline styles to explicitly define the features of the list and inner items, but these can also be applied within the document or referenced style definitions.

There are also style items that alter the width of the number region (@number-inset) and the horizontal alignment (@number-alignment)

<Styles>
<styles:Style applied-type="pdf:List" applied-class="roman-counted" >
      <styles:List number-alignment="Left" number-inset="100pt" 
                   number-style="LowercaseRoman" number-concat="false" 
                   number-postfix="." number-prefix="Item " number-group="item-roman" />
      <styles:Background color="#EEEEEE"/>
      <styles:Border color="#DDDDDD" width="1pt"/>
      <styles:Position full-width="true" />
      <styles:Padding all="3pt"/>
    </styles:Style>

    <styles:Style applied-type="pdf:Li" applied-class="counted-item" >
      <styles:Border color="#DDDDDD" width="1pt"/>
      <styles:Padding all="3pt"/>
      <styles:Position full-width="true" />
    </styles:Style>

.
.
.

<pdf:List styles:class="roman-counted" >
    <pdf:Li styles:class="counted-item" >First Item</pdf:Li>
    <pdf:Li styles:class="counted-item" >Second Item</pdf:Li>
    <pdf:Li styles:class="counted-item" >Third Item</pdf:Li>
</pdf:List>

Preview Image

Binding to sources

Just as everything else in srcyber. The components and values fully support data binding.

<pdf:Section id="Bindings" outline-title="Data bound list" styles:padding="10pt" >
      <Content>
          <pdf:H4 styles:border-color="black" styles:border-sides="Bottom" styles:border-width="1pt">
            A list data bound to a large xml file, generating long content
          </pdf:H4>
        <pdf:Ol>
          <data:ForEach select="MedlineCitationSet/MedlineCitation/Article[@PubModel='Print']" datasource-id="MedlineCitations" >
            <Template>
              <pdf:Li styles:padding="4pt">
                <pdf:Label text="{xpath:ArticleTitle}" />
              </pdf:Li>
            </Template>
          </data:ForEach>
        </pdf:Ol>

        <data:XMLDataSource id="MedlineCitations" source-path="../../XML/medsamp2014.xml" ></data:XMLDataSource>
      </Content>
    </pdf:Section>

Preview Image

See Also



  Rating
Rate This Page: Poor Great   |  Rate Content |
Average rating:  No Ratings Yet   
Number of Ratings : 0
  Comments
Add Comment
No Comments Yet