cancel
Showing results for 
Search instead for 
Did you mean: 

WebForm Output Path Expressions - behaviour

tommorris
Champ in-the-making
Champ in-the-making
The ability to use a Freemarker expression in the output-path is very useful, but it's behaviour is interesting.

1)
For example: ${name} is the entered name of the form, so if you named the form 'mydata' then the following expression:
/${webapp}/mysubfolder/${name}.xml
…creates the file '/mywebapp/mysubfolder/mydata.xml'

and the template can use a similar path
/${webapp}/mysubfolder/${name}.html
…creates the file '/mywebapp/mysubfolder/mydata.html'


However, if the data path was more like:
/${webapp}/mysubfolder/myprefix_${name}.xml
…creating the file '/mywebapp/mysubfolder/myprefix_mydata.xml'

then the template output path that looks like:
/${webapp}/mysubfolder/${name}.html
…creates the file '/mywebapp/mysubfolder/myprefix_mydata.html'

Notice that I did not provide a prefix for the second expression, but it seemed to re-assign the value of ${name} to be the calculated named of the XML and not the form value.

This has turned-out to be quite useful, although surprising. What if I didn't want my rendition to have the prefix - how do i get the form name?

2)
Other interesting behaviour is that the XML output path could be complex and absolute such as:
/${webapp}/${xml['mydata/mycategory']}/myprefix_${name}.xml
…creating the file '/mywebapp/mycategoryvalue/myprefix_mydata.xml'

But the template/rendition output path could be as simple as :
${name}.jsp
but the created file goes into the same dynamically determined location as the XML. Like this:
…creates the file '/mywebapp/mycategoryvalue/myprefix_mydata.html'

3)
If you try to reproduce the above outputpath of the XML for the rendition, like this:
/${webapp}/${xml['mydata/mycategory']}/myprefix_${name}.html
…then you get a freemarker error. Is the 'xml' node available to renditions? There's only one related XML, so you'd think that this would be placed into the freemarker model. Is this just my defect, or is it common to the implementation?

Can anyone elaborate on this and the Freemarker rules for outputpath?

Many thanks,
Tom
6 REPLIES 6

tommorris
Champ in-the-making
Champ in-the-making
Did that make sense?
Anyone?

alfresco_gopesh
Champ in-the-making
Champ in-the-making
Output path pattern:
${xml['/*[name()="languageoutput:myform"]/*[name()="languageoutput:language1"]/*[name()="languageoutput:value"]']}/${name}.xml




For this Sample xsd:



<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"   xmlns:languageoutput="http://www.alfresco.org/alfresco/languageoutput"

           targetNamespace="http://www.alfresco.org/alfresco/languageoutput" elementFormDefault="qualified">

                <xs:complexType name="language">

                                <xs:sequence>

                                                <xs:element name="key" type="xs:normalizedString"/>

                                                <xs:element name="value" type="xs:anyURI"/>

                                                <xs:element name="languageName" type="xs:normalizedString"/>

                                                <xs:element name="publish" type="xs:boolean" minOccurs="0" default="true"/>

                                </xs:sequence>                                         

                </xs:complexType>

                <xs:element name="myform">

                                <xs:complexType>

                                                <xs:sequence>

                                                                <xs:element name="language1" type="languageoutput:language" minOccurs="0" maxOccurs="unbounded"/>

                                                </xs:sequence>

                                </xs:complexType>

                </xs:element>

</xs:schema>


it works fine for me….thanks to the jira for the answer

tommorris
Champ in-the-making
Champ in-the-making
Hello gopesh,
Does that mean you experience the same behaviour as I do, for point 1) and 2)?

tommorris
Champ in-the-making
Champ in-the-making
Is there an alfresco engineer with an insight for this area?

tommorris
Champ in-the-making
Champ in-the-making
alfresco?

tommorris
Champ in-the-making
Champ in-the-making
Looks like we found the answer to point 3) above.

Although something like the following works for XML creation:
/${xml['press_release/title']}/myfile.xml

It needs the name-space prefix for rendition output paths, like this:
/${xml['prSmiley Tongueress_release/pr:title']}/myfile.html

I think this is what Gopesh was trying to tell me earlier in this thread…

The general behaviour described in my other points are still interestingly subtle.