cancel
Showing results for 
Search instead for 
Did you mean: 

Expression simple.string is instead a freemarker.ext.dom.No

darsat_8
Champ in-the-making
Champ in-the-making
Hi All,
i m suffering from Freemarker template..
i got this error several times when i creating content in web form…

freemarker_template Expecting a string, date or number here, Expression simple.string is instead a freemarker.ext.dom.NodeListModel


i have very little knowledge about freemarker template…
plz anyone know guide me how to solve this error??

I really appreciate to your reply.
Thanks in advance
18 REPLIES 18

dgenard
Champ on-the-rise
Champ on-the-rise
I've fixed such errors by adding this line on top (first line) of your freemarker template file
<#ftl ns_prefixes={"D", "http://www.alfresco.org/training"}>
It did solve the problem with Alfresco 2.1.1E
Denis

darsat_8
Champ in-the-making
Champ in-the-making
Hi dgenard
Even i tried wht u sayed me bt still i suffering of tht prblm..
any other solution you knw for avoid this exception??

dgenard
Champ on-the-rise
Champ on-the-rise
I think that you'll have to replace the "http://www.alfresco.org/training" part by your default namespace. I mean the namespace specified by in
targetNamespace attribute of the matching xsd.
In example, here is the xsd root element of my form.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:trn="http://www.alfresco.org/training"
           targetNamespace="http://www.alfresco.org/training"
           elementFormDefault="qualified">
Denis

darsat_8
Champ in-the-making
Champ in-the-making
Hi dgenard…
rt nw i got another error :    * Error generating rendition using LaptopFreeMarker51.ftl: Encountered "-" at line 2, column 15. Was expecting one of: "=" … "in" … ">" …

   

      
by the way i m vry confuse ..
what i want do exactly for solving this prblm..

   
here i give you all four  files to you (xsd,xsl,xml and ftl file).
plz observe these file and tell be when i wrong..

xsd file
[<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Laptop5Feb.xsl"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr"
           targetNamespace="http://www.alfresco.org/alfresco/pr"
           elementFormDefault="qualified">
  <xs:simpleType name="Processor">
    <xs:restriction base="xs:normalizedString">
      <xs:enumeration value="Pentium4"/>
      <xs:enumeration value="celeron"/>
      <xs:enumeration value="AMDAthlon"/>
      <xs:enumeration value="DualCore"/>
     </xs:restriction>
  </xs:simpleType>
  <xs:element name="press-release">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="CustomerName" type="xs:normalizedString"/>
        <xs:element name="E-mail" type="xs:normalizedString"/>
        <xs:element name="city" type="xs:normalizedString"/>
   <xs:element name="CompanyName" type="xs:normalizedString"/>
   <xs:element name="Processor" type="prSmiley Tonguerocessor"/>
   <xs:element name="Ram" type="xs:normalizedString"/>
   <xs:element name="ScreenSize" type="xs:normalizedString"/>
   <xs:element name="HardDisk" type="xs:normalizedString"/>
   <xs:element name="DVDWriter" type="xs:normalizedString"/>
   <xs:element name="ExtraFeatures" type="xs:normalizedString"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
]

XSL file

