xsltproc
In this exercise you will install libxml2 and libxslt, the libraries necessary
to run xsltproc. The process adheres pretty much to the standard GNU installa-
tion process: configure, make, make install.
1.
Acquire the libxml2 library from the CD, local file system, or Internet
and save it in your home directory.
2.
Uncompress the distribution: gunzip libxml2-2.5.8.tar.gz.
3.
Un-tar the distribution: tar xvf libxml2-2.5.8.tar
4.
Change directories accordingly: cd libxml2-2.5.8.
5.
Configure the build process remembering to specify your home directory as
the prefix: ./configure --prefix=/home/[username] where [username] is
your... username.
6.
Build the library: make
7.
Install the library: make install. When you are finished with this step
there ought to be directory in your home directory named lib, and lib
should contain a file named libxml2.
Now you will make a binary application that uses the libxml2 library, xstl-
proc.
1.
Acquire the libxslt distribution from the CD, local file system, or the
Internet and save it in your home directory.
2.
Uncompress the distribution: gunzip libxslt-1.0.31.tar.gz.
3.
Un-tar the distribution: tar xvf libxslt-1.0.31.tar.
4.
Change into the newly created directory: cd libxslt-1.0.31.
5.
Configure, making sure to specify your home directory as the prefix:
./configure --prefix=/home/[username] where [username] is your username.
6.
Compile like this: make.
Chapter 6. Hands-on activities
40
7.
Install like this: make install.
8.
When you are done you should have a binary named xsltproc in the bin di-
rectory of your home directory. You can run the command like this: xslt-
proc.
In this exercise you will transform an XML document into some other type of
document using an XSL stylesheet and xsltproc.
1.
Copy the files named hello-world.xml and hello-world.xsl from the extras
directory of the CD to your home directory.
2.
Take a look at the files like this: more hello-world.xml and more hello-
world.xsl.
3.
Do an XML transformation like this: xsltproc hello-world.xsl hello-
world.xml.
4.
Open hello-world.xml in a text editor: pico hello-world.xml.
5.
Add a new message to the file and exit the editor by pressing ctrl-X.
6.
Go to Step #3 until satisfied.
You can get a lot of use out of xsltproc, but the fact that it is distributed
as a library than can be compiled into other applications make it even more
powerful.
Chapter 6. Hands-on activities
41
Do'stlaringiz bilan baham: |