2016-10-05 6 views
1

XMLファイルを解析してVelocityテンプレートのデータを使用できるようにXmlToolを使用しようとしています。VelocityツールXmlTool

しかし、そのドキュメントはすべて非常に貧しく、必要な情報を実際に提供していません。

ドキュメントはである:https://velocity.apache.org/tools/devel/apidocs/org/apache/velocity/tools/generic/XmlTool.html

そして、私が試してみました:

VelocityContext context = new VelocityContext(page); 

EasyFactoryConfiguration config = new EasyFactoryConfiguration(); 
       config.toolbox("application") 
        .tool("org.apache.velocity.tools.generic.XmlTool") 
        .property("safeMode", false) 
        .property("key", "foo") 
        .property("file", xmlFilePath); 

ToolboxFactory factory = config.createFactory(); 

template = Velocity.getTemplate(page.get("template-file")); 
template.merge(context, write); 
return write.toString(); 

しかし、これは動作しません。 データを実際にテンプレートにする方法を教えてください。私はたくさんのステップがありませんが、必要な情報は見つけられません。

+0

エラーは何ですか?あなたのテンプレートはどのように見えますか? –

答えて

1

私の同僚は、最初の場所でこれをやっていたはずだったはずだったはずですが、それを理解しました。

XmlTool tool = new XmlTool(); 
tool = tool.read(dataFile.getAbsolutePath()); 
context.put("foo", tool); 
関連する問題