← 返回命令列表

Linux command

xsltproc 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Transform XML

xsltproc [stylesheet.xsl] [input.xml]

Save output to a file

xsltproc -o [output.html] [stylesheet.xsl] [input.xml]

Pass a string parameter

xsltproc --stringparam [name] "[value]" [stylesheet.xsl] [input.xml]

Pass an XPath expression

xsltproc --param [name] "[xpath]" [stylesheet.xsl] [input.xml]

Process XInclude

xsltproc --xinclude [stylesheet.xsl] [input.xml]

Transform HTML

xsltproc --html [stylesheet.xsl] [input.html]

Show timing information

xsltproc --timing [stylesheet.xsl] [input.xml]

Disable network access

xsltproc --nonet [stylesheet.xsl] [input.xml]

说明

xsltproc is a command-line XSLT processor for transforming XML documents using XSLT stylesheets. It is part of libxslt, the XSLT C library for GNOME, but operates independently of the GNOME desktop. If the input XML document contains a stylesheet processing instruction, xsltproc can automatically use the referenced stylesheet without command-line specification. The tool supports XSLT 1.0 and EXSLT extensions. Output can be XML, HTML, or text depending on the stylesheet's xsl:output directive.

参数

-o, --output _file_
Write output to file instead of stdout.
--stringparam _name_ _value_
Pass a string parameter to the stylesheet.
--param _name_ _value_
Pass an XPath expression result as parameter.
--xinclude
Process XInclude elements before transformation.
--html
Treat input as HTML instead of XML.
--nonet
Disable network access (for DTDs, entities, stylesheets).
--novalid
Skip DTD validation of input document.
--noout
Suppress output of result.
--timing
Display timing for parsing and transformation.
--profile
Output profiling information for optimization.
--maxdepth _value_
Maximum template stack depth (default: 3000).
--nowrite
Refuse to write to any file.
--nomkdir
Refuse to create directories.
-v, --verbose
Output each step during processing.
-V, --version
Show libxml and libxslt versions.

FAQ

What is the xsltproc command used for?

xsltproc is a command-line XSLT processor for transforming XML documents using XSLT stylesheets. It is part of libxslt, the XSLT C library for GNOME, but operates independently of the GNOME desktop. If the input XML document contains a stylesheet processing instruction, xsltproc can automatically use the referenced stylesheet without command-line specification. The tool supports XSLT 1.0 and EXSLT extensions. Output can be XML, HTML, or text depending on the stylesheet's xsl:output directive.

How do I run a basic xsltproc example?

Run `xsltproc [stylesheet.xsl] [input.xml]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o, --output _file_ do in xsltproc?

Write output to file instead of stdout.