Difference between revisions of "Docbook"

From ArchWiki
Jump to: navigation, search
m
m (add ja link)
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Office (English)]]
+
[[Category:Office]]
{{Stub}}
+
[[ja:Docbook]]
 +
{{Expansion|missing introduction}}
  
We will assume that our docbook document is in <code>File.xml</code>
+
== Installation ==
  
==Setting up Docbook in Arch==
+
[[Install]] {{Pkg|docbook-xml}} and {{Pkg|docbook-xsl}}.
To set up docbook running on arch:
+
 
$ pacman -S docbook-xml docbook-xsl libxslt libxml2
+
== Validating XML file ==
  
==Validating XML file==
 
 
To validate the XML file use:
 
To validate the XML file use:
  $ xmllint --valid --noout File.xml
+
 
 +
  $ xmllint --valid --noout ''/path/to/file.xml''
  
 
This will generate no output if the file is proper XML.  
 
This will generate no output if the file is proper XML.  
  
==Converting into XHTML==
+
== Converting into XHTML ==
===Single file===
+
 
 +
=== Single file ===
 +
 
 
To convert into a XHTML file (single file) use:
 
To convert into a XHTML file (single file) use:
  xsltproc /usr/share/xml/docbook/xhtml/docbook.xsl File.xml > Output.html
+
 
===Segmented===
+
  $ xsltproc /usr/share/xml/docbook/$(pacman -Q docbook-xsl | cut -d ' ' -f 2 | cut -d '-' -f 1)/xhtml/docbook.xsl ''/path/to/file.xml'' > ''output.html''
 +
 
 +
=== Segmented ===
 +
 
 
To convert into a a segmented XHTML file (each section in its own file) use:
 
To convert into a a segmented XHTML file (each section in its own file) use:
xsltproc /usr/share/xml/docbook/xhtml/chunk.xsl File.xml
 
  
==Automating==
+
$ xsltproc /usr/share/xml/docbook/$(pacman -Q docbook-xsl | cut -d ' ' -f 2 | cut -d '-' -f 1)/xhtml/chunk.xsl ''/path/to/file.xml''
You can add these to <code>~/.bashrc</code>(or similar shell startup file):
+
 
<pre>
+
== Automating ==
 +
 
 +
You can add these to {{ic|~/.bashrc}} (or similar shell startup file):
 +
 
 +
{{bc|1=
 
alias doc2html1="xsltproc /usr/share/xml/docbook/xhtml/docbook.xsl"
 
alias doc2html1="xsltproc /usr/share/xml/docbook/xhtml/docbook.xsl"
 
alias doc2multihtml="xsltproc /usr/share/xml/docbook/xhtml/chunk.xsl"
 
alias doc2multihtml="xsltproc /usr/share/xml/docbook/xhtml/chunk.xsl"
 
alias docvalidate="xmllint --valid --noout"
 
alias docvalidate="xmllint --valid --noout"
</pre>
+
}}
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== Compilation errors ===
 +
 
 +
If you have already installed the packages above, but begin to see compilation errors such as:
 +
 
 +
{{bc|
 +
GEN    appdata-validate.1
 +
I/O error : Attempt to load network entity http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
 +
warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
 +
cannot parse http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
 +
}}
 +
 
 +
Then reinstall {{Pkg|docbook-xml}} and {{Pkg|docbook-xsl}}. If something has corrupted the catalog file, this will run {{ic|xmlcatalog}} and rebuild {{ic|/etc/xml/catalog}}, which may resolve these compile errors.

Latest revision as of 13:49, 20 August 2017

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: missing introduction (Discuss in Talk:Docbook#)

Installation

Install docbook-xml and docbook-xsl.

Validating XML file

To validate the XML file use:

$ xmllint --valid --noout /path/to/file.xml

This will generate no output if the file is proper XML.

Converting into XHTML

Single file

To convert into a XHTML file (single file) use:

$ xsltproc /usr/share/xml/docbook/$(pacman -Q docbook-xsl | cut -d ' ' -f 2 | cut -d '-' -f 1)/xhtml/docbook.xsl /path/to/file.xml > output.html

Segmented

To convert into a a segmented XHTML file (each section in its own file) use:

$ xsltproc /usr/share/xml/docbook/$(pacman -Q docbook-xsl | cut -d ' ' -f 2 | cut -d '-' -f 1)/xhtml/chunk.xsl /path/to/file.xml

Automating

You can add these to ~/.bashrc (or similar shell startup file):

alias doc2html1="xsltproc /usr/share/xml/docbook/xhtml/docbook.xsl"
alias doc2multihtml="xsltproc /usr/share/xml/docbook/xhtml/chunk.xsl"
alias docvalidate="xmllint --valid --noout"

Troubleshooting

Compilation errors

If you have already installed the packages above, but begin to see compilation errors such as:

GEN    appdata-validate.1
I/O error : Attempt to load network entity http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
cannot parse http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl

Then reinstall docbook-xml and docbook-xsl. If something has corrupted the catalog file, this will run xmlcatalog and rebuild /etc/xml/catalog, which may resolve these compile errors.