cancel
Showing results for 
Search instead for 
Did you mean: 

Vague XML Syntax error when processing JSON for atom feed

ashex
Champ in-the-making
Champ in-the-making
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.

3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
make sure you have not added any special character in the javascript file during editing.
And as you are saying earlier it was working  where you have done the changes?

ashex
Champ in-the-making
Champ in-the-making
I'm fairly certain I didn't, i'm making sure I'm saving everything as UTF-8 without BOM. I went back through and checked for any bad syntax on the js and didn't find anything (but I'm not a javascript expert).

To clarify, I have a two node cluster, I uploaded the new jar with the changes to the atom template onto Node 1 and got the syntax error. On node 2 the atom feed generates just fine (albeit with the wrong date format) so i copied the jar from there on to Node 1. After doing that I'm still getting the syntax error.

ashex
Champ in-the-making
Champ in-the-making
I modified the atom template to run on the repo side and the result is XML valid so at least that's working. On the share side I'm still seeing the syntax error which is problematic as I plan to build a dashlet with this.