Alfresco webscript FTL returning XML throws the entity nbsp was referenced but not declared exception
FTL Structure:
<?xml version="1.0" encoding="UTF-8"?>
<properties>
<node>
<name>${node.name}</name>
<id>${node.id}</id>
<path>${node.displayPath}/${node.name}</path>
<#if node.isContainer>
<#assign isFolder="true">
<#assign size="">
<#assign encoding="">
<#assign mimetype="">
<#assign content="">
<#else>
<#assign isFolder="false">
<#assign size=node.size/1024 + " KB">
<#assign encoding=node.properties.content.encoding!>
<#assign mimetype=node.properties.content.mimetype!>
<#assign content=node.content>
</#if>
<icon16>${node.icon16}</icon16>
<icon32>${node.icon32}</icon32>
<isFolder>${isFolder}</isFolder>
<title>${node.properties.title!}</title>
<description>${node.properties.description!}</description>
<author>${node.properties.author!}</author>
<size>${size}</size>
<creator>${node.properties.creator}</creator>
<created>${node.properties.created?datetime}</created>
<modifier>${node.properties.modifier}</modifier>
<modified>${node.properties.modified?datetime}</modified>
<editinline>${node.properties.editInline!}</editinline> <encoding>${encoding}</encoding>
<mimetype>${mimetype}</mimetype>
<content>${content}</content>
<#if node.properties["sk:extranetId"]?exists>
<extranetId>${node.properties["sk:extranetId"]?string}</extranetId>
<#else>
<extranetId>Extranet Id not found</extranetId>
</#if>
<#if node.properties["sk:templateId"]?exists>
<templateId>${node.properties["sk:templateId"]?string}</templateId>
<#else>
<templateId>Template Id not found</templateId>
</#if>
<#if node.properties["sk:docstatus"]?exists>
<docstatus>${node.properties["sk:docstatus"]?string}</docstatus>
<#else>
<docstatus>Template Id not found</docstatus>
</#if>
<#if node.properties["sk:pageId"]?exists>
<containerId>${node.properties["sk:pageId"]?string}</containerId>
<#else>
<containerId>${node.properties["sk:extranetId"]?string}</containerId>
</#if>
</node>
</properties>
<properties>
<node>
<name>${node.name}</name>
<id>${node.id}</id>
<path>${node.displayPath}/${node.name}</path>
<#if node.isContainer>
<#assign isFolder="true">
<#assign size="">
<#assign encoding="">
<#assign mimetype="">
<#assign content="">
<#else>
<#assign isFolder="false">
<#assign size=node.size/1024 + " KB">
<#assign encoding=node.properties.content.encoding!>
<#assign mimetype=node.properties.content.mimetype!>
<#assign content=node.content>
</#if>
<icon16>${node.icon16}</icon16>
<icon32>${node.icon32}</icon32>
<isFolder>${isFolder}</isFolder>
<title>${node.properties.title!}</title>
<description>${node.properties.description!}</description>
<author>${node.properties.author!}</author>
<size>${size}</size>
<creator>${node.properties.creator}</creator>
<created>${node.properties.created?datetime}</created>
<modifier>${node.properties.modifier}</modifier>
<modified>${node.properties.modified?datetime}</modified>
<editinline>${node.properties.editInline!}</editinline> <encoding>${encoding}</encoding>
<mimetype>${mimetype}</mimetype>
<content>${content}</content>
<#if node.properties["sk:extranetId"]?exists>
<extranetId>${node.properties["sk:extranetId"]?string}</extranetId>
<#else>
<extranetId>Extranet Id not found</extranetId>
</#if>
<#if node.properties["sk:templateId"]?exists>
<templateId>${node.properties["sk:templateId"]?string}</templateId>
<#else>
<templateId>Template Id not found</templateId>
</#if>
<#if node.properties["sk:docstatus"]?exists>
<docstatus>${node.properties["sk:docstatus"]?string}</docstatus>
<#else>
<docstatus>Template Id not found</docstatus>
</#if>
<#if node.properties["sk:pageId"]?exists>
<containerId>${node.properties["sk:pageId"]?string}</containerId>
<#else>
<containerId>${node.properties["sk:extranetId"]?string}</containerId>
</#if>
</node>
</properties>
Why???(Solution)
Just wrap it with the right DTD something like below,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties[
<!ELEMENT node (name, id, path, icon16, icon32, isFolder, title, description, author, size, creator, created, modifier, modified, editinline, encoding, mimetype, content, extranetId, templateId, docstatus, containerId)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT path (#PCDATA)>
<!ELEMENT icon16 (#PCDATA)>
<!ELEMENT icon32 (#PCDATA)>
<!ELEMENT isFolder (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT creator (#PCDATA)>
<!ELEMENT created (#PCDATA)>
<!ELEMENT modifier (#PCDATA)>
<!ELEMENT modified (#PCDATA)>
<!ELEMENT editinline (#PCDATA)>
<!ELEMENT mimetype (#PCDATA)>
<!ELEMENT content (#PCDATA)>
<!ELEMENT extranetId (#PCDATA)>
<!ELEMENT templateId (#PCDATA)>
<!ELEMENT docstatus (#PCDATA)>
<!ELEMENT containerId (#PCDATA)>
<!ENTITY nbsp " ">
]>
<properties>
<node>
<name>${node.name}</name>
<id>${node.id}</id>
<path>${node.displayPath}/${node.name}</path>
<#if node.isContainer>
<#assign isFolder="true">
<#assign size="">
<#assign encoding="">
<#assign mimetype="">
<#assign content="">
<#else>
<#assign isFolder="false">
<#assign size=node.size/1024 + " KB">
<#assign encoding=node.properties.content.encoding!>
<#assign mimetype=node.properties.content.mimetype!>
<#assign content=node.content>
</#if>
<icon16>${node.icon16}</icon16>
<icon32>${node.icon32}</icon32>
<isFolder>${isFolder}</isFolder>
<title>${node.properties.title!}</title>
<description>${node.properties.description!}</description>
<author>${node.properties.author!}</author>
<size>${size}</size>
<creator>${node.properties.creator}</creator>
<created>${node.properties.created?datetime}</created>
<modifier>${node.properties.modifier}</modifier>
<modified>${node.properties.modified?datetime}</modified>
<editinline>${node.properties.editInline!}</editinline> <encoding>${encoding}</encoding>
<mimetype>${mimetype}</mimetype>
<content>${content}</content>
<#if node.properties["sk:extranetId"]?exists>
<extranetId>${node.properties["sk:extranetId"]?string}</extranetId>
<#else>
<extranetId>Extranet Id not found</extranetId>
</#if>
<#if node.properties["sk:templateId"]?exists>
<templateId>${node.properties["sk:templateId"]?string}</templateId>
<#else>
<templateId>Template Id not found</templateId>
</#if>
<#if node.properties["sk:docstatus"]?exists>
<docstatus>${node.properties["sk:docstatus"]?string}</docstatus>
<#else>
<docstatus>Template Id not found</docstatus>
</#if>
<#if node.properties["sk:pageId"]?exists>
<containerId>${node.properties["sk:pageId"]?string}</containerId>
<#else>
<containerId>${node.properties["sk:extranetId"]?string}</containerId>
</#if>
</node>
</properties>
Cheers!!
<!DOCTYPE properties[
<!ELEMENT node (name, id, path, icon16, icon32, isFolder, title, description, author, size, creator, created, modifier, modified, editinline, encoding, mimetype, content, extranetId, templateId, docstatus, containerId)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT path (#PCDATA)>
<!ELEMENT icon16 (#PCDATA)>
<!ELEMENT icon32 (#PCDATA)>
<!ELEMENT isFolder (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT creator (#PCDATA)>
<!ELEMENT created (#PCDATA)>
<!ELEMENT modifier (#PCDATA)>
<!ELEMENT modified (#PCDATA)>
<!ELEMENT editinline (#PCDATA)>
<!ELEMENT mimetype (#PCDATA)>
<!ELEMENT content (#PCDATA)>
<!ELEMENT extranetId (#PCDATA)>
<!ELEMENT templateId (#PCDATA)>
<!ELEMENT docstatus (#PCDATA)>
<!ELEMENT containerId (#PCDATA)>
<!ENTITY nbsp " ">
]>
<properties>
<node>
<name>${node.name}</name>
<id>${node.id}</id>
<path>${node.displayPath}/${node.name}</path>
<#if node.isContainer>
<#assign isFolder="true">
<#assign size="">
<#assign encoding="">
<#assign mimetype="">
<#assign content="">
<#else>
<#assign isFolder="false">
<#assign size=node.size/1024 + " KB">
<#assign encoding=node.properties.content.encoding!>
<#assign mimetype=node.properties.content.mimetype!>
<#assign content=node.content>
</#if>
<icon16>${node.icon16}</icon16>
<icon32>${node.icon32}</icon32>
<isFolder>${isFolder}</isFolder>
<title>${node.properties.title!}</title>
<description>${node.properties.description!}</description>
<author>${node.properties.author!}</author>
<size>${size}</size>
<creator>${node.properties.creator}</creator>
<created>${node.properties.created?datetime}</created>
<modifier>${node.properties.modifier}</modifier>
<modified>${node.properties.modified?datetime}</modified>
<editinline>${node.properties.editInline!}</editinline> <encoding>${encoding}</encoding>
<mimetype>${mimetype}</mimetype>
<content>${content}</content>
<#if node.properties["sk:extranetId"]?exists>
<extranetId>${node.properties["sk:extranetId"]?string}</extranetId>
<#else>
<extranetId>Extranet Id not found</extranetId>
</#if>
<#if node.properties["sk:templateId"]?exists>
<templateId>${node.properties["sk:templateId"]?string}</templateId>
<#else>
<templateId>Template Id not found</templateId>
</#if>
<#if node.properties["sk:docstatus"]?exists>
<docstatus>${node.properties["sk:docstatus"]?string}</docstatus>
<#else>
<docstatus>Template Id not found</docstatus>
</#if>
<#if node.properties["sk:pageId"]?exists>
<containerId>${node.properties["sk:pageId"]?string}</containerId>
<#else>
<containerId>${node.properties["sk:extranetId"]?string}</containerId>
</#if>
</node>
</properties>
Cheers!!