2

docbook maven プラグインを使用していくつかのドキュメントを書いています。HTML 出力のヘッダーにナビゲーション バーを自動的に作成したいと考えています。

私はこのように整理された本をいくつか持っています:

  • ガイド1
  • ガイド2
  • チュートリアル
    • チュート1
    • tuto2

望ましい結果は、XSL スタイルシートを使用して書籍ごとに HTML 出力にナビゲーション バーを生成することです。何かのようなもの :

<xsl:template name="user.header.content">
  <xsl:for-each select="something">
      <xsl:value-of select="somethingelse"/>
  </xsl:for-each>
</xsl:template>

前もって感謝します :)。

4

2 に答える 2

0

標準の XSLT 関数を使用しますdocument()

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xsl:output method="text"/>

 <xsl:template match="/">
  <xsl:value-of select=
  "document('http://www.w3.org/2007/schema-for-xslt20.xsd')
     /*/xs:annotation[1]/xs:documentation
  "/>
 </xsl:template>
</xsl:stylesheet>

この変換が任意の XML ドキュメント (未使用) に適用されると、指定された URL (これは XSLT 2.0 言語の XSD) で XML ドキュメントにアクセスし、xs:annotation/xs:documentationこのリモート XML ドキュメントの最初の要素の文字列値を出力します。

This is a schema for XSLT 2.0 stylesheets.

It defines all the elements that appear in the XSLT namespace; it also
provides hooks that allow the inclusion of user-defined literal result elements,
extension instructions, and top-level data elements.

The schema is derived (with kind permission) from a schema for XSLT 1.0 stylesheets
produced by Asir S Vedamuthu of WebMethods Inc.

This schema is available for use under the conditions of the W3C Software License
published at http://www.w3.org/Consortium/Legal/copyright-software-19980720

The schema is organized as follows:

PART A: definitions of complex types and model groups used as the basis 
        for element definitions
PART B: definitions of individual XSLT elements
PART C: definitions for literal result elements
PART D: definitions of simple types used in attribute definitions

This schema does not attempt to define all the constraints that apply to a valid
XSLT 2.0 stylesheet module. It is the intention that all valid stylesheet modules 
should conform to this schema; however, the schema is non-normative and in the event 
of any conflict, the text of the Recommendation takes precedence.

This schema does not implement the special rules that apply when a stylesheet
has sections that use forwards-compatible-mode. In this mode, setting version="3.0"
allows elements from the XSLT namespace to be used that are not defined in XSLT 2.0.

Simplified stylesheets (those with a literal result element as the outermost element)
will validate against this schema only if validation starts in lax mode.

This version is dated 2007-03-16
Authors: Michael H Kay, Saxonica Limited
         Jeni Tennison, Jeni Tennison Consulting Ltd.

2007-03-15: added xsl:document element
            revised xsl:sequence element
            see http://www.w3.org/Bugs/Public/show_bug.cgi?id=4237         

:

アクセスする XML ドキュメントがローカル ファイルに存在する場合は、次のように「file:」スキーマを使用します。

'file:///c:/temp/myXmlDocument.xml'

于 2013-03-28T14:32:46.277 に答える
0

私の経験では、ドキュメントを Web ブラウザ経由で利用できるようにする最善の方法は、maven-site-plugin.

maven-site-plugin<distributionManagement>サイトを生成し、POMのセクションで指定された URL に公開できます。

「ナビゲーションバー」は、 (wiki に似たAPT 形式で) 相対index.htmlを編集することで記述できます。index.apt

+- src/
   +- site/
      +- apt/
      |  +- index.apt

次に、サイトを生成します。

+- target/
   +- site/
      +- index.html
      +- resources/
         +- Guide1.html
         +- Guide2.html
         +- tuto1.html
         +- tuto2.html
         +- Guide1.pdf
         +- Guide2.pdf
         +- tuto1.pdf
         +- tuto2.pdf

Mavenの方法で達成可能です:

  • 2 つのサブ プロジェクト (Maven モジュール) を持つプロジェクトを作成しますmy-prj-docmy-prj-site
  • my-prj-docによってDocBookドキュメンテーションを構築しdocbkx-maven-pluginます。このプロジェクトの主なアーティファクトはmy-prj-doc-1.0.0.jar、ローカルの Maven リポジトリ (.m2ディレクトリ)にインストールされるものである必要があります。
  • my-prj-siteによってサイトを生成しmaven-site-pluginます。さらに、maven-dependency-plugin(最終的にsiteフェーズにアタッチされた) は、ローカルの Maven リポジトリから取得し、ディレクトリmy-prj-doc-1.0.0.jarに展開します。target/site/resources/

私の経験では、この方法が最良の方法の 1 つであることが証明されています。

  • decoupling - ドキュメントを読むことと閲覧することは別の概念であり、それを別のプロジェクトやプロセスに反映させることができます
  • 保守性- 別々のプロジェクトで作業することで、エラーが発生しにくくなります
  • モジュール化- 要するに、ドキュメントをコードとして考え始めると、ドキュメントを API としてパッケージ化して配布できます。faq-1.0.0.jarつまり、FAQ Maven サブ プロジェクトを作成してから、アーティファクトを自分Guide1とMaven サブ プロジェクトにインポートすることができますGuide2。そのため、1 つの FAQ サブ プロジェクトを維持すると、2 つ (またはそれ以上) の異なる最終ドキュメントに同じ FAQ が含まれることになります。
于 2013-03-29T08:12:20.403 に答える