Putting the XML into the data-model
This section is for programmers.
It's easy to create a simple program to try the examples. Just replace the "Create a data-model" part of the example of Programmer's Guide Quickstart with this:
/* Create a data-model */ Map root = new HashMap(); root.put( "doc", freemarker.ext.dom.NodeModel.parse(new File("the/path/of/the.xml")));
and then you have a program that outputs the result of the XML transformation to the standard output (usually the terminal screen).
parsemethod removes comment and processing instruction nodes by default. See the API for more details.
NodeModelalso allows you to wrap
org.w3c.dom.Node-s directly. You may want to clean up the DOM tree first with the static utility methods, such as
NodeModel.simplifyor your own custom cleanup routines.
Note that there are tools available that you can use to generate files from XML documents, so you don't have to write your own for this common task. See here...