[<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr">
<xslSmiley Surprisedutput method="html"  encoding="UTF-8" indent="yes"/>
<xsl:variable name="CustName" select="/prSmiley Tongueress-release/pr:CustomerName"/>
<xsl:variable name="Email" select="/prSmiley Tongueress-release/pr:E-mail"/>
<xsl:variable name="city" select="/prSmiley Tongueress-release/pr:city"/>
<xsl:variable name="CompanyName" select="/prSmiley Tongueress-release/pr:CompanyName"/>
<xsl:variable name="Processor" select="/prSmiley Tongueress-release/prSmiley Tonguerocessor"/>
<xsl:variable name="Ram" select="/prSmiley Tongueress-release/pr:Ram"/>
<xsl:variable name="ScreenSize" select="/prSmiley Tongueress-release/prSmiley FrustratedcreenSize"/>
<xsl:variable name="HardDisk" select="/prSmiley Tongueress-release/pr:HardDisk"/>
<xsl:variable name="DVDWriter" select="/prSmiley Tongueress-release/prSmiley Very HappyVDWriter"/>
<xsl:variable name="ExtraFeatures" select="/prSmiley Tongueress-release/pr:ExtraFeatures"/>
<xsl:template match="/prSmiley Tongueress-release">
   <B><xsl:text>Customer Name  :</xsl:text></B>
   <xsl:value-of select="$CustName"/><br/>
   <B><xsl:text>E-mail  :</xsl:text></B>
   <xsl:value-of select="$Email"/><br/>
   <B><xsl:text>City  :</xsl:text></B>
   <xsl:value-of select="$city"/><br/>
   <B><xsl:text>Company Name  :</xsl:text></B>
   <xsl:value-of select="$CompanyName"/><br/>
   <B><xsl:text>Processor  :</xsl:text></B>
   <xsl:value-of select="$Processor"/><br/>
   <B><xsl:text>Ram  :</xsl:text></B>
   <xsl:value-of select="$Ram"/><br/>
   <B><xsl:text>Screen Size  :</xsl:text></B>
   <xsl:value-of select="$ScreenSize"/><br/>
   <B><xsl:text>HardDisk  :</xsl:text></B>
   <xsl:value-of select="$HardDisk"/><br/>
   <B><xsl:text>DVD Writer(Yes/No)  :</xsl:text></B>
   <xsl:value-of select="$DVDWriter"/><br/>
   <B><xsl:text>Extra Features  :</xsl:text></B>
   <xsl:value-of select="$ExtraFeatures"/><br/>
</xsl:template>
</xsl:stylesheet>]


XML File

[<alfrescoSmiley Tongueress-release xmlns:alfresco="http://www.alfresco.org/alfresco">
<alfresco:CustomerName></alfresco:CustomerName>
<alfresco:E-mail></alfresco:E-mail>
<alfresco:city></alfresco:city>
<alfresco:CompanyName></alfresco:CompanyName>
<alfrescoSmiley Tonguerocessor></alfrescoSmiley Tonguerocessor>
<alfresco:Ram></alfresco:Ram>
<alfrescoSmiley FrustratedcreenSize></alfrescoSmiley FrustratedcreenSize>
<alfresco:HardDisk></alfresco:HardDisk>
<alfrescoSmiley Very HappyVDWriter></alfrescoSmiley Very HappyVDWriter>
<alfresco:ExtraFeatures></alfresco:ExtraFeatures>
</alfrescoSmiley Tongueress-release>]

FTL File
[<#ftl ns_prefixes={"si":"http://www.alfresco.org/alfresco/press-release"}>
<#assign press-release = .vars["siSmiley Tongueress-release"]>
<html>
   <body>
   ${press-release["si:CustomerName"]}
   ${press-release["si:E-mail"]}
   ${press-release["si:city"]}
   ${press-release["si:CompanyName"]}
   ${press-release["siSmiley Tonguerocessor"]}
   ${press-release["si:Ram"]}
   ${press-release["siSmiley FrustratedcreenSize"]}
   ${press-release["si:HardDisk"]}
   ${press-release["siSmiley Very HappyVDWriter"]}
   ${press-release["si:ExtraFeatures"]}
   </body>
</html>




]

dgenard
Champ on-the-rise
Champ on-the-rise
Well, it looks like things have progressed.
The current error seems to tell that the '-' character is not valid in a freemarker variable name.
Try rename 'press-release' variable into something like 'pressRelease'.

Denis

