<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi all,<br>
      <br>
      stepped on the same problem with the [index] brackets (version
      9.0.1).<br>
      <br>
      Is there a possiblitiy to map a specific subelement directly to
      solr field like Mathias described below:<br>
      <br>
      <searchsetting element="OptionalElements[2]/FeaturedImage"
      searchcontent="true"> <br>
          <solrfield targetfield="afeaturedimage" />
      <br>
      </searchsetting>
      <br>
      <br>
      Maybe in 9.5 ?<br>
      <br>
      Found two things, how it works, but a direct mapping would be
      preferable and straight forward:<br>
      <br>
      1. Use a specific property, as properties always are mapped to
      Solr,<br>
      <mapping element="OptionalElements[2]/FeaturedImage"
      mapto="property:FeaturedImage"/><br>
      and read field FeaturedImage_prop afterwards:<br>
      <str name="FeaturedImage_prop"><br>
          /sites/default/_images/image2.png<br>
      </str><br>
      <br>
      <br>
      2. Map all elements<br>
      <searchsetting element="OptionalElements/FeaturedImage"
      searchcontent="true"> <br>
          <solrfield targetfield="afeaturedimage" />
      <br>
      </searchsetting>
      <br>
      and select the desired one out of the list afterwards:<br>
      <str name="afeaturedimage"><br>
          /sites/default/_images/image1.jpg
      /sites/default/_images/image2.png
      /sites/default/_images/image3.png<br>
      </str><br>
      <br>
      Regards,<br>
      Tobias<br>
      <br>
      Am 26.08.2013 08:19, schrieb Mathias Lin:<br>
    </div>
    <blockquote
cite="mid:http:%2F%2Fpermalink.gmane.org%2Fgmane.comp.cms.opencms.devel%2F38226@localhost.localdomain"
      type="cite"><base
        href="http://permalink.gmane.org/gmane.comp.cms.opencms.devel/38226">
      <title>How to map field of nested choice xsd to property
        andsolrfield?</title>
      <base
        href="http://permalink.gmane.org/gmane.comp.cms.opencms.devel/38226">
      <pre>How do you configure a field mapping from a nested xsd, which has choices?

Since it's not clear at what position the certain choice element is, I am
not sure how to configure the mapping.

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?

The OpenCms documentation unfortunately doesn't give that much info about
those cases.


Below is an article.xsd, which embeds a article-choices.xsd.


    <xsd:complexType name="OpenCmsMAArticle">
        <xsd:sequence>
            <xsd:element name="Title" type="OpenCmsString" minOccurs="1"
maxOccurs="1"/>
            <xsd:element name="Subtitle" type="OpenCmsString" minOccurs="0"
maxOccurs="1"/>
            <xsd:element name="Teaser" type="OpenCmsString" minOccurs="0"
maxOccurs="1"/>
            <xsd:element name="Text" type="OpenCmsHtml" minOccurs="0"
maxOccurs="1"/>
            <xsd:element name="DetailViewPage" type="OpenCmsVfsFile"
minOccurs="0" maxOccurs="1"/>
*            <xsd:element name="OptionalElements"
type="OpenCmsMAArticleChoice" minOccurs="0" maxOccurs="unbounded"/>*
        </xsd:sequence>
        <xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
    </xsd:complexType>


    <xsd:complexType name="OpenCmsMAArticleChoice">
        <xsd:choice>
            <xsd:element name="FeaturedImage" type="OpenCmsVfsFile"
minOccurs="0" maxOccurs="1"/>
            <xsd:element name="LandingPageImage" type="OpenCmsVfsFile"
minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Image" type="OpenCmsVfsFile" minOccurs="0"
maxOccurs="1"/>
            <xsd:element name="IFrame" type="OpenCmsString" minOccurs="0"
maxOccurs="1"/>
            <xsd:element name="Video" type="OpenCmsMAVideo" minOccurs="0"
maxOccurs="1"/>
            <xsd:element name="LeftButton" type="OpenCmsMAButton"
minOccurs="0" maxOccurs="1"/>
            <xsd:element name="RightButton" type="OpenCmsMAButton"
minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ReleaseDate" type="OpenCmsDateTime"
minOccurs="0" maxOccurs="1"/>
        </xsd:choice>
        <xsd:attribute name="language" type="OpenCmsLocale" use="optional"/>
    </xsd:complexType>


My question now is, how can I map the nested OptionalElements/ReleaseDate
to attribute:datereleased ?

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?
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

            <mappings>
                <mapping element="Title" mapto="property:Title"/>
                <mapping element="OptionalElements[1]/ReleaseDate"
mapto="attribute:datereleased"/>
                <mapping element="OptionalElements[2]/ReleaseDate"
mapto="attribute:datereleased"/>
                <mapping element="OptionalElements[3]/ReleaseDate"
mapto="attribute:datereleased"/>
                <mapping element="OptionalElements[4]/ReleaseDate"
mapto="attribute:datereleased"/>
                <mapping element="OptionalElements[5]/ReleaseDate"
mapto="attribute:datereleased"/>
                <mapping element="OptionalElements[6]/ReleaseDate"
mapto="attribute:datereleased"/>
                <mapping element="OptionalElements[7]/ReleaseDate"
mapto="attribute:datereleased"/>

However, when I want to add further mappings for other choice elements,
this approach doesn't work.


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.

This doesn't work:

<searchsetting element="OptionalElements[2]/FeaturedImage"
searchcontent="true">
    <solrfield targetfield="afeaturedimage" />
</searchsetting>

Thanks.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
<a class="moz-txt-link-freetext" href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a>



</pre>
    </blockquote>
    <br>
  </body>
</html>