个人工具

UbuntuHelp:XsltprocAndXmllint

来自Ubuntu中文

跳转至: 导航, 搜索

xsltproc - Transforming

This tool is an XSL Processor. It is a part of the libxml2 library from the GNOME development project. It takes as first argument the path or URL to an XSLT stylesheet, the next arguments are filenames or URIs of the inputs to be processed. The output of the processing is redirected on the standard output. There are also a number of other options available. To view them type xsltproc at the command prompt. In general you will not have to worry to much about using xsltproc since we have already programmed the 'makefile' to invoke xsltproc when transforming the XML sources to target presentational formats (see below). NOTE:: There is something wacky about the Ubuntu install of libxml2. If your transformation calls to the network during transformations then

XML_CATALOG_FILES=/usr/share/xml/docbook/schema/dtd/4.3/catalog.xml
export XML_CATALOG_FILES

This will cause xsltproc to use your docbook catalog as the method to resolve URI's to local resources, so improving the spead of the transformation.

xmllint - Validating Documents

Before contributing your work back, it is wise to test your changes for errors and resolve them. Since the documents are XML the most important tests to do are to check that they are Well-formed and Valid. Most XML Editors provide utilities and methods for testing these conditions. Please see the documentation of your editor or tool for instructions on how to do well-formed and validity checks. To understand what this means and learn something about XML in general visit http://www.zvon.org/ and take the XML tutorial. You will find many other tutorial son this most excellent of sites. Bookmark it. The xmllint utility is included with the xsltproc toolkit can be used to resolve XIncludes and validate XML documents without modifying the DocBook DTD. It has an --xinclude option that resolves Xincludes, and a --postvalid option that validates after the includes are resolved. At the Ubuntu Documentation Project we use a combination of XInclude and External Entities, so we also add the --noent option to ensure that they are also substituted by their value during validation. So to validate a project document document that has Xincludes and External Entities this the command:

xmllint --noout --xinclude --noent --postvalid foo.xml

To make life easier, we have created a script file for validation. The script contains the command above without the filename which is passed to the script as an argument. To validate a document the command would be:

./validate.sh userguide/userguide.xml