简体   繁体   English

是否可以编写将XSLT 2.0样式表转换为XSLT 1.0样式表的XSLT 1.0样式表?

[英]Is it possible to write an XSLT 1.0 stylesheet that could convert an XSLT 2.0 stylesheet into an XSLT 1.0 Stylesheet?

Browser support for XSLT 2.0 seems a long way coming (Firefox still doesn't do it at least): XSLT 2.0 offers a number of programmer friendly advantages over XSLT 1.0 (no more horrid Result Tree Fragments for instance)...so.... 浏览器对XSLT 2.0的支持似乎还有很长的路要走(至少Firefox仍然没有做到):与XSLT 1.0相比,XSLT 2.0提供了许多程序员友好的优势(例如,没有更恐怖的结果树片段)...等等。 ..

How feasible would it be for an XSLT 1.0 stylesheet to be written which could convert an XSLT 2.0 stylesheet to an XSLT 1.0 stylesheet ? 编写将XSLT 2.0样式表转换为XSLT 1.0样式表的XSLT 1.0样式表是多么可行?

In theory you could get the programmer-benefits, but then also the compatibility benefits as well..... 从理论上讲,您可以获得程序员的好处,但同时也获得了兼容性的好处.....


It wouldn't strictly necessary to write this manually in XSLT 1.0 though....in theory the difficult bits (such as a regex engine) could be created from a higher-level language, which would need to be 'compiled' ('translated' I guess) into XSLT.... 不过,并不一定要在XSLT 1.0中手动编写它。...理论上,困难的位(例如regex引擎)可以由高级语言创建,而这需要“编译”(“翻译成“我猜”成XSLT。...

But even granted that (and I concede that isn't necessarily an easy thing to do), it sounds like the resultant stylesheet itself would be prohibitively large / inefficient.... 但是,即使考虑到了这一点(而且我也承认这不一定是一件容易的事),但听起来结果样式表本身却会过大/效率低下。

It sounds like certain facilities would just not be possible to express in XSLT 1.0: like reading a non-XML input file.... 听起来某些功能无法在XSLT 1.0中表达:就像读取非XML输入文件一样。

Thanks for the replies ! 感谢您的回复!

Cheers 干杯

Possible ? 有可能 Probably, at least in the sense that XSLT is Turing complete . 可能至少在XSLT是Turing complete的意义上。

Feasible ? 可行吗? No way. 没门。 Not only would you need to implement all of the new functionality in XSLT 2.0 (and somehow handle XPath 2.0 expressions), you'd also need to figure out some way to deal with every one of the items in this large list of differences between the two versions , many of which render normal XSLT 1.0 results incompatible with XSLT 2.0. 您不仅需要在XSLT 2.0中实现所有新功能(并以某种方式处理XPath 2.0表达式),而且还需要找出一些方法来处理这一巨大差异之间的每个项目。 两种版本 ,其中许多版本呈现普通的XSLT 1.0结果与XSLT 2.0不兼容。 In other words, there's no direct, straightforward translation. 换句话说,没有直接,直接的翻译。

Writing a full XSLT 2.0 implementation in XSLT 1.0 strikes me as insane. 用XSLT 1.0编写完整的XSLT 2.0实现使我感到疯狂。

How feasible would it be for an XSLT 1.0 stylesheet to be written which could convert an XSLT 2.0 stylesheet to an XSLT 1.0 stylesheet ? 编写将XSLT 2.0样式表转换为XSLT 1.0样式表的XSLT 1.0样式表是多么可行?

Forget about this . 算了吧

While this is possible in theory, the amount of work involved will exceed that of writing an XSLT 2.0 processor from scratch. 尽管从理论上讲这是可能的,但是所涉及的工作量将超过从头开始编写XSLT 2.0处理器的工作量。 Also, the result would be terribly inefficient. 而且,结果将是非常低效的。

Because of many novel features in XSLT that have no analogue in XSLT 1.0, it is generally not possible to write such a convertor in pure XSLT 1.0 . 由于在XSLT不具有模拟在XSLT 1.0许多新颖的特征,所以一般不可能在纯XSLT 1.0写这样的转换器 Extensions will be massively needed, which makes such a project unportable from the very beginning, therefore with very limited usefulness, if any. 扩展将是非常需要的,这使得这种项目从一开始就无法移植,因此其实用性非常有限(如果有的话)。

Among the features of XSLT 2.0 that would be almost extremely difficult to implement or impossible withoutt extensions : 在XSLT 2.0的功能中,几乎没有扩展就很难实现或无法实现

  • The new XPath 2.0 XDM. 新的XPath 2.0 XDM。

  • Strong typing and rich type system. 强大的打字和丰富的打字系统。

  • Sequences. 序列。

  • RegEx support. RegEx支持。

  • RTF abolished. RTF废止。

  • Support for reading any text file. 支持读取任何文本文件。

  • <xsl:for-each-group>

  • The XPath 2.0 collection() function. XPath 2.0 collection()函数。

  • Date/Time/Duration functions. 日期/时间/持续时间功能。

  • <xsl:function> . <xsl:function>

  • Tunnel parameters. 隧道参数。

  • <xsl:apply-imports> with parameters. <xsl:apply-imports>和参数。

  • etc., ..., etc. 等...等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM