使用 XML 配置生成 HTML 文件
我的目标是组装一个包含大量重复代码的静态网站。现在,我可以使用 JSP include 来实现此目的。但该网站很少会被修改,并且负载非常重,并且还使用 gzip 等功能,我不需要复杂的情况。
我的想法是使用像 ant 这样的工具建立一个构建过程,该构建过程将连接所有 HTML 片段,使用 minifier 预处理 HTML、JS、CSS,最后应用 gzip。 我想要一个 XML 配置来定义每个 html 页面中需要包含的部分及其顺序。
我需要有关 ant 或任何类似工具的建议;如何进行配置,有什么外部工具可以提供帮助吗?非常感谢任何建议。
My target is to assemble a static web site that has a lot of repeating code. Now, I could use JSP includes for that purpose. But the site will be modified infrequently and under very heavy load, also using features like gzip and I don't need the complications.
My idea is to put up a build process with some tool like ant, That build process will concatenate all HTML pieces, preprocess HTML, JS, CSS with minifier and finally apply gzip.
I want an XML configuration that will define the parts that need to go in every html page and their order.
I need advice on ant or any similar tool; how to approach the configuration, any external tools that will help? Any suggestions are much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
XSLT 非常适合将 XML 转换为另一种格式(如 HTML)。
您可以下载 Apache Xalan 来尝试一下。 Ant 支持XSLT 处理。
XSLT is perfectly suited to transform XML into another format like HTML.
You can download Apache Xalan to give it a try. Ant has support for XSLT processing.
在java世界中,你可以看看Apache Forrest,它正是做这种事情的。
在其他世界中,还存在 webgen,它是一个称职的 Ruby 站点构建器。
我还隐约记得还有其他选择,但我找不到他们的名字。
In the java world, you can take a look at Apache Forrest, which precisely do that kind of things.
In other worlds, there also exist webgen, which is a competent Ruby site builder.
I also vaguey remember there are other alternatives, but i can't find back their name.