AnsweredAssumed Answered

Vague XML Syntax error when processing JSON for atom feed

Question asked by ashex on Jun 11, 2013
Latest reply on Jun 12, 2013 by ashex
I've run into an incredibly very frustrating error. This was working without issue on Friday and I deployed it last night, found out today that the modified timestamp isn't properly formatted so I reformatted it and built a jar for testing. This error comes up:


05110009 Failed to execute script 'classpath*:alfresco/site-webscripts/org/tibco/components/dashlets/recent-docs.get.js': 05110008 SyntaxError: illegally formed XML syntax (jar:file:/usr/share/tomcat6/shared/lib/recent-docs.jar!/alfresco/site-webscripts/org/tibco/components/dashlets/recent-docs.get.js#20(eval)#1)

So I revert the changes and the exact same error is displayed. Can anyone tell me why I'm receiving this?

Here's an example of the JSON output generated by the repo webscript:


{
"documents":
    [
        {
            "site": "swsdp",
            "nodeRef": "workspace://SpacesStore/1a0b110f-1e09-4ca2-b367-fe25e4964a4e",
            "id": "1a0b110f-1e09-4ca2-b367-fe25e4964a4e",
            "name": "Project Contract.pdf",
            "title": "Project Contract for Green Enery",
            "creator": "abeecher",
            "description": "Conract for the Green Energy project",
            "categories": [
                    ],
            "created": "15 Feb 2011 21:26:54 PM (UTC)",
            "modified": "14 Jun 2011 10:28:54 AM (UTC)"
        },
        {
            "site": "swsdp",
            "nodeRef": "workspace://SpacesStore/05dedd34-9d9d-48d9-9af6-c81b555541c9",
            "id": "05dedd34-9d9d-48d9-9af6-c81b555541c9",
            "name": "WebSiteReview.mp4",
            "title": "WebSiteReview.mp4",
            "creator": "abeecher",
            "description": "This is a video of the mock up to show the planned structure for the new web site.",
            "categories": [
                    ],
            "created": "08 Mar 2011 10:35:10 AM (UTC)",
            "modified": "08 Mar 2011 10:37:43 AM (UTC)"
        }
    ]
}



And the share webscript stuff

recent-docs.get.desc.xml

<webscript>
  <shortname>Recently Modified Documents</shortname>
  <description>Retrieve Recently Modified content for a site</description>
  <url>/components/recent-docs?site={site}</url>
  <arg>
    <shortname>site</shortname>
    <description><![CDATA[site name]]></description>
  </arg>
  <format default="html">argument</format>
  <authentication>user</authentication>
  <transaction>required</transaction>
  <cache>
    <neverCache>false</neverCache>
    <mustRevalidate/>
  </cache>
</webscript>

recent-docs.get.js

function main()
{
    for (var arg in args)
    {
      if (arg == "site")
      {
        model.site = args[arg];
      }
    }
        // call the repository to get recent documents
        var connector = remote.connect("alfresco");
        var json = connector.call("/recent-docs?site=" + escape(model.site));
        if (json.status == 200)
        {
                obj = eval("(" + json + ")");
                model.docs = obj["documents"];
        }
        else
        {
                obj = eval("(" + json + ")");
                obj.name = "Error";
                model.docs = obj;
        }

}

main()


recent-docs.get.atom.ftl

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <generator version="${server.version}">Alfresco (${server.edition})</generator>
  <link rel="self" href="${absurl(url.full)?xml}" />
  <id>${absurl(url.full)?xml}</id>
  <title>Site: ${site}</title>
  <subtitle>Alfresco Recently Modified Documents</subtitle> 
  <updated>${xmldate(date)}</updated>
  <icon>${absurl(url.context)}/res/themes/default/images/app-logo-48.png</icon>
<#list docs as child>
  <entry xmlns='http://www.w3.org/2005/Atom'>
    <title>${child.name?html}</title>
    <link href="${absurl(url.context)}/page/document-details?nodeRef=${child.nodeRef}"/>
    <id>urn:uuid:${child.id}</id>
    <updated>${child.modified}</updated>
    <summary>
       ${msg("feed.uploaded", child.name, child.creator)}<br />
    <#if child.modifier?exists>${msg("feed.modified", child.modified, child.modifier)}<br /></#if>
    ${child.description!""}<br />
     <#if child.categories[0]?exists>
     ${msg("feed.categories")} <#list child.categories as category> ${category.name}<#if category_has_next>, </#if></#list></#if><br />
    </summary>
    <author>
      <name>${child.creator}</name>
    </author>
  </entry>
</#list>
</feed>



I've been hacking at this trying various things without success, going to try turning everything into a string or something next.

Outcomes