Sxmlcnv Kiyoka Nishiyama http://www.netfort.gr.jp/~kiyoka/sxmlcnv $Date: 2004/06/20 13:26:16 $
email: Kiyoka Nishiyama
What is Sxmlcnv? Features
  • Gaucheの全ての機能を使ってプログラマブルなドキュメントを作成できます。
  • You can create programmable documents with whole power of Gauche.
What is SXML?
  • SXMLXML Infosetの一種で、XMLの持つ情報量を損なわずにS式で記述できるようにしたフォーマットです。
  • 本ソフトウェアではssaxというソフトウェアを使用して、XMLをパースしています。
  • SXML is a concrete instance of the XML Infoset.
  • You can describe documents in S-expressions that can keep all information of XML
  • This software was built up with ssax that parses XML data format
Purpose

個人的にはSmartDocという XMLドキュメントフォーマットをもっと書きやすくできないかと考えて、これを作るにいたりました。SXMLにすることでXMLに比べて以下のようなメリットがあると考えています。

Personally, I want to write a SmartDoc document more easily, So I made this software.I think follows are the merits to use the SXML format comparing to the XML format.

Samples

このページは Sxmlvncを使って作成しています。このページがサンプルとして最適でしょう。

I made this page using Sxmlcnv.I think this page is the best way to show you a sample.

Source Code

sourceforgeのサマリページからダウンロードできます。

It can be downloaded from Summary page of development.

Change Log [0.1.0] 1. Apply patches and advice from Oleg Kiselyov(Thanks!) 1) local-rules feature applied. 2) And other re-factorings. 2. Sxmlcnv includes a useful style sheet for SmartDoc. (SmartDoc:style-sheet) 3. Added feature : Supported error handling during loading source file. [0.0.4] 1. Apply patches and advice from Oleg Kiselyov(Thanks!) 1) Bug fix: Handling of SXML->XML's `port argument. 2) Bug fix: Better to use eqv? rather than eq? for comparing characters. 3) Advice : Better to define some functions which has no effect at the top level. 4) Advice : Better to use let* form rather than some (set! args ...) modifications. 5) Advice : Better to use an input parsing library to skip simple white-spaces rather than using regular expressions. [0.0.3] 1. Apply patches and advice from Oleg Kiselyov(Thanks!) 1) Patch : string->goodXML() instead of string->goodHTML() 2) Advice: He taught me the way to output a pretty-printed XML. 3) Advice: He taught me the way to output a well-formed XML. 4) Advice: He gave me pretty-printed XML sample code and some advice. 2. Added feature: -p switch ... Enable pretty-print feature. 3. Added feature: -P switch ... Enable pretty-print + indent feature. 4. Added feature: Added `port argument to SXML->XML(). [0.0.2] 1. Added feature: Reading source from stdin 2. Added feature: Handling Japanese character encoding type of the input. 3. Added feature: Adding suitable 'encoding=' attribute to XML Declaration. [0.0.1] first release version CREDITS This is at least a partial credits of people that have contributed to the Sxmlcnv project. Formatted in a format that allows for easy grepping and beautification by scripts. The fields are: name (N), email (E), web-address (W), PGP key ID and fingerprint (P), description (D). Thanks, Kiyoka ---------- N: Kiyoka Nishiyama E: kiyoka@netfort.gr.jp D: Author of original sxmlcnv W: http://www.netfort.gr.jp/~kiyoka/ N: Oleg Kiselyov E: oleg@pobox.com D: Contributer of Patches and advice for 0.0.3, 0.0.4., 0.1.0
Usage You must install these software to run Sxmlcnv Memo:How to build the gauche on Cygwin platform(version 0.8.0)
  • slibのインストール
    • /usr/share/slib にインストールします。
  • iconvのインストール
    • Cygwinで標準でインストールされています。
  • configureのスイッチ
    • 次の設定で utf-8,euc,sjisのコンテンツが扱えます
    • configure --enable-multibyte=utf-8 --with-slib=/usr/share/slib --with-iconv=/usr/lib
  • installation slib
    • Installing slib archive to /usr/share/slib directory.
  • installing iconv
    • iconv is installed in cygwin system by default.
  • specification switches for configure
    • If you specify follow line, you can handle utf-8,euc,sjis contents.
    • configure --enable-multibyte=utf-8 --with-slib=/usr/share/slib --with-iconv=/usr/lib
How to install
  • sxmlcnv を パスの通ったところにコピーしてください。
  • Please copy the 'sxmlcnv' file to path which can be searched by system for execution.
