简体   繁体   中英

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....

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 ?

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....

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....

Thanks for the replies !

Cheers

Possible ? Probably, at least in the sense that XSLT is 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. In other words, there's no direct, straightforward translation.

Writing a full XSLT 2.0 implementation in XSLT 1.0 strikes me as insane.

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 ?

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. 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 . 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 :

  • The new XPath 2.0 XDM.

  • Strong typing and rich type system.

  • Sequences.

  • RegEx support.

  • RTF abolished.

  • Support for reading any text file.

  • <xsl:for-each-group>

  • The XPath 2.0 collection() function.

  • Date/Time/Duration functions.

  • <xsl:function> .

  • Tunnel parameters.

  • <xsl:apply-imports> with parameters.

  • etc., ..., etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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