Skip to content

filter.csv-to-xml.url-template (collection.cfg setting)

Description

The template to use for the URLs of the documents created in the CSVToXML Filter.

As each row in the CSV file is converted into a new XML document each document will need a unique URL. This option allows you to use freemarker templating language to define the URL to use.

Variables

The following variables are made available in the template:

  • ${scheme_host_port}: Contains the scheme, host and port e.g. https://example.com:81
  • ${path}: The path of the URL as is e.g. /foo/bar.
  • ${path_ends_with_slash}: The path of the URL such that it ends with a slash, if the original URL path is /foo/bar this value will be set to /foo/bar/.
  • ${query}: The query part of the URL e.g. ?foo=bar.
  • ${query_ends_with_query_separator}: The query part of the URL such that it ends with either ? or & such that an argument can be appended for example if the query is ?foo=bar this will be set to ?foo=bar&.
  • ${id_number}: Usually the row number of the record of the CSV file.
  • ${fragment}: The fragment of the URL e.g. #Foo.
  • ${csv_value_by_header}: A map of the CSV record where the key is the field name (from the header) and the value is the value of that field, for example to get the year of the csv record
    ${(csv_value_by_header['year'])?url}. If the header is not defined you can access the n'th field using field_n for example to access the first field use ${(csv_value_by_header['field_0'])?url}. The ?url part is for escaping the field value so that it is safe to be in a URL.

Default value

The default is to use the id_number as a query parameter of the URL:

filter.csv-to-xml.url-template=${scheme_host_port}${path}${query_ends_with_query_separator}id=${id_number}${fragment}

Examples

To use the year field of the CSV in the URLs path:

filter.csv-to-xml.url-template=${scheme_host_port}${path_ends_with_slash}${(csv_value_by_header['year'])?url}${query}id=${id_number}${fragment}

See also

top

Funnelback logo
v15.16.0