| 1 | # /=====================================================================\ # | ||
| 2 | # | LaTeXML::Common::XML::XSLT | # | ||
| 3 | # | wrapper for XML::LibXML | # | ||
| 4 | # |=====================================================================| # | ||
| 5 | # | Part of LaTeXML: | # | ||
| 6 | # | Public domain software, produced as part of work done by the | # | ||
| 7 | # | United States Government & not subject to copyright in the US. | # | ||
| 8 | # |---------------------------------------------------------------------| # | ||
| 9 | # | Bruce Miller <bruce.miller@nist.gov> #_# | # | ||
| 10 | # | http://dlmf.nist.gov/LaTeXML/ (o o) | # | ||
| 11 | # \=========================================================ooo==U==ooo=/ # | ||
| 12 | package LaTeXML::Common::XML::XSLT; | ||
| 13 | 33 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 33 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 0 | ▶ | use XML::LibXSLT; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 16 | |||
| 17 | sub new { | ||
| 18 | my ($class, $stylesheet) = @_; | ||
| 19 | my $xslt = XML::LibXSLT->new(); | ||
| 20 | LaTeXML::Common::XML::initialize_catalogs(); | ||
| 21 | # LaTeXML::Common::XML::initialize_input_callbacks($xslt,installation_subdir => 'resources/XSLT'); | ||
| 22 | # Do we still need this logic, if callbacks work? | ||
| 23 | if (!ref $stylesheet) { | ||
| 24 | $stylesheet = LaTeXML::Common::XML::Parser->new()->parseFile($stylesheet); } | ||
| 25 | # $stylesheet = $xslt->parse_stylesheet_file($stylesheet); } | ||
| 26 | if (ref $stylesheet eq 'XML::LibXML::Document') { | ||
| 27 | $stylesheet = $xslt->parse_stylesheet($stylesheet); } | ||
| 28 | return bless { stylesheet => $stylesheet }, $class; } | ||
| 29 | |||
| 30 | sub transform { | ||
| 31 | my ($self, $document, %params) = @_; | ||
| 32 | return $$self{stylesheet}->transform($document, %params); } | ||
| 33 | |||
| 34 | #====================================================================== | ||
| 35 | 1; | ||