cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the XML file name in freemarker template

creddy2001
Champ in-the-making
Champ in-the-making
I am using <#assign docs = alf.parseXMLDocuments('fund_distribution', '/fund distribution/source')> for processing all the xml documents in a folder and rendering as HTML.  Also i am using <#list docs as x> </#list> for looping.

My question is how to get the file name of each xml file.

Help me out in resolving this issue. Its  very urgent.

Thanks
Chandra
6 REPLIES 6

jayjayecl
Confirmed Champ
Confirmed Champ

<#list docs as x>
${x.name}
</#list>

creddy2001
Champ in-the-making
Champ in-the-making
Thanks for your promt reply JayJayECL

But it is not working. In alfresco wiki page http://wiki.alfresco.com/wiki/WCM_Forms_Rendering, its mentioned like

parseXMLDocuments(String formName, String virtualPath)
A function returning an iterator over the root elements of the XML documents at directory given by virtualPath; this interator only contains those form instance data files generated by formName. In FreeMarker, the return value of this function is a list. In XSL, the return value is a node-set. In either case, the attribute alf:file_name is set on each element; this contains the name of the file that was parsed.


If i try to get the file name using ${alf.file_name}, its throwing non string exception. But Its working with XSL template (<xsl:value-of select="fn:replaceAll(string(@alf:file_name), '.xml', '.html')"/>).

How to get the alf:file_name attribute value using freemarker template.

Please help me out in resolving this isssue.

Thanks
Chandra

dvc
Champ in-the-making
Champ in-the-making
Anybody has resolved this issue?

I'm in the same situation.

Thank you!!!

kmehta31
Champ in-the-making
Champ in-the-making
I havent tried but I guess it should be working.
For more info go to http://www.benh.co.uk/alfresco/example-alfparsexmldocuments-using-xsl-and-freemarker/


<#list parsedPost.@@ as attr>
<#if attr?node_name = 'file_name'>
<#list attr?split(".") as name>
<#if name_has_next>
<#assign myFilename = name?lower_case>
</#if>
</#list>
</#if>
</#list>

dvc
Champ in-the-making
Champ in-the-making
Great kmehta31
it works!!

Thank you

jarrett
Champ in-the-making
Champ in-the-making
Wouldn't ${alf.form_instance_data_file_name} do the same thing? http://wiki.alfresco.com/wiki/WCM_Forms_Rendering