Command line

入力を与えると内容を自動判別して変換します。

If you specify an input for sxmlcnv script, sxmlcnv guesses the encoding from the input data automatically.

sxmlcnv version 0.x.x Usage: sxmlcnv [switches] < 'sxml-file/xml-file/scm-file' > outfile or sxmlcnv [switches] 'sxml-file/xml-file/scm-file' > outfile Switches: -h ... Display this help message. -p ... Enable pretty-print feature. -P ... Enable pretty-print + indent feature. File: Action: started with # line load and eval as scheme code started with '(' load as s-exp and convert it to XML started with '<?xml' load as XML and convert it to SXML
Specification of recognition methods and actions
判別方法 アクション
1行目が#で始まっている schemeコードどして loadする (SXML->XML関数が使える)
'(' で始まっている SXMLのS式として XMLに変換する
'<?xml'で始まっている XMLとして SXMLに変換する
Recognition method Action
started with # line load and eval as scheme code (you can use SXML->XML function)
started with '(' load as S-expression and convert it to XML
started with '<?xml' load as XML and convert it to SXML
Usable character encodings
  • 入力
    • 全ての入力ソースで、euc-jp,sjis,utf-8の3つの文字コードが使用できます。
  • 出力
    • インストールされているgaucheの内部エンコーディングと同じ文字コードで出力されます。
    • XMLを出力する場合、XML宣言に適切な encoding= 指定が付与されます。
  • input
    • You can use three codes (euc-jp,sjis,utf-8) in every type of inputs.
  • output
    • Sxmlcnv generates a result in gauche's internal character encoding.
    • When sxmlcnv generates the XML, it adds suitable 'encoding=' attribute to XML Declaration
Usable functions

scheme codeとしてロードされる場合、以下の関数が使えます。

You can use these functions, When sxmlcnv load as scheme code.

  • SXML式を渡すとXMLに変換して標準出力に表示します(local-rulesというスタイルシートを使用します)
  • (SXML->XML local-rules SXML &optional port)
  • This function converts SXML argument to XML and write to stdout.(Sxmlcnv uses local-rules defined as style-sheet)
  • (SXML->XML local-rules SXML &optional port)
Built-in style-sheet

SxmlcnvはSmartDoc文書を簡潔に記述するためのスタイルシートを内蔵しています。

Sxmlcnv includes built-in style-sheet for writing SmartDoc documents concisely.

Preparing
  • schemeプログラムで '(SXML->XML SmartDoc:style-sheet S式)' のようにスタイルシートを指定して SXML->XML関数を呼び出してください。
  • You must write code '(SXML->XML SmartDoc:style-sheet ssax-exp)' in your scheme program. SmartDoc:style-sheet is a built-in style-sheet.
How to write a document with SmartDoc style-sheet.
  • sectionの書き方(subsection,subsubsectionも同様)
    • (*section "日本語タイトル" "英語タイトル" S式 ... S式)
  • How to write 'section'(subsection and subsubsection is applied the same rules.)
    • (*section "Title in Japanese" "Title in English" S-exp ... S-exp)
  • 日本語ロケール部分の書き方
    • (*ja (S式))
  • How to write a fragment in Japanese locale
    • (*ja (S-exp))
  • 英語ロケール部分の書き方
    • (*en (S式))
  • How to write a fragment in English locale
    • (*en (S-exp))
  • ファイル内容の挿入の書き方
    • (*insert-file path)
  • How to insert content of a file.
    • (*insert-file path)
  • ハイパーリンクの書き方
    • (*link keyword url)
  • How to write hyper-link.
    • (*link keyword url)
  • 短縮キーワードの使い方
    • 事前にテーブルを定義します。
    • (define SmartDoc:abbrev-table '( (Keyword-1 (S-exp-1)) (Keyword-2 (S-exp-2)) (Keyword-n (S-exp-n))))
    • 使う時は以下のように書きます。
    • ,Keyword-1
  • How to use abbrev keyword
    • You must prepare the table for abbreviation.
    • (define SmartDoc:abbrev-table '( (Keyword-1 (S-exp-1)) (Keyword-2 (S-exp-2)) (Keyword-n (S-exp-n))))
    • You can write abbrev keyword as follows.
    • ,Keyword-1
TODO <hr> hosted by <A href="http://sourceforge.net"> <IMG src="http://sourceforge.net/sflogo.php?group_id=82608" width="88" height="31" border="0" alt="SourceForge Logo"></A>