Search

October 1, 2009

List - XpressDox

List repeating data in a comma separated list

 

The «List»() command outputs repeating data elements as a formatted, delimited list. It is used as a standalone fillpoint.

 

Syntax

«List(parties,firstnames surname,!, , and )»
Parameter Description
repeat The name of the repeating element
data_element One or more data elements (or functions) within the repeat, separated by spaces
separator The separator between all items except the last two (use ! before a comma)
delimiter The separator before the second-to-last item
last_delimiter The separator before the last item (e.g. and )

Note: A comma in any delimiter parameter must be prefixed with ! because commas are used by XpressDox as parameter delimters. The same applies to ( and ).

 

Basic example

Given the following XML:

<parties>
<firstnames>Harry Charles</firstnames>
<aka>Charlie</aka>
<parties>
<firstnames>Juliet Charlene</firstnames>
<surname>Jones</surname>
<aka>Charley</aka>
</parties>
<parties>
<firstnames>Fred Reggie</firstnames>
<surname>Basset</surname>
<aka>Freddie</aka>
</parties>

 

To produce a comma-separated list of party names ending with “and”:

«List(parties, firstnames surname, !, , and )»

Output: Harry Charles Potter, Juliet Charlene Jones and Fred Reggie Basset

 

Using expressions with List

The data_elements parameter accepts a space-separated list of element names and/or functions, making it possible to compose more complex output:

 

  • Wrap a function around individual elements:
«List(parties, ToUpper(firstnames) ToUpper(surname), !, , and )»

Output: HARRY CHARLES POTTER, JULIET CHARLENE JONES and FRED REGGIE BASSET

 

  • Extract initials and apply uppercase to the surname:
«List(parties, ExtractInitials(firstnames, '.') ToUpper(surname), !, ,  and )»

Output: H.C. POTTER, J.C. JONES and F.R. BASSET

 

  • Mix functions and literal text using Use():
«List(parties, ExtractInitials(firstnames, '.') Use('aka') aka ToUpper(surname), !, ,  and )»

Output: H.C. aka Charlie POTTER, J.C. aka Charley JONES and F.R. aka Freddie BASSET

 

If you need to use a list inside another command or expression, see BuildList function for more info.