R.A. Epigonos et al.

[perl] XML::LibXSLT を使う

smlを入力として適当なhtmlを生成する方法の一般論として、xsltを使う方法がある。

XML::LibXSLT を使うために必要な開発パッケージをインストールする。search の結果、libxml-libxslt-perl パッケージがインストールされているが、新しいものを使うために今回は気にしない。必要な開発パッケージはlibxsltとlibgdbmの2つ。まずはlibxslt1-devをインストール

# aptitude search libxslt
i A libxml-libxslt-perl    - Perl module for using the GNOME libxslt library
v   libxslt-dev            -
p   libxslt-ruby           - Ruby interface to libxslt
p   libxslt-ruby1.8        - Ruby interface to libxslt (for Ruby 1.8)
p   libxslt1-dbg           - XSLT 1.0 processing library - debugging symbols
p   libxslt1-dev           - XSLT 1.0 processing library - development kit
i A libxslt1.1             - XSLT 1.0 processing library - runtime library
p   libxsltc-java          - XSL Transformations (XSLT) compiler from Xalan-Java
p   libxsltc-java-gcj      - XSL Transformations (XSLT) compiler from Xalan-Java (native code)
p   libxslthl-java         - XSLT syntax highlighting
p   python-libxslt1        - Python bindings for libxslt1
p   python-libxslt1-dbg    - Python bindings for libxslt1 (debug extension)
v   python2.5-libxslt1     -
v   python2.5-libxslt1-dbg -
v   python2.6-libxslt1     -
v   python2.6-libxslt1-dbg -
# aptitude install libxslt1-dev
The following NEW packages will be installed:
  libxslt1-dev
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 634 kB of archives. After unpacking 2580 kB will be used.
Get:1 http://ftp.jp.debian.org/debian/ squeeze/main libxslt1-dev amd64 1.1.26-6+squeeze1 [634 kB]
Fetched 634 kB in 0s (2223 kB/s)
Selecting previously deselected package libxslt1-dev.
(Reading database ... 86514 files and directories currently installed.)
Unpacking libxslt1-dev (from .../libxslt1-dev_1.1.26-6+squeeze1_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for doc-base ...
Processing 1 added doc-base file(s)...
Setting up libxslt1-dev (1.1.26-6+squeeze1) ...

libgdbm-dev のインストール。

# aptitude search libgdbm
p   libgdbm-dev                                                            - GNU dbm database routines (development files)
p   libgdbm-gst                                                            - GDBM bindings for GNU Smalltalk
v   libgdbm-ruby                                                           -
v   libgdbm-ruby1.8                                                        -
v   libgdbm-ruby1.9.1                                                      -
i   libgdbm3                                                               - GNU dbm database routines (runtime version)
root@localhost:~# aptitude install libgdbm-dev
The following NEW packages will be installed:
  libgdbm-dev
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 38.6 kB of archives. After unpacking 131 kB will be used.
Get:1 http://ftp.jp.debian.org/debian/ squeeze/main libgdbm-dev amd64 1.8.3-9 [38.6 kB]
Fetched 38.6 kB in 0s (99.8 kB/s)
Selecting previously deselected package libgdbm-dev.
(Reading database ... 86661 files and directories currently installed.)
Unpacking libgdbm-dev (from .../libgdbm-dev_1.8.3-9_amd64.deb) ...
Processing triggers for man-db ...
Setting up libgdbm-dev (1.8.3-9) ...

cpan 経由で XML::LibXSLT をインストール。

# cpan -i XML::LibXSLT
CPAN: Storable loaded ok (v2.39)
Reading '/root/.cpan/Metadata'
  Database was generated on Wed, 03 Oct 2012 04:43:04 GMT
Running install for module 'XML::LibXSLT'
Running make for S/SH/SHLOMIF/XML-LibXSLT-1.78.tar.gz
CPAN: Digest::SHA loaded ok (v5.72)
CPAN: Compress::Zlib loaded ok (v2.055)
Checksum for /root/.cpan/sources/authors/id/S/SH/SHLOMIF/XML-LibXSLT-1.78.tar.gz ok
CPAN: Archive::Tar loaded ok (v1.90)
XML-LibXSLT-1.78/
XML-LibXSLT-1.78/perl-libxml-mm.h
XML-LibXSLT-1.78/benchmark/
XML-LibXSLT-1.78/benchmark/Driver/
XML-LibXSLT-1.78/benchmark/Driver/Sablotron.pm
XML-LibXSLT-1.78/benchmark/Driver/LibXSLT.pm
XML-LibXSLT-1.78/benchmark/Driver/BaseClass.pm
XML-LibXSLT-1.78/benchmark/benchmark.pl
XML-LibXSLT-1.78/Changes
XML-LibXSLT-1.78/LibXSLT.pm
XML-LibXSLT-1.78/MANIFEST
XML-LibXSLT-1.78/testcases/
XML-LibXSLT-1.78/testcases/default.conf
XML-LibXSLT-1.78/example/
XML-LibXSLT-1.78/example/fatal.xsl
XML-LibXSLT-1.78/example/2.xml
XML-LibXSLT-1.78/example/bad3.xsl
XML-LibXSLT-1.78/example/nonfatal.xsl
XML-LibXSLT-1.78/example/1.xml
XML-LibXSLT-1.78/example/bad2.xsl
XML-LibXSLT-1.78/example/1.xsl
XML-LibXSLT-1.78/example/2.xsl
XML-LibXSLT-1.78/example/bad1.xsl
XML-LibXSLT-1.78/Makefile.PL
XML-LibXSLT-1.78/META.yml
XML-LibXSLT-1.78/META.json
XML-LibXSLT-1.78/README
XML-LibXSLT-1.78/t/
XML-LibXSLT-1.78/t/04params.t
XML-LibXSLT-1.78/t/rt71345_a.t
XML-LibXSLT-1.78/t/09exslt.t
XML-LibXSLT-1.78/t/06output.t
XML-LibXSLT-1.78/t/03input.t
XML-LibXSLT-1.78/t/08literal.t
XML-LibXSLT-1.78/t/02dromeds.t
XML-LibXSLT-1.78/t/06entities.t
XML-LibXSLT-1.78/t/11utf8.t
XML-LibXSLT-1.78/t/10functions.t
XML-LibXSLT-1.78/t/05quick.t
XML-LibXSLT-1.78/t/07blankdoc.t
XML-LibXSLT-1.78/t/13error.t
XML-LibXSLT-1.78/t/01basic.t
XML-LibXSLT-1.78/t/14security.t
XML-LibXSLT-1.78/t/12import.t
XML-LibXSLT-1.78/t/15misc.t
XML-LibXSLT-1.78/t/rt71345_b.t
XML-LibXSLT-1.78/typemap
XML-LibXSLT-1.78/LibXSLT.xs
XML-LibXSLT-1.78/ppport.h
XML-LibXSLT-1.78/perl-libxml-mm.c
CPAN: Parse::CPAN::Meta loaded ok (v1.4404)
CPAN: CPAN::Meta loaded ok (v2.120921)
CPAN: Module::CoreList loaded ok (v2.73)

  CPAN.pm: Building S/SH/SHLOMIF/XML-LibXSLT-1.78.tar.gz

running xslt-config... ok
looking for -lxslt... yes
looking for -lexslt... yes
running pkg-config libexslt... ok
Checking if your kit is complete...
Looks good
Note (probably harmless): No library found for -ldb
Writing Makefile for XML::LibXSLT
Writing MYMETA.yml and MYMETA.json
cp LibXSLT.pm blib/lib/XML/LibXSLT.pm
/usr/bin/perl /usr/local/share/perl/5.10.1/ExtUtils/xsubpp  -typemap /usr/share/perl/5.10/ExtUtils/typemap -typemap typemap  LibXSLT.xs > LibXSLT.xsc && mv LibXSLT.xsc LibXSLT.c
cc -c  -I/usr/include/libxml2 -I/usr/include/libxml2   -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"1.78\" -DXS_VERSION=\"1.78\" -fPIC "-I/usr/lib/perl/5.10/CORE"  -DHAVE_BLANK -DHAVE_BLANK -DHAVE_EXSLT LibXSLT.c
cc -c  -I/usr/include/libxml2 -I/usr/include/libxml2   -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"1.78\" -DXS_VERSION=\"1.78\" -fPIC "-I/usr/lib/perl/5.10/CORE"  -DHAVE_BLANK -DHAVE_BLANK -DHAVE_EXSLT perl-libxml-mm.c
Running Mkbootstrap for XML::LibXSLT ()
chmod 644 LibXSLT.bs
rm -f blib/arch/auto/XML/LibXSLT/LibXSLT.so
LD_RUN_PATH="/usr/lib" cc  -shared -O2 -g -L/usr/local/lib -fstack-protector LibXSLT.o perl-libxml-mm.o  -o blib/arch/auto/XML/LibXSLT/LibXSLT.so       \
           -L/usr/lib -lxslt -lxml2 -lz -lm -lexslt -lgdbm -lgdbm_compat -ldl -lm -lpthread -lc -lcrypt         \

chmod 755 blib/arch/auto/XML/LibXSLT/LibXSLT.so
cp LibXSLT.bs blib/arch/auto/XML/LibXSLT/LibXSLT.bs
chmod 644 blib/arch/auto/XML/LibXSLT/LibXSLT.bs
Manifying blib/man3/XML::LibXSLT.3pm
  SHLOMIF/XML-LibXSLT-1.78.tar.gz
  make -- OK
CPAN: YAML loaded ok (v0.84)
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01basic.t ...... 1/4

Compiled against:    libxslt 10126, libxml2 20708
Running:             libxslt 10126, libxml2 20708
Compiled with EXSLT: yes

t/01basic.t ...... ok
t/02dromeds.t .... ok
t/03input.t ...... ok
t/04params.t ..... ok
t/05quick.t ...... ok
t/06entities.t ... ok
t/06output.t ..... ok
t/07blankdoc.t ... ok
t/08literal.t .... ok
t/09exslt.t ...... ok
t/10functions.t .. ok
t/11utf8.t ....... ok
t/12import.t ..... ok
t/13error.t ...... ok
t/14security.t ... ok
t/15misc.t ....... ok
t/rt71345_a.t .... ok
t/rt71345_b.t .... ok
All tests successful.
Files=18, Tests=241,  3 wallclock secs ( 0.21 usr  0.07 sys +  2.68 cusr  0.44 csys =  3.40 CPU)
Result: PASS
  SHLOMIF/XML-LibXSLT-1.78.tar.gz
  make test -- OK
Running make install
Prepending /root/.cpan/build/XML-LibXSLT-1.78-wbyw41/blib/arch /root/.cpan/build/XML-LibXSLT-1.78-wbyw41/blib/lib to PERL5LIB for 'install'
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib/perl/5.10.1/auto/XML/LibXSLT/LibXSLT.so
Installing /usr/local/lib/perl/5.10.1/auto/XML/LibXSLT/LibXSLT.bs
Installing /usr/local/lib/perl/5.10.1/XML/LibXSLT.pm
Installing /usr/local/man/man3/XML::LibXSLT.3pm
Appending installation info to /usr/lib/perl/5.10/perllocal.pod
  SHLOMIF/XML-LibXSLT-1.78.tar.gz
  make install  -- OK

リファレンス

  1. XML::LibXSLT - search.cpan.org
  2. Debian -- squeeze の libxslt1-dev パッケージに関する詳細
  3. Debian -- squeeze の libgdbm-dev パッケージに関する詳細

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-06-29T18:11:22+09:00
  2. Modified: 2010-06-29T18:11:22+09:00
  3. Generated: 2024-12-16T23:09:11+09:00