我想知道是否存在可以读取DTD规范的程序,使用规范来创建表单或控制台提示,使用表单/提示来获取用户的数据输入,然后从输入的数据中写入XML文档
是否存在这样的程序?
例如,想象一下:
[开始想象]
我们有以下DTD文件来定义XML文档的结构:
<!DOCTYPE cd_collection [
<!ELEMENT cd_collection (album+) >
<!ELEMENT album (disc+) >
<!ATTLIST album title CDATA #REQUIRED >
<!ATTLIST album artist CDATA #REQUIRED >
<!ATTLIST album label CDATA #REQUIRED >
<!ELEMENT disc (track*) >
<!ELEMENT track EMPTY >
<!ATTLIST track title CDATA #REQUIRED >
<!ATTLIST track length CDATA #IMPLIED >
<!ATTLIST track featuring CDATA #IMPLIED >
]>
程序(比如PHP或Javascript网站或C ++应用程序)读取DTD文件以确定将保存在XML文件中的记录格式。
在阅读上面的DTD文件后,程序将要求用户输入以开始创建XML树:
Lets create cd_collection...
What is the title attribute of album 1? Barenaked Ladies Are Men [enter]
What is the artist attribute of album 1? Barenaked Ladies [enter]
What is the label attribute of album 1? Raisin Records [enter]
Does album 1 disc 1 contain track(s) (y/n)? yes [enter]
What is the title attribute of album 1 disc 1 track 1? [enter]
Error: this attribute is required.
What is the title attribute of album 1 disc 1 track 1? Serendipity [enter]
What is the length attribute of album 1 disc 1 track 1 (optional)? 4:11 [enter]
What is the featuring attribute of album 1 disc 1 track 1 (optional)? [enter]
What is the title attribute of album 1 disc 1 track 2? Something You'll Never Find [enter]
What is the length attribute of album 1 disc 1 track 2 (optional)? 4:57 [enter]
What is the featuring attribute of album 1 disc 1 track 2 (optional)? [enter]
...
Does album 1 contain another disc (y/n)? [enter]
Error: Yes or No answer expected.
Does album 1 contain another disc (y/n)? n [enter]
Does cd_collection contain another album (y/n)? yes [enter]
What is the title attribute of album 2? Live From Mars [enter]
What is the artist attribute of album 2? Ben Harper [enter]
What is the label attribute of album 2? Virgin Records [enter]
Does album 1 disc 1 contain track(s) (y/n)? y [enter]
What is the title attribute of album 2 disc 1 track 1? Glory & Consequence [enter]
What is the length attribute of album 2 disc 1 track 1 (optional)? [enter]
What is the featuring attribute of album 2 disc 1 track 1 (optional)? [enter]
...
Does album 2 contain another disc (y/n)? y [enter]
...
What is the title attribute of album 2 disc 2 track 6? The Drugs Don't Work [enter]
What is the length attribute of album 2 disc 2 track 1 (optional)? [enter]
What is the featuring attribute of album 2 disc 2 track 1 (optional)? Richard Ashcroft [enter]
...
Does album 2 contain another disc (y/n)? no [enter]
Does cd_collection contain another album (y/n)? n [enter]
Ok! cd_collection saved in ./cd_collection.xml (or outputted to the screen, etc).
因此,您会看到,基于DTD,程序会询问创建XML文档所需的所有数据。该计划遵循一种模式:
程序继续这样(根据需要我可能错过了更多的DTD规则),直到它最终返回到根元素(在这种情况下为cd_collection),此时程序有足够的信息来编写XML包含所有获取数据的文件。
[/ end imagination]
在那个想象的场景中,示例是一个命令行程序。但是,它也可以是图形Web界面。例如,不是像这样一块一条地提示数据:
What is the title attribute of album 2? Live From Mars [enter]
What is the artist attribute of album 2? Ben Harper [enter]
What is the label attribute of album 2? Virgin Records [enter]
可以通过以下HTML格式获取:
album 2:
title: ____Live From Mars____
artist: ____Ben Harper _______
label: ____Virgin Records ___
[submit button]
是否存在任何此类程序(或类似程序),最好是免费的?如果是这样,它叫什么,我在哪里可以找到它?
答案 0 :(得分:3)
您应该查看Altova suite。您可以使用XMLSpy来处理XML和DTD。您可以使用StyleVision创建表单并输出XML数据。
祝你好运!!答案 1 :(得分:3)
@trusktr:可以选择在websphere studio中使用DTD生成HTML表单。见link
已更新,以提供更多信息:
Websphere studio更名为IBM Rational应用程序开发人员,您可以从here下载试用版。此IDE基于eclipse工作台。下载前请检查系统要求。
一旦安装,就会有很多XML工具/编辑器。根据您的需要,您只需要通过菜单使用DTD editior创建DTD:文件&gt;新&gt;其他&gt; XML&gt; DTD 并且一旦创建了DTD,请单击DTD&gt;生成HTML表单。
答案 2 :(得分:1)
Symfony Admin Generator将为您创建功能正常的Web表单(带验证)。
http://www.symfony-project.org/jobeet/1_4/Propel/en/12
您可以使用DTD解析器和XML到RDMS将DTD转换为SQL架构(下面的链接)。
http://www.rpbourret.com/xmldbms/index.htm
http://www.rpbourret.com/dtdparser/index.htm
然后,一旦拥有了SQL模式,就可以将模式插入MySQL。然后,您可以使用symfony pake任务从现有MySQL数据库构建schema.xml(或schema.yml)文件:
./ symfony propel:build-schema
一旦有了一个工作的schema.yml(或schema.xml),你最终可以通过运行来构建数据库的Web表单:
./ symfony propel:generate-admin (上面第一个链接的完整详情)
建议在DTD上使用XSD,但我了解您的情况。对于使用XSD,XML或DTD的任何严肃或重复的工作,XMLSpy也非常棒。
希望有帮助...