cancel
Showing results for 
Search instead for 
Did you mean: 

Freemarker breaks on folders starting with a number

simon
Champ in-the-making
Champ in-the-making
Hi Alf,

I have a Freemarker template with the following Lucene search query:
<#list companyhome.childrenByLuceneSearch["(PATH:\"/app:company_home/cm:Extranet/cm:Test//*\") AND (TYPE:\"{http://www.alfresco.org/model/content/1.0}folder\" NOT TYPE:\"{http://www.alfresco.org/model/content/1.0}systemfolder\")"] as child>
[…]
<#/list>
This works fine for folders starting with an alphanumeric characters but if a folder starts with a number the template breaks (lots of our folders start with 2006_somename). The folder works fine in the web client, CIFS and all other interfaces but Freemarker fails to recognize this folder.

It has something to do with the conversion of the first character, when I look in the node browser to the same space I get this:
{http://www.alfresco.org/model/content/1.0}_x0037_005_x0020_PTC (web client view shows "2005 PTC")
I'm replacing the spaces with _x0020_ but should I replace the first number as wel? "Replace the first number and only the first number if the spaces starts with this number to their strange value" doesn't sound like the ideal solution.
2 REPLIES 2

andy
Champ on-the-rise
Champ on-the-rise
Hi

PATH uses ISO9075 to encode what are in effect XML element names.
This is consistent with XPATH use.

See the classes ISO9075 and ISO9075Test.

I am not sure if there is any helper function in the freemarker model to support this encoding…..I will have a look ….

Regards

Andy

kevinr
Star Contributor
Star Contributor
The qname encoded path for a space has been added to the 1.4 freemarker API:

qnamePath
    returns the QName based Path to the node. This is useful for building Lucene PATH: style queries that constrain to a path location.

http://wiki.alfresco.com/wiki/Template_Guide#Extended_TemplateNode_Model_API

Thanks,

Kevin