XMLProcessing : testing optional value in a NodeModel

thierry.henrio <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hi all,

I would like to conditionaly provide xml section if some attributes exists
in model

here is my model
<?xml version="1.0" encoding="UTF-8"?>
<connection name="sle-001" template="sle-optional.ftl" saveDir="save">
</connection>

model is parsed using dom api and a NodeModel is made out of it

here is my template
<connections>
	<connection name="${connection.@name}" url="imc:gl:slev42">
<#if (connection.@saveDir)??>
	<property name="saveDir" value="${connection.@saveDir}" />
</#if>
<#if (connection.@optional)??>
	<property name="optional" value="${connection.@optional}" />
</#if>
	</connection>
</connections>

that is, if optionnal attribute exists, there is a such property in 
output


the template processing fails on 

Error on line 7, column 44 in sle-optional.ftl
Expecting a string, date or number here, Expression connection.@optional 
is
instead a freemarker.ext.dom.NodeListModel
The problematic instruction:
----------
==> ${connection.@optional} [on line 7, column 42 in sle-optional.ftl]

did i missed something concerning null values and ?? directive behaviour ?

the first conditional on connection.@saveDir evaluates to "true", as the
attribute does exist in model


Regards, Thierry


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.