darsat_8
Champ in-the-making
Champ in-the-making
Hi dgenard,
i made changes as per you sayed bt stil i got this error at time when we submitting content in web form:-
Error generating rendition using LaptopFreeMarker6.ftl: freemarker.core.NonStringException: Error on line 5, column 6 in freemarker_template Expecting a string, date or number here, Expression pressrelease["si:CustomerName"] is instead a freemarker.ext.dom.NodeListModel

here i again give my FTL file to you for ur observation..
plz guide me hw to resolve this critical  issue …
it's vry urgent for me…

LaptopFreeMarker6.ftl


<#ftl ns_prefixes={"si":"http://www.alfresco.org/alfresco/pressrelease"}>
<#assign pressrelease = .vars["si:pressrelease"]>
<html>
   <body>
   ${pressrelease["si:CustomerName"]}
   ${pressrelease["si:E-mail"]}
   ${pressrelease["si:city"]}
   ${pressrelease["si:CompanyName"]}
   ${pressrelease["si:Processor"]}
   ${pressrelease["si:Ram"]}
   ${pressrelease["si:ScreenSize"]}
   ${pressrelease["si:HardDisk"]}
   ${pressrelease["si:DVDWriter"]}
   ${pressrelease["si:ExtraFeatures"]}
   </body>
</html>

I really appreciate for your reply..
thanks…

dgenard
Champ on-the-rise
Champ on-the-rise
This is probably a namespace issue :
The FTL should start with
<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/pr"}>
where the "D" stands for Freemarker Default namespace I think, and should not be changed.
The second part (the namespace) should then match the targetNamespace of your XSD, which seems to be "http://www.alfresco.org/alfresco/pr" in your case.

Denis

darsat_8
Champ in-the-making
Champ in-the-making
Hi dgenard,
first of all thanks to you for continue to support me for solving this prblm..
after tht i again made changes in  names pace:-
still i got this error:-
Error generating rendition using Freemarker62feb.ftl: freemarker.core.NonStringException: Error on line 4, column 6 in freemarker_template Expecting a string, date or number here, Expression CustomerName.string is instead a freemarker.ext.dom.NodeListModel

updated new files are as follows:-
ftl file

<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/pressrelease"}>
<html>
   <body>
   ${CustomerName.string}
   ${E-mail.string}
   ${city.string}
   ${CompanyName.string}
   ${Processor.string}
   ${Ram.string}
   ${ScreenSize.string}
   ${HardDisk.string}
   ${DVDWriter.string}
   ${ExtraFeatures.string}
   </body>
</html>

xsd file


<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Laptop6Feb.xsl"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:pr="http://www.alfresco.org/alfresco/pr"
           targetNamespace="http://www.alfresco.org/alfresco/pr"
           elementFormDefault="qualified">
  <xs:simpleType name="Processor">
    <xs:restriction base="xs:normalizedString">
      <xs:enumeration value="Pentium4"/>
      <xs:enumeration value="celeron"/>
      <xs:enumeration value="AMDAthlon"/>
      <xs:enumeration value="DualCore"/>
     </xs:restriction>
  </xs:simpleType>
  <xs:element name="pressrelease">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="CustomerName" type="xs:normalizedString"/>
        <xs:element name="E-mail" type="xs:normalizedString"/>
        <xs:element name="city" type="xs:normalizedString"/>
   <xs:element name="CompanyName" type="xs:normalizedString"/>
   <xs:element name="Processor" type="pr:Processor"/>
   <xs:element name="Ram" type="xs:normalizedString"/>
   <xs:element name="ScreenSize" type="xs:normalizedString"/>
   <xs:element name="HardDisk" type="xs:normalizedString"/>
   <xs:element name="DVDWriter" type="xs:normalizedString"/>
   <xs:element name="ExtraFeatures" type="xs:normalizedString"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


thanks..

dgenard
Champ on-the-rise
Champ on-the-rise
Don't change the xsd. The template should look like this :
<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/pr"}> 
<html>
   <body>
   ${pressrelease.CustomerName}
   ${pressrelease.E-mail}
   …
Denis