[opencms-dev] Apply template on nested xmlcontent

Thomas Adams thomas.adams at interone.cn
Fri Mar 7 01:49:51 CET 2014


Dear all,

I try to apply a JSP template to nested content.
I have a XSD  like :

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
       <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>
       <xsd:include schemaLocation="opencms://system/modules/cn.opencms.mysql.ecrm/schemas/formfields/option.xsd"/>
       <xsd:element name="Selects" type="OpenCmsSelects"/>
       …….
<xsd:complexType name="OpenCmsSelect">
              <xsd:sequence>
                     <xsd:element name="options" type="OpenCmsOption" minOccurs="0" maxOccurs="unbounded"/>
              </xsd:sequence>
              <xsd:attribute name="language" type="OpenCmsLocale" use="optional"/>
       </xsd:complexType>
</xsd:schema>

With the CmsOption XSD:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

       <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>

       <xsd:element name="Options" type="OpenCmsOptions"/>
       ….
       <xsd:complexType name="OpenCmsOption">
              <xsd:sequence>
                     <xsd:element name="value" type="OpenCmsString" minOccurs="1" maxOccurs="1"/>
                     <xsd:element name="text" type="OpenCmsString" minOccurs="1" maxOccurs="1"/>
              </xsd:sequence>
              <xsd:attribute name="language" type="OpenCmsLocale" use="optional"/>
       </xsd:complexType>
</xsd:schema>

And the option template option.jsp as :
<cms:contentload collector='singleFile' param='%(opencms.filename)'>
<cms:contentaccess var='optionContent' />
       <cms:template element="option">
              <c:set var='optionValue' value=''/>
              <cms:contentcheck ifexists='optionContent.value'>
                     <c:set var='optionValue'><cms:contentshow element='optionContent.value' /></c:set>
              </cms:contentcheck>
              <c:if test='${!empty optionValue}'>
                     <c:set var='optionValue' value=' value="${value}"'/>
              </c:if>

<c:set var='optionText' value=''/>
              <cms:contentcheck ifexists='optionContent.text'>
                     <c:set var='optionText'><cms:contentshow element='optionContent.text' /></c:set>
              </cms:contentcheck>
              <option<c:out escapeXml='false' value='${optionClass}${optionId}${optionDisabled}${optionSelected}${optionValue}' />><c:out value="${optionText}"/></option>
       </cms:template>
</cms:contentload>

For both XSD I have setup corresponding resourcetypes and corresponding templates JSP’s
Within the template for the select now I want to apply the template of the options resource like:

<cms:contentloop element="options">
       <cms:contentaccess var='optionContent' />
                <cms:include file="/system/modules/cn.bmw.opencms.mysql.ecrm/templates/option.jsp">
              <cms:param name="optionContent" value="${optionContent}"/>
       </cms:include>
</cms:contentloop>

But in the end the options get not correctly rendered the [text] and [value] are missing:
It renders something like:
<select …..>
                <option></option>
                <option></option>
                <option></option>
<select>

With empty options, Is there any way to achieve this  and to avoid to repeat
Template code from the option template in the select template again?


Thomas Adams德勤
DIRECTOR APPLICATION DEVELOPMENT

[io]

INTERONE CHINA // AN AGENCY OF BBDO WORLDWIDE
1604, E -TOWER, 12 GUANGHUA ROAD, CHAOYANG DISTRICT, BEIJING 100020, CHINA
北京天一国际广告有限公司
光华路丙12号数码01大厦1604室,100020 北京,朝阳区

PHONE +86 10.65 91 3792 EXT. -3026 // MOBILE +86 139 1059 0750

WWW.INTERONE.CN<https://mail.weboutlook.hk/owa/redir.aspx?C=4f9ed844d60c4108874abc272e3662e9&URL=http%3a%2f%2fwww.interone.cn%2f>

PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS E-MAIL.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20140307/5e01f602/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 5135 bytes
Desc: image001.png
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20140307/5e01f602/attachment.png>


More information about the opencms-dev mailing list