We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
您最好问:如何DSL XSLT?
您可能对一些实际示例感兴趣,例如 YSLT 基于 YML 概念。
注意 最好不要转换/预处理代码来获得 XSLT 转换;相反,只需模拟处理器解析输入文档的方式并使用您自己的 DSL。
您还可以编写自己的 DSL。您应该使用某种真正使 DSL 概念变得简单的脚本语言,例如 ruby。在ruby中,您可以实现一些非常漂亮和干净的东西,例如:
可以这样工作:
另一件值得一提的是模板语言,例如erb。我认为这是 XSLT 的唯一可行的替代方案(即使这里的替代方案是一个很大的妥协,并且您很快就会迷失在节点的程序操作中)。
注意
我喜欢 XSLT 冗长,并且由于这种冗长,我认为 XSLT 代码比任何代码都更具可读性其他语言(一旦您了解模板的工作原理)。
我不建议搜索一些内容来将某些不同的标记转换为 XSLT 代码。您的最终 XSLT 代码将缺乏可读性,并且其代码根本不是最佳的。
You should be better ask: how to DSL the XSLT?
You might be interested in some practical example such as YSLT based on YML concept.
NOTE It should be better not to convert/preprocess the code to get an XSLT transform at all; instead, just emulate the way a processor parses the input document and use your own DSL.
You can also write your own DSL. You should use some scripting language which really makes DSL concept easy, as, for example, ruby. In ruby, you can achieve something very nice and clean like:
which could work as:
Another thing that worth to be mentioned is templating languages like erb. This is I think the only feasible alternative to XSLT in general (even if alternative here is a big compromise and you get lost very soon with procedural manipulation of nodes).
Note
I love XSLT verbosity and, because of this verbosity, I think XSLT code is much more readable then any other language (once you understand how templates work).
I don't recommend to search something for converting some different markup to XSLT code. Your final XSLT code will loose of readbility and its code will not be optimal at all.
多年来我见过一些这样做的尝试,但除了其创始人之外,似乎没有任何人使用过。坦率地说,我认为您很快就会习惯 XSLT 的冗长。 XSLT 2.0 当然比 1.0 简洁得多。
I've seen a few attempts to do this over the years but none that seems to have been used by anyone other than its originator. I think, frankly, the verbosity of XSLT is something you quickly get used to. XSLT 2.0 is of course far less verbose than 1.0.
上周在 Balisage 上,Evan Lenz 提出了另一种尝试,称为 Carrot:这一次不仅仅是 XSLT 的紧凑语法,而且是一种尝试提供 XSLT 和 XQuery 联合的语言。看起来很有趣,但我认为还没有实现(如果它流行起来我会感到惊讶......)
At Balisage last week Evan Lenz presented yet another attempt, called Carrot: this time not just a compact syntax for XSLT but a language that attempts to provide the union of XSLT and XQuery. Looks interesting, but I don't think there's an implementation yet (and I'd be surprised if it catches on...)
处理指令可用于实现宏,例如 Docbook 上的这个不相关的问题。
还有一个类似的问题涵盖简化的参数传递。
XMLPreprocess 或 oXML 也可能令人感兴趣。
Processing-instructions can be used to implement macros, such as in this unrelated question on Docbook.
There's also a similar question which covers simplified parameter passing.
XMLPreprocess or oXML may also be of interest as well.