Home Diary 倉庫

2004年3月7日

2004年3月7日

Apache Forrest導入

Apache Forrest
Forrest is an XML standards-oriented project documentation framework based on Apache Cocoon,
providing XSLT stylesheets and schemas, images and other resources. Forrest uses these to render
the XML source content into a website via command-line, robot, or a dynamic web application.

Movable Typeはweb interfaceがつかいづらく、豪華な機能はいらないから、自分でxsltで書こうとおもい、いれる。forrestはapacheのcocoonをつかい、ソフトウェアプロジェクトのウェブページを生成するツール。普通の個人サイトに使うには微妙だけど。

j2sdkはsunからj2sdk-1_4_2_03-linux-i586.binをおとして、j2se-packageつかっていれる

mtのexportデータをrubyでxmlに変換し、xsltでととのえる。lexerとparserはもっとも書きたくない部類の物。あとはskinいじる。forrestが提供するのはcocoonのパイプラインつかってxmlデータを、document-v12というスタイルの中間xmlドキュメントに変換し、menuとかをつけてwebページを自動生成するしくみ。foに変換してからpdfも作ってくれるが日本語は対応してないっぽい。サイト内リンクはチェックして存在しないとエラーをだしてくれる。すぐれもの。

document-v12はソフトウェアドキュメントを記述するもので、section,link,table,figure(img),source程度の基本的なもののみ提供してるだけで、シンプルなページを記述できる。生成されたdocument-v12は、skinのxsltでhtmlに変換されるが、skinはサイトで共通だからこのぺーじだけこう、とかはできない。

日記データはarchives/内にdiary20040307.xmlて形式でおいてあり、そこから全日記のタイトルのlistやら日々ごとのhtmlを生成する。


<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  <map:components>
    <map:generators default="file">
      <map:generator name="directory" src="org.apache.cocoon.generation.DirectoryGenerator" />
    </map:generators>
    <map:serializers default="html"/>
    <map:transformers default="xslt">
      <map:transformer name="cinclude" src="org.apache.cocoon.transformation.CIncludeTransformer"/>
    </map:transformers>
    <map:matchers default="wildcard"/>
  </map:components>

  <map:pipelines>
    <map:pipeline>

      <map:match pattern="**/diary-archives.xml">
        <map:generate type="directory" src="content/xdocs/{1}/archives"/>
        <map:transform src="resources/stylesheets/directory2diary-append.xsl">
          <map:parameter name="use-request-parameters" value="true" />
          <map:parameter name="path" value="{1}" />
        </map:transform>
        <map:transform type="cinclude"/>
        <map:transform src="resources/stylesheets/diary-append2diary-archives.xsl"/>
        <map:serialize type="xml"/>
      </map:match>

      <map:match pattern="**index.xml">
        <map:generate src="cocoon:/{1}/diary-archives.xml" />
        <map:transform src="resources/stylesheets/diary-archives2latest-document.xsl" />
        <map:serialize type="xml-document"/>
      </map:match>

      <map:match pattern="**list.xml">
        <map:generate src="cocoon:/{1}/diary-archives.xml" />
        <map:transform src="resources/stylesheets/diary-archives2list-document.xsl" />
        <map:serialize type="xml-document"/>
      </map:match>

      <map:match pattern="**/diary*.xml">
        <map:generate src="content/xdocs/{1}/archives/diary{2}.xml" />
        <map:transform src="resources/stylesheets/diary-individual2document.xsl" />
        <map:serialize type="xml-document"/>
      </map:match>

    </map:pipeline>
  </map:pipelines>
</map:sitemap>

cocoonでディレクトリ構造をxslt内でさぐれたりするdirとか、他のxmlをふくんだりするcincludeなんてのも提供されている

ひとつ気にくわないのは、JavaVMがかなりの確率でクラッシュすること。何度もやると成功する。なんだかな...