XML processing : how to generate several output out of one data model
thierry.henrio <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, i'm newb and this post is long
given the following xml model
<connection name="sle-001">
<property name="host" value="localhost"/>
<property name="port" value="1234"/>
</connection>
<connection name="sle-002">
<property name="host" value="localhost"/>
<property name="port" value="1234"/>
</connection>
<connection name="virtual">
<connectionRef name="sle-001"/>
<connectionRef name="sle-002"/>
</connection>
i need to generate the following files : sle-001.xml, sle-002, virtual.xml with
templates sle.ftl and virtual.ftl
STEP1 : stone
separatly, each <connection> xml content + appropriate template = correct output
that is fine
STEP2 : church
i would like to automate this : given the whole xml data model (sle-001,
sle-002, virtual) , i want to generate all 3 files
i tried
CLUMSY ??
*inject template information to the model
(for instance <connection name="sle-001" templateFile="sle.ftl">)
*make a NodeModel out of it
*visit NodeModel, and when i see a NodeModel with name and template, generate
like in STEP1
this does not work : asking model.get("name") causes npe on
java.lang.NullPointerException
at freemarker.template.utility.StringUtil.matchesName(StringUtil.java:1110)
at freemarker.ext.dom.ElementModel.matchesName(ElementModel.java:208)
at freemarker.ext.dom.DocumentModel.get(DocumentModel.java:87)
i believe the NodeModel can not be used outside Template.process method
execution, that is without Environment.getCurrentEnvironment()
ADVICE WELCOME
Is there a means of using freemarker to produce my STEP2 goal out of whole xml
data file ?
Regards
-------------------------------------------------------------------------
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/