cancel
Showing results for 
Search instead for 
Did you mean: 

Freemarker Error on child nodes

junderwood
Champ in-the-making
Champ in-the-making
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
2 REPLIES 2

junderwood
Champ in-the-making
Champ in-the-making
OK after more research, this returns the element children as long as there is only 1 child set.  If there are more than 1 it blows up with:

error regenerating rendition using company_superseminars.ftl: freemarker.template.TemplateException: Expected node model. company_superseminars["avss:seminarLocation"] evaluated instead to freemarker.ext.dom.NodeListModel on line 56, column 22 in freemarker_template.


<#assign seq = company_superseminars["avss:seminarLocation"]/>
              <#list seq?children as c>              
                  
                 ${c}                 

              </#list>


Any ideas?

junderwood
Champ in-the-making
Champ in-the-making
Thanks to ddekany over at the freemarker forum, <#list seq.* as c> is what works in case anyone else has trouble.