问题描述
是否可以从Schematron生成HTML表单?我在Schematron文件中描述了一堆架构。我必须创建HTML表单,允许输入将被转换为与Schematrons兼容的XML文档的数据。我想以任何方式生成它们,而不是手动开发表格。可能吗?你知道这个工具吗?
我发现了类似的从XSD生成HTML表单的工具,例如。
非常有趣的问题。它可以用XSD来完成,因为XSD描述了有效XML文档的结构(可以显示哪些元素,以什么顺序,次数等等)。因此,应用程序可以绕过此过程并向用户显示允许填充输入小部件元素,重新排序元素等的表单,从而最终生成有效的XML文档。
然而,Schematron没有通过描述XML文档结构,而是给出了极其强大的语义规则或约束。所以(在一般情况下)过程不能被颠倒,以显示生成有效XML文档的表单。然而,这可以根据你的Schematrons的样子来完成,但想一想这个简单的例子(摘自):
< schema xmlns =http://www.ascc。 net / xml / schematron>
< pattern name =测试整数>
< rule context =AAA>
< assert test =floor(。)= number(。)> AAA值不是整数。< / assert>
< / rule>
< / pattern>
< / schema>
有许多不同的XML文档结构可以生成对这个Schematron有效的XML文档,所以您可能有一个表单来填充元素值,但是Schematron没有提供关于文档结构应该是什么的足够信息:元素应该放置在什么位置?元素应该出现多少次?等等。
来源:在我的最终学位项目中,我构建了一个多平台应用程序,它提供了一个XSD(以及可选的Schematron和可选的XSLT),它生成了一个表单,以便任何用户都可以创建一个有效的XML文档针对XSD和Schematron,而不需要了解有关XML / XSD / Schematron / XSLT的任何信息。 Schematron的信息(如果存在的话)被用来做额外的验证,甚至动态地禁用枚举值,如果选择将会导致Schematron错误。但请注意,Schematron的信息不足以知道XML文档应具有哪种结构(该信息存在于XSD中)。如果您想知道,可以使用XSLT文档(如果有的话)可选地将生成的XML文档转换为更适合用户的其他类型的文档,如HTML或PDF。
is it possible to generate HTML form from a Schematron? I have a bunch of schemas described in Schematron files. I have to create HTML forms which allow to input data which will be transformed into an XML documents compatible with Schematrons. Instead of a manual development of forms I would like to generate them in any way. Is it possible? Do you know tools for this?
I found similar tools for generating HTML forms from XSD, for example https://github.com/davidmoten/xsd-forms .
Very interesting question. It can be done with XSD because XSD describes the structure of valid XML documents (what elements can appear, in what order, how many times, etc.). So an app can just turn around this process and show the user a form allowing to fill input widget elements, reorder elements, etc, that at the end will generate a valid XML document.
However Schematron does not usally describes XML document structure, but rather it give extremlly powerfull semmantic rules or constraints. So (in the general case) the process cannot be reversed to show a form that produces a valid XML document. However it can be done depending on what your Schematrons looks like, but think about this simple example (taken from this page):
<schema xmlns="http://www.ascc.net/xml/schematron" >
<pattern name="Test integer">
<rule context="AAA">
<assert test="floor(.) = number(.)">The AAA value is not an integer.</assert>
</rule>
</pattern>
</schema>
There are many different XML document structures that produces XML documents valid against this Schematron, so you may have a form to fill the element value but the Schematron doesn't provides enough information about what the structure of the document should be: where should the element be placed?, how many times should the element appear?, etc.
Source: in my final degree project I built a multiplatform app that given an XSD (and optionally an Schematron, and optionally an XSLT) it generated a form so that any user could create a XML document valid against the XSD and the Schematron, without them needing to know anything about XML/XSD/Schematron/XSLT. The info of the Schematron (if present) was used to do extra validations, and even to dynamically disable enumeration values that if selected will cause Schematron errors. But please note that the info of the Schematron was not enough to know what structure should the XML document have (that info were present in the XSD). In case you want to know, the XSLT document (if present) was used to optionally transform the resulting XML document to other type of document more suitable for the user, like HTML or PDF.
这篇关于从Schematron生成HTML表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!