# Elementname: `While`

## Description

Create a loop. All child elements are executed as long as the condition in the test attribute evaluates to true.

Allowed attributes: test

Child elements: Action, AddSearchpath, Attribute, B, Barcode, Bookmark, Br, Column, Columns, Copy-of, DefineColor, DefineFontalias, DefineFontfamily, DefineTextformat, Element, Fontface, ForAll, Frame, Group, HSpace, Hyphenation, I, Image, Include, Initial, InsertPages, Layout, Li, LoadDataset, LoadFontfile, Loop, Message, NewPage, NextFrame, NextRow, Options, Output, Pageformat, Paragraph, PlaceObject, PositioningArea, PositioningFrame, ProcessNode, SaveDataset, SavePages, SetGrid, SetVariable, SortSequence, Span, Sub, Sup, Switch, Table, TableNewPage, Tablehead, Tablerule, Td, Tr, Trace, U, Until, Value, While

Parent elements: AtPageCreation, AtPageShipout, Case, Contents, ForAll, Layout, Loop, Otherwise, Record, SavePages, Until, While

### Attributes

test (XPath Expression)

  Every time before the the loop is executed, this condition must evaluate to true. See the command Until for a loop with an exit test.

## Example

The following example creates a textblock with three times the contents 'Text Text Text '.

    <Record element="data">
      <SetVariable variable="counter" select="1"/>
      <SetVariable variable="text" select="''"/>
      <While test=" $counter &lt;= 3 "> <!-- less or equal -->
        <SetVariable variable="counter" select=" $counter + 1"/>
        <SetVariable variable="text">
          <Value select="$text"/>
          <Value select="'Text '"/>
        </SetVariable>
      </While>
      <PlaceObject>
        <Textblock>
          <Paragraph><Value select="$text"/></Paragraph>
        </Textblock>
      </PlaceObject>
    </Record>

## See also

Switch, SetVariable, Until

# Commands

- A
- Action
- AddSearchpath
- AtPageCreation
- AtPageShipout
- AttachFile
- Attribute
- B
- Barcode
- Bold
- BoldItalic
- Bookmark
- Box
- Br
- Case
- Circle
- Color
- Column
- Columns
- Compatibility
- Contents
- Copy-of
- DefineColor
- DefineColorprofile
- DefineFontalias
- DefineFontfamily
- DefineTextformat
- Element
- Fallback
- Fontface
- ForAll
- Frame
- Grid
- Group
- Groupcontents
- HSpace
- Hyphenation
- I
- Image
- Include
- Initial
- InsertPages
- Italic
- Layout
- Li
- LoadDataset
- LoadFontfile
- Loop
- Makeindex
- Margin
- Mark
- Message
- NewPage
- NextFrame
- NextRow
- NoBreak
- Ol
- Options
- Otherwise
- Output
- Overlay
- PDFOptions
- Pageformat
- Pagetype
- Paragraph
- PlaceObject
- Position
- PositioningArea
- PositioningFrame
- ProcessNode
- Record
- Regular
- Rule
- SaveDataset
- SavePages
- SetGrid
- SetVariable
- SortSequence
- Span
- Stylesheet
- Sub
- Sup
- Switch
- Table
- TableNewPage
- Tablefoot
- Tablehead
- Tablerule
- Td
- Text
- Textblock
- Tr
- Trace
- Transformation
- U
- URL
- Ul
- Until
- VSpace
- Value
- While

Version: 3.8.0 | Start page | Command reference | Other language: German