cancel
Showing results for 
Search instead for 
Did you mean: 

unterminated string literal because of an wordwrap

ridmess
Champ in-the-making
Champ in-the-making
Hallo,

I develop a webscript, wich looks in the repository und get information from my contents,  the result of te webscript looks like this snipts:
{

   newsl: [
      {
        fileName: "gdfgioudfz.xml"
        ,
      titel: "rewr"
      ,
      body: "<p>rwerewr</p>
<p> </p>"
            }
      ,
      {
        fileName: "ServiceorientierteArchitekturen .xml"
        ,
      titel: "Serviceorientierte Architektur (SOA)"
      ,
      body: "<p>ist derzeit einer der meistverwendeten, aber auch meistdiskutierten Begriffe in der Informationsverarbeitung. Dabei zeigt sich,.</p>
<p> </p>"
          }
      ,
      {
        fileName: "test.xml"
        ,
      titel: "test"
      ,
      body: "<p>hier ist nur ein test</p>
<p> </p>"
   
      }
      
   ]
   
}
the Problem is, Surf can not consume this webscript because of wordwrap in the Json result:
 body: "<p>hier ist nur ein test</p>
<p> </p>"

my Json looks so:
newsl: [
<#list folder.children as d>
   <#if d.mimetype = "text/xml">
      <#assign dom=d.xmlNodeModel>
      {
        fileName: "${d.name}"
        ,
      titel: "${dom.news.title}"
      ,
     
      body: "${dom.news.body}"
  
            }
      <#if d_has_next>,</#if>
   </#if>
</#list>
   ]
und when I execute this webscript on the server side, i don't get any error, but when Surf consume this webscript Iget this error:
Alfresco     Web Script Status 500 - Internal Error

The Web Script /surf/service/newsListe has responded with a status of 500 - Internal Error.

500 Description:   An error inside the HTTP server which prevented it from fulfilling the request.

Message:   Failed to load script 'org.alfresco.web.scripts.LocalFileSystemStore$LocalFileSystemStoreScriptContent@ef43b1': SyntaxError: unterminated string literal (C:deploy/alfresco/site-webscripts/newsListe.get.js#8(eval)#10)
   
Exception:   org.mozilla.javascript.EcmaError - SyntaxError: unterminated string literal (C:/alfresco/site-webscripts/newsListe.get.js#8(eval)#10)

Thanks for your help.
Ridmess
1 REPLY 1

ridmess
Champ in-the-making
Champ in-the-making
the solution was, I needed to convert the body to String, see the follwing body  parameter
newsl: [
<#list folder.children as d>
   <#if d.mimetype = "text/xml">
      <#assign dom=d.xmlNodeModel>
      {
        fileName: "${d.name}"
        ,
      titel: "${dom.testNews.title}"
      ,
    
      body: "${dom.testNews.body?j_string}"
  
            }
      <#if d_has_next>,</#if>
   </#if>
</#list>
   ]

Please colse it Smiley Very Happy