什么是最好的Perl XSLT引擎? [英] What is the best XSLT engine for Perl?

查看:129
本文介绍了什么是最好的Perl XSLT引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道的许多XSLT引擎是什么在那里用Perl效果很好。

I would like to know what of the many XSLT engines out there works well with Perl.

我将使用Apache(2.0)和Perl,我想获得PDF和XHTMLs。

I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs.

我是新来的此类项目,所以任何意见或建议将受到欢迎。

I'm new to this kind of projects so any comment or suggestion will be welcome.

感谢。


在做谷歌一个简单的搜索,我发现了很多,我想有很多了。

Doing a simple search on Google I found a lot and I suppose that there are to many more.

  • http://www.mod-xslt2.com/
  • http://xml.apache.org/xalan-j/
  • http://saxon.sourceforge.net/
  • http://www.dopscripts.com/xslt_parser.html

您遇到任何的评论将受到欢迎。

Any comment on your experiences will be welcome.

推荐答案

第一个错误 - 上搜索C​​PAN ,而不是谷歌:)

First mistake - search on CPAN, not Google :)

这抛出了一堆的结果,但相当突出CPAN的问题,即有不止一个解决方案,而且它并不总是很清楚哪些工作,已被抛弃,被分解,缓慢或什么的。

This throws up a bunch of results, but does rather highlight the problem of CPAN, that there's more than one solution, and it's not always clear which ones work, have been abandoned, are broken, slow or whatever.

和令人不安的是,最好的答案(或至少是最好的之一)出现的结果:(至于其他人建议的页面的上的XML::LibXSLT 是稳健和做这项工作:

And disturbingly, the best answer (or at least, one of the best) comes up on page four of the results :( As other folks have suggested, XML::LibXSLT is robust and does the job:

  use XML::LibXSLT;
  use XML::LibXML;

  my $parser = XML::LibXML->new();
  my $xslt = XML::LibXSLT->new();

  my $source = $parser->parse_file('foo.xml');
  my $style_doc = $parser->parse_file('bar.xsl');

  my $stylesheet = $xslt->parse_stylesheet($style_doc);

  my $results = $stylesheet->transform($source);

  print $stylesheet->output_string($results);

如果你不想做任何幻想,不过,还有 XML :: ::的libxslt易,基本上只是包装上面的一个方法调用(和做了一堆幕后的东西巧妙使用穆斯。检查源教育!)。

If you don't want to do anything fancy, though, there's XML::LibXSLT::Easy, which essentially just wraps the above in one method call (and does a bunch of clever stuff behind the scenes using Moose. Check the source for an education!).

  use XML::LibXSLT::Easy;

  my $p = XML::LibXSLT::Easy->new;

  my $output = $p->process( xml => "foo.xml", xsl => "foo.xsl" );

这篇关于什么是最好的Perl XSLT引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