<div dir="ltr">How do you configure a field mapping from a nested xsd, which has choices?<div style><br></div><div style>Since it's not clear at what position the certain choice element is, I am not sure how to configure the mapping.</div>
<div style><br></div><div style>Furthermore, how do you configure a searchsetting/solrfield for such nested choice element? Does it also need to be configured in the parent xsd or in the nested xsd?</div><div style><br></div>
<div style>The OpenCms documentation unfortunately doesn't give that much info about those cases.</div><div style><br></div><div style><br></div><div style>Below is an article.xsd, which embeds a article-choices.xsd.</div>
<div style><br></div><div style><br></div><div style><div><font face="courier new, monospace">    <xsd:complexType name="OpenCmsMAArticle"></font></div><div><font face="courier new, monospace">        <xsd:sequence></font></div>
<div><font face="courier new, monospace">            <xsd:element name="Title" type="OpenCmsString" minOccurs="1" maxOccurs="1"/></font></div><div><font face="courier new, monospace">            <xsd:element name="Subtitle" type="OpenCmsString" minOccurs="0" maxOccurs="1"/></font></div>
<div><font face="courier new, monospace">            <xsd:element name="Teaser" type="OpenCmsString" minOccurs="0" maxOccurs="1"/></font></div><div><font face="courier new, monospace">            <xsd:element name="Text" type="OpenCmsHtml" minOccurs="0" maxOccurs="1"/></font></div>
<div><font face="courier new, monospace">            <xsd:element name="DetailViewPage" type="OpenCmsVfsFile" minOccurs="0" maxOccurs="1"/></font></div><div><b><font face="courier new, monospace">            <xsd:element name="OptionalElements" type="OpenCmsMAArticleChoice" minOccurs="0" maxOccurs="unbounded"/></font></b></div>
<div><font face="courier new, monospace">        </xsd:sequence></font></div><div><font face="courier new, monospace">        <xsd:attribute name="language" type="OpenCmsLocale" use="required"/></font></div>
<div><font face="courier new, monospace">    </xsd:complexType></font></div><div><br></div><div><br></div><div><div><font face="courier new, monospace">    <xsd:complexType name="OpenCmsMAArticleChoice"></font></div>
<div><font face="courier new, monospace">        <xsd:choice></font></div><div><font face="courier new, monospace">            <xsd:element name="FeaturedImage" type="OpenCmsVfsFile" minOccurs="0" maxOccurs="1"/></font></div>
<div><font face="courier new, monospace">            <xsd:element name="LandingPageImage" type="OpenCmsVfsFile" minOccurs="0" maxOccurs="1"/></font></div><div><font face="courier new, monospace">            <xsd:element name="Image" type="OpenCmsVfsFile" minOccurs="0" maxOccurs="1"/></font></div>
<div><font face="courier new, monospace">            <xsd:element name="IFrame" type="OpenCmsString" minOccurs="0" maxOccurs="1"/></font></div><div><font face="courier new, monospace">            <xsd:element name="Video" type="OpenCmsMAVideo" minOccurs="0" maxOccurs="1"/></font></div>
<div><font face="courier new, monospace">            <xsd:element name="LeftButton" type="OpenCmsMAButton" minOccurs="0" maxOccurs="1"/></font></div><div><font face="courier new, monospace">            <xsd:element name="RightButton" type="OpenCmsMAButton" minOccurs="0" maxOccurs="1"/></font></div>
<div><font face="courier new, monospace">            <xsd:element name="ReleaseDate" type="OpenCmsDateTime" minOccurs="0" maxOccurs="1"/></font></div><div><font face="courier new, monospace">        </xsd:choice></font></div>
<div><font face="courier new, monospace">        <xsd:attribute name="language" type="OpenCmsLocale" use="optional"/></font></div><div><font face="courier new, monospace">    </xsd:complexType></font></div>
</div><div><br></div><div><br></div><div style>My question now is, how can I map the nested OptionalElements/ReleaseDate to attribute:datereleased ?</div><div style><br></div><div style>The approach below seems to work for the first mapping of a choice element, but it doesn't "feel right". Do I really need to configure a mapping for all the 7 position at which the choice item could be?</div>
<div style>Assuming that there can be a maximum of 7 choice elements (number of elements in my article-choice.xsd), I mapped all of them to the attribute, which seems to work that OpenCms only takes the </div><div style><br>
</div><div style><div><font face="courier new, monospace">            <mappings></font></div><div><font face="courier new, monospace">                <mapping element="Title" mapto="property:Title"/></font></div>
<div><font face="courier new, monospace">                <mapping element="OptionalElements[1]/ReleaseDate" mapto="attribute:datereleased"/></font></div><div><font face="courier new, monospace">                <mapping element="OptionalElements[2]/ReleaseDate" mapto="attribute:datereleased"/></font></div>
<div><font face="courier new, monospace">                <mapping element="OptionalElements[3]/ReleaseDate" mapto="attribute:datereleased"/></font></div><div><font face="courier new, monospace">                <mapping element="OptionalElements[4]/ReleaseDate" mapto="attribute:datereleased"/></font></div>
<div><font face="courier new, monospace">                <mapping element="OptionalElements[5]/ReleaseDate" mapto="attribute:datereleased"/></font></div><div><font face="courier new, monospace">                <mapping element="OptionalElements[6]/ReleaseDate" mapto="attribute:datereleased"/></font></div>
<div><font face="courier new, monospace">                <mapping element="OptionalElements[7]/ReleaseDate" mapto="attribute:datereleased"/></font></div></div><div style><br></div><div style>However, when I want to add further mappings for other choice elements, this approach doesn't work.</div>
<div style><br></div><div style><br></div><div style>Also, how to map such field to a searchsetting / solrfield? Do I add it to the parent or the nested xsd? Because using brackets for the [index] doesn't seem to be valid syntax.</div>
<div style><br></div><div style>This doesn't work:</div><div style><br></div><div style><div><font face="courier new, monospace"><searchsetting element="OptionalElements[2]/FeaturedImage" searchcontent="true"></font></div>
<div><font face="courier new, monospace">    <solrfield targetfield="afeaturedimage" /></font></div><div><font face="courier new, monospace"></searchsetting></font></div><div><br></div><div style>Thanks.</div>
</div><div style><br></div><div style><br></div><div style><br></div><div style><br></div><div><br></div><div><br></div></div></div>