Friday, December 28, 2007

Alfresco Web Forms

Working on some XSL transformations today I ran into some trouble trying to get a document generated by a different WebForm. The logic is as follows:

Header WebForm --produced--> Header1.xml --under-->/ROOT/content
Main WebForm --looked for--> Header1.xml --produced--> Main.xml --under-->/ROOT

I keep running into the same exception below:

14:23:09,321 ERROR [org.alfresco.web.ui.common.Utils] Error generating rendition using main.xsl: javax.xml.transform.TransformerException: java.lang.NullPointerException
org.alfresco.web.forms.RenderingEngine$RenderingException: javax.xml.transform.TransformerException: java.lang.NullPointerException

caused by this line in my XSL file:

<xsl:variable name="header_file" select="alf:parseXMLDocument($header_location)"/>

So my guess was that it wasn't finding the file referenced by $header_location, which value was "Header1.xml" by the way.

After some debugging it worked when both Header WebForm and Main WebForm Output path pattern was the same. The Output path pattern is configured when you add and configure the Webform to the Web Project. So my guess is that when I was using parseXMLDocument($header_location) it look for a file with a path relative to the Output path pattern.

So for future reference the parameter to parseXMLDocument(location) shoul be relative to your ROOT web project folder. For example, suppose you have a Webform generate content to ROOT/content and you want to grab a file under that location (i.e. Header.xml) from a file generated under a diferent directory (i.e. ROOT) then you would get the file like this parseXMLDocument(content/Header.xml).

Hope you find this info useful. God knows I was searching for a post like this an hour ago :).

Happy Holidays!

1 comment:

Unknown said...

Hello.. I was wondering if you had used the assign alf.parseXMLDocuments('','') function. If so, have you had any luck with it? I am having an issue specifying the virtual_path arguement, i.e. the second argument. If I use '/' the function works, anything else like /pressrelease/ and the functions throws an exception.

Any help is appreciated... Also, good article regarding alf.parseXMLDocument.