加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

A perl script for XSLT using MSXML

发布时间:2020-12-16 00:37:36 所属栏目:大数据 来源:网络整理
导读:Last version:?https://gist.github.com/1053576 sub TransformWithArgs { ???? my ( $xsltFile , $xmlFile ,128); ">$argsHash ) = @_ ; ???? my $template = Win32:: OLE - new ( 'MSXML2.XSLTemplate.4.0' ) ??????? or die "Couldn't create MSXML2.XSLT

Last version:?https://gist.github.com/1053576

 
 
sub TransformWithArgs {
???? my ( $xsltFile , $xmlFile ,128); ">$argsHash ) = @_ ;

???? my $template = Win32:: OLE -> new ( 'MSXML2.XSLTemplate.4.0' )
??????? or die "Couldn't create MSXML2.XSLTemplate object.n" ;

???? my $xsltDoc = 'MSXML2.FreeThreadedDOMDocument.4.0' )
??????? or "Couldn't create MSXML2.FreeThreadedDOMDocument.4.0 object.n " ;

???? $xsltDoc -> { async } = "false" ;
???? $xsltDoc -> { resolveExternals } = "false" ;
??? $xsltDoc -> load ( $xsltFile );

??? $template -> { stylesheet } = $xsltDoc ;

???? my $xsltProc = $template -> createProcessor ();

???? my $xmlDoc = "Msxml2.DOMDocument.4.0" );
??? $xmlDoc -> load ( $xmlFile );
???? $xmlDoc || "Failed to load $xmlFilen" ;

???? # Note: ? The code can not work here: $xsltProc->{input} = $docXhtml;
??? $xsltProc -> LetProperty ( 'input' ,128); ">$xmlDoc );

???? # Add parametes of XSLT
???? foreach my $key ( keys %$argsHash ) {
??????? $xsltProc -> addParameter ( $key ,128); ">$argsHash -> { $key });
???? }

??? $xsltProc -> transform () or "Faied to transform.n" ;
???? my $result = $xsltProc -> { output };

???? $result ;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读