Re: [FreeMarker-user] freemarker xml/xslt functions
Generates text that depends on changing data (like dynamic HTML).
Brought to you by:
revusky
|
From: Russell S. <rus...@ho...> - 2005-12-22 11:42:31
|
> > public class Helper {
> > public Document load(String xml) {
> > File inFile= new File(xml);
> > Document docNode = builder.parse(inFile);
> >
> > TemplateModel document = new NodeListModel(docNode);
> > TemplateNodeModel docNodeModel =
>NodeModel.wrap(docNode);
> > HashMap root = new HashMap();
> > root.put("document", document);
>
>Why do you modify the root? Just return it. It will be the value of an
>method call expression.
It was copied from the FreeMarkerXmlTask, I wanted to make sure, that if i
created a class that I had to rap the document in a NodeListModel. Is it the
NodeListModel that allows the template to say stuff like
.node.mytopnodename.mynestednodename.mynestedentity
I've worked with Anakia, and with that you dom through the doc with
getSibling and getNextSibling which isn't as reminder friendly.
>Something like this. BTW the commonly used "tools" can added at the
>Configuration level, using yourConfiguration.setSharderVariable(...).
I haven't used Velocity's tools that much. I will read more on the
configuration level.
I have found that with Jaxen you can do xpath document() function to any xml
document below the run directory. So, whereas <#assign
loaded=.node['document("/some/other/dir/file.xml")']> will give you an
"Unable to parse URI", when running the FreeMarker XML task, I could so
<#assign loaded=.node['document("xml/faq.xml")']> without issue.
I've seen similar results with XSLT and the JDK 1.4, 1.5 XPath
implementation. If I set up a transformer with a file, I could use
document() to anything on the disk, but if I started the transformer with an
input stream, I could not use anything on the disk.
|