AnsweredAssumed Answered

Freemarker Error on child nodes

Question asked by junderwood on Jul 10, 2009
Latest reply on Jul 13, 2009 by junderwood
I am trying to render a page, accessing the child elements in a schema.  I have looked throught the freemarker documentation but just don't see the forest for the trees.

If someone can take a look at the following and point me in the right direction I would appreciate it.  Thanks

I keep getting the following error:
error regenerating rendition using company_superseminars.ftl: freemarker.core.NonStringException: Error on line 58, column 21 in freemarker_template Expecting a string, date or number here, Expression slist.locationNew is instead a freemarker.ext.dom.NodeListModel

Here is the schema:

<?xml version="1.0"?>
<xs:schema xmlns:alf="http://www.alfresco.org"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:avss="http://www.company.com/avss"
           targetNamespace="http://www.company.com/avss"
           elementFormDefault="qualified">

<xs:element name="company_superseminars" >
   <xs:complexType>
   <xs:sequence>
   <xs:element name="seminarLocation" minOccurs="0" maxOccurs="unbounded">
   <xs:complexType>
    <xs:sequence>   
   <xs:element name="locationNew" type="xs:normalizedString" minOccurs="0" maxOccurs="1">
              <xs:annotation>
                 <xs:appinfo>
                    <alf:label>Location</alf:label>   
                 </xs:appinfo>             
              </xs:annotation>
           </xs:element>
           <xs:element name="locationNewdate" type="xs:normalizedString" minOccurs="0" maxOccurs="1">
               <xs:annotation>
                 <xs:appinfo>
                    <alf:label>Date</alf:label>   
                 </xs:appinfo>             
              </xs:annotation>
           </xs:element>
           <xs:element name="locationNewurl" type="xs:normalizedString" minOccurs="0" maxOccurs="1">
               <xs:annotation>
                 <xs:appinfo>
                    <alf:label>More Info</alf:label>   
                 </xs:appinfo>             
              </xs:annotation>
           </xs:element>
           <xs:element name="locationNewimg" type="xs:anyURI" minOccurs="0" maxOccurs="1">
               <xs:annotation>
                 <xs:appinfo>
                    <alf:label>Thumbnail</alf:label>   
                 </xs:appinfo>             
              </xs:annotation>
           </xs:element>
       </xs:sequence>
      </xs:complexType>
      </xs:element>                 
   </xs:sequence>
   </xs:complexType>
</xs:element>
</xs:schema>

And here is the freemarker giving the error:


<#ftl ns_prefixes={"avss":"http://www.company.com/avss"}>
<#assign company_superseminars = .vars["avss:company_superseminars"]>

<html>
<body>
<#list company_superseminars["avss:seminarLocation"] as slist>             
<br>         ${slist.locationNew}
</#list>
</body>
</html

Outcomes