docbook-いいドキュメント編集フォーマット


Edit by King      
docbookって何?ドキュメント標準でもドキュメントエディタでもなく、XMLドキュメントのみです.docbookはDTD(scheme)によってXMLドキュメントを仕様し、これらのラベルに基づいてxsltによってXMLをより可視化され、html、chm、pdfなどのより広い範囲のドキュメントに変換する.
以前は、ドキュメントを編集するときにページスタイルの問題に遭遇していました.ドキュメント自体を書くときは、ドキュメントの最後の展示の様子も考慮し、テキストを書き続けるときは、同時にフォーマットを調整する必要があります.docbookを使用する最大のメリットは、コンテンツとページスタイルが完全に分離されていることです.編集の使用では、標準的なラベルを使用するだけで、使用するスタイルをあまり考えなくてもいいです.これらのラベルは変換後、対応するclassになり、直接cssで全体のスタイルを変更します.
もう一つの問題は、ドキュメントが保存されているフォーマットです.chmのドキュメントを見るのに慣れている人もいれば、chmのフォーマットが好きな人もいれば、htmlのフォーマットが好きな人もいます(サーバで配布されている場合).docbookはXML形式のテキストとして、これらのフォーマットの中間状態としてよく機能し、xsltによって他のフォーマットに簡単に変換できます(pdfは中国語表示で少し問題があります).また、docbookのラベル自体が可読性を備えています.
docbookに関することをたくさん話して、簡単に書き方を紹介します.△『DocBook:The Definitive Guide』という本を読むことをお勧めします.docbookの最も基本的ないくつかのラベルは、ラベルであり、本を表し、ラベルは章を表すために使用されます.ここでもう一つのポイントは、すべての秩序シーケンス(章シーケンス、秩序リスト、小節シーケンスなど)がシーケンス符号化に注目せず、xslt変換を行うと自動的に符号化されることです.
ドキュメントでは、ソースコードが参照される場合が多く、docbookにはラベルがあり、languageプロパティを指定できます.この属性は標準のxsltを行う場合,正常に変換されず,拡張したxsltを用いて変換する必要がある.私は普段xslthlを使って変換して、ini、c、c++、java、xmlなどの言語のハイライトをサポートすることができます.xslファイルを変更して、キーワード、プロパティ、コメントなどの対応するプロパティのハイライト色を指定できます.
docbookで使えるラベルがたくさんあるので、ネットでゆっくり探せます(残念ながら、公式サイトhttp://www.docbook.org/壁に囲まれているようで、エージェントを使う必要があります).普段本当に使っているのは、前述した以外にpara、example、sect 1などかもしれません.最後に、現在使用されているxslファイルを貼ります(まずdocbookで提供されているxslファイルをダウンロードする必要があります.ここでは、基本的に元のファイルの構成を示しています):
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xslthl="http://xslthl.sf.net"
exclude-result-prefixes="xslthl"
version="1.0">

<!--     -->
<xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh5/current/html/docbook.xsl"/>

<xsl:param name="chunker.output.encoding" select="'utf-8'"/> 
<!--          -->
<xsl:param name="l10n.gentext.language" select="'zh_cn'"/>
<!--     -->
<xsl:param name="html.stylesheet" select="'docbook.css'"/>
<!--              0 1-->
<xsl:param name="admon.graphics" select="1"/>

<xsl:param name="highlight.source" select="1"/>

<xsl:param name="base.dir" select="'target/single/'"/>

<!--    HTML            yes no-->
<xsl:param name="chunker.output.indent" select="'yes'"/>
<!--     0 1-->
<xsl:param name="section.autolabel" select="1"/>
<!--             0 1-->
<xsl:param name="section.label.includes.component.label" select="1"/>
<!--              CSS    -->
<xsl:param name="table.borders.with.css" select="0"/>
<!--          -->
<xsl:param name="bibliography.numbered" select="1"></xsl:param>


<!--    -->
<xsl:param name="toc.max.depth" select="2"/>
<!--sect#       -->
<xsl:param name="generate.section.toc.level" select="0"/>
<!--sect#        -->
<xsl:param name="toc.section.depth" select="2"/>
<!--         -->
<!--   toc,title,figure,table,example,equation -->
<!-- nop    -->
<xsl:param name="generate.toc">
appendix  toc
article/appendix  nop
article   toc,title
book      toc,title,example
chapter   toc,title
part      toc,title
preface   toc,title
qandadiv  toc
qandaset  toc
reference toc,title
sect1     toc
sect2     toc
sect3     toc
sect4     toc
sect5     toc
section   toc
set       toc,title
</xsl:param>

<!--       <?linebreak?>   ,   Html     <br> -->
<xsl:template match="processing-instruction('linebreak')">
<br/>
</xsl:template>

<xsl:template match="xslthl:string" mode="xslthl">
<b class="hl-string"><xsl:apply-templates mode="xslthl"/></b>
</xsl:template>

<xsl:template match="xslthl:comment" mode="xslthl">
<i class="hl-comment" ><xsl:apply-templates mode="xslthl"/></i>
</xsl:template>

<xsl:template match="xslthl:directive" mode="xslthl">
<span class="hl-directive" style="color: maroon"><xsl:apply-templates mode="xslthl"/></span>
</xsl:template>

<xsl:template match="xslthl:tag" mode="xslthl">
<b class="hl-tag" style="color: #000096"><xsl:apply-templates mode="xslthl"/></b>
</xsl:template>

<xsl:template match="xslthl:attribute" mode="xslthl">
<span class="hl-attribute" style="color: #F5844C"><xsl:apply-templates mode="xslthl"/></span>
</xsl:template>

<xsl:template match="xslthl:value" mode="xslthl">
<span class="hl-value" style="color: #993300"><xsl:apply-templates mode="xslthl"/></span>
</xsl:template>

<xsl:template match="xslthl:html" mode="xslthl">
<b><i style="color: red"><xsl:apply-templates mode="xslthl"/></i></b>
</xsl:template>

<xsl:template match="xslthl:xslt" mode="xslthl">
<b style="color: #0066FF"><xsl:apply-templates mode="xslthl"/></b>
</xsl:template>

<!-- Not emitted since XSLTHL 2.0 -->
<xsl:template match="xslthl:number" mode="xslthl">
<span class="hl-number"><xsl:apply-templates mode="xslthl"/></span>
</xsl:template>

<xsl:template match="xslthl:annotation" mode="xslthl">
<i><span class="hl-annotation"><xsl:apply-templates mode="xslthl"/></span></i>
</xsl:template>

<!-- Not sure which element will be in final XSLTHL 2.0 -->
<xsl:template match="xslthl:doccomment|xslthl:doctype" mode="xslthl">
<b class="hl-tag" style="color: blue"><xsl:apply-templates mode="xslthl"/></b>
</xsl:template>

</xsl:stylesheet>