{xmlfield:tags:field_id}

Description

Wraps an item field value in an XML element, for building XML or RSS export feeds from item content. The first parameter is the tag (or two space-separated names: an outer wrapper tag and the inner element tag). The second parameter is a field id of the current items slice - or any AA expression/alias, which is then resolved and wrapped as-is. xmlfield needs a current item: with no item in context it returns nothing. A multi-value field repeats the element once per value; a multilingual field adds a lang attribute per translation (lang="cs", lang="en"); a field that offers a formatter choice adds a format attribute (format="plain" or format="html"). Empty values are skipped, and the outer wrapper is emitted only when there is at least one inner element. Element content is XML-escaped. Bind a specific item with the item expression, deferring xmlfield so it runs in that items context: see the examples.

Parameters

tags required default (empty)

The XML element name to wrap the value in. Give one name for a plain element, or two space-separated names to add an outer wrapper: an outer-tag plus an inner-tag. With two names every value becomes an inner element and the whole set is wrapped once in the outer tag (the outer tag is emitted only when there is at least one value).

field_id required default (empty)

Which field of the current items slice to read, e.g. headline........ or category........ . You may instead pass any AA expression or alias (for example _#NUMBER__ or literal text); when it is not a field id it is resolved and wrapped as-is, without the per-value, format or lang handling that real fields get.

Examples

virtual[{item:5726c2c6b035d7aab450d1794e9e90d7:{({xmlfield:name:headline........})}}]
Expected[<name>Gamma</name>]
Actual[Gamma]
The everyday use: wrap one items field in an XML element. Bind the item with the item expression and defer xmlfield with the (...) braces so it runs in that items context; a bare xmlfield reads whatever item is currently rendering.
test[{item:5726c2c6b035d7aab450d1794e9e90d7:{({xmlfield:tag:edit_note.......})}}]
Expected[]
Actual[]
An empty field produces no element at all - xmlfield skips empty values. Here the items edit_note field is blank, so the result is empty.
virtual{item:5726c2c6b035d7aab450d1794e9e90d7:{({xmlfield:colors color:abstract........})}}
Expected<colors><color format="plain">red</color></colors>
Actualred
Two space-separated names give an outer wrapper and an inner element: outer-tag then inner-tag. Each value becomes an inner element and the whole set is wrapped once. The format attribute appears because this field offers a plain/html formatter choice.
test[{item:5726c2c6b035d7aab450d1794e9e90d7:{({xmlfield:colors color:edit_note.......})}}]
Expected[]
Actual[]
The outer wrapper is emitted only when there is at least one inner element. With an empty source field, both the inner element and the outer wrapper are suppressed - the result is empty, not an empty pair of tags.
virtual[{item:5726c2c6b035d7aab450d1794e9e90d7:{({xmlfield:body:full_text.......})}}]
Expected[<body format="plain">Gamma contains color data: red green blue. Used for string tests.</body>]
Actual[Gamma contains color data: red green blue. Used for string tests.]
When a field lets the editor pick a formatter (plain or html), xmlfield records that choice as a format attribute on the element. The body field here is stored plain, so format=plain.
virtual{item:00000000000000000000000000000000:{({xmlfield:name:headline........})}}
Expected(<name lang="cs">Jan</name><name lang="en">John</name>)
For a multilingual field, xmlfield repeats the element once per translation and tags each with a lang attribute. The frozen test slice is single-language and the item id here is a placeholder, so the live result is empty; the expected output below shows the shape you get on a real multilingual slice.
virtual[{item:5726c2c6b035d7aab450d1794e9e90d7:{({xmlfield:n:_#NUMBER__})}}]
Expected[<n>100</n>]
Actual[100]
The second parameter does not have to be a field id. Any AA expression or alias is resolved and wrapped as-is. Here _#NUMBER__ is the items integer alias; because it is not a slice field, no format or lang handling is applied.
virtual{item:5726c2c6b035d7aab450d1794e9e90d7:{({xmlfield:title:headline........})}{({xmlfield:summary:abstract........})}}
Expected<title>Gamma</title><summary format="plain">red</summary>
ActualGammared
The real-world pattern: inside an items view or export template the current item is already in context, so you list one xmlfield per field you want in the feed. Each emits one element and empty fields drop out. Here two fields of one item are bound to show the combined output; the summary field carries a format attribute because it offers a formatter choice.