There are several interesting spots in the XSD:
- The optional
Title
element
- The two mapping entries
- The definition of the default value for the
Title
element
The optional Title
element is the one mapped to property:Title
and galleryName
. The important fact is, that the <Mapping>
element has set the option <UseDefault>true</UseDefault>
. This setting forces the default value defined for Title
to be mapped to the Title
property even if the element itself is not present.
To set default values for the Title
element that fit for the actual content, special macros are used:
- The
%(page_title)
macro inserts the title of the page where the content is placed.
- The
%(no_prefix:)
macro places its body value, ":
" in the example, only if a prefix exists, i.e., if the %(page_title)
macro expands to a non-empty string in the example.
- The
%(value:)
macro takes an XPath to an element of the content and expands to the value of this content.
The use of <DefaultResolveMacros>false</DefaultResolveMacors>
option along with the <Default>
element is necessary to get the whole mapping working. If not set, the macros are resolved too early and will all expand to the empty string.
In case the optional Title
element is added to the content via the content editor, the default value with unresolved macros is displayed and can be adjusted. The content editor can also use the macros when editing the value.