将配置文件转换为HTML [英] Converting an configuration file to HTML

查看:109
本文介绍了将配置文件转换为HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆配置文件,通常是从应用程序打开并像记事本一样编辑的属性文件,现在的要求是选择每个属性并找到适合的HTML标记并将整个属性文件显示为HTML页面. 例如:

I have a bunch of configuration files which are usually properties files which are opened from application and edited like notepad.Now the requirement is pick each property and find which HTML tag does it fit through and display the whole properties file as HTML page. For eg:

Security.Properties文件

//This property checks if the user has already logged or not
//Possible values Y N

order.security.Login=Y

因此上述属性具有两个可能的值Y N.等效的HTML格式可以是具有Y N的单选按钮.类似地,如果另一个属性的值是1,2,则HTML是具有这两个值的Listbox.

So the above property has two possible values Y N .The equivalent HTML format can be a radio button with Y N. Similarly if another property takes values 1,2, the HTML is Listbox with these two values.

我知道这有点麻烦,但必须这样做. 开发就是JAVA JAVASCRIPT VELOCITY 我的想法是将所有属性文件转换为XML,然后使用XSLT呈现为HTML. 我想听听更多的想法,包括性能问题.

I know this is little cumbersome but has to done. Development is JAVA JAVASCRIPT VELOCITY My idea is convert all properties files into XML then use XSLT to render as HTML. I would like to hear more ideas including performance issues.

推荐答案

我将定义一个XML文件,该文件列出每个属性键,以及每个属性键在HTML中的显示方式.

I would define a XML file that lists every properties key, and for each, the way it will displayed in HTML.

<property key="order.security.Login">
    <display type="radio" values="Y,N" />
</property>

然后,如果要将属性显示为HTML文件,只需使用XSLT解析此XML文件,使用属性键匹配正确的元素并很好地显示其内容(使用转换为<显示类型的XSL文件="radio">放入< input type ="radio">)的列表中

then if you want to display a Properties as an HTML file, just parse this XML file with XSLT, using the property key to match the right element and display well its content (with a XSL file that convert a <display type="radio"> into a list of <input type="radio">)

Dunno是否适合您的应用程序配置,但这是我的第一个适合的想法.

Dunno if it will fit to your app configuration, but that'll be my first idea to fit.

这篇关于将配置文件转换为HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