[#30426] CGI でグラフを描くときにお勧めのライブラリは? — 堀川 久 <vzw00011@...>

こんにちは。

12 messages 2001/07/01

[#30453] syntax check without execution? — Tanaka Akira <akr@...17n.org>

最近、eRuby のまねごとをしていて、そのなかで Ruby のコードを生成してい

16 messages 2001/07/04
[#30455] Re: syntax check without execution? — matz@... (Yukihiro Matsumoto) 2001/07/04

まつもと ゆきひろです

[#30479] Object#dup — "Shin'ya Adzumi" <adzumi@...>

あづみです。

20 messages 2001/07/05

[#30512] open errno EALREADY triggerd — "Inoue" <inoue@...>

井上です。

16 messages 2001/07/08

[#30514] Ruby module frame work? — Takahiro Kambe <taca@...>

こんにちは。

16 messages 2001/07/09
[#30515] Re: Ruby module frame work? — matz@... (Yukihiro Matsumoto) 2001/07/09

まつもと ゆきひろです

[#30529] InterBase を使用したい — "YOUJI KUROKAWA" <CQE10242@...>

環境

22 messages 2001/07/09

[#30530] Question about script on the book "Ruby nyuumon" — NAWATE Masahiko <agul@...>

縄手@松江と言います。

17 messages 2001/07/09
[#30531] Re: Question about script on the book "Ruby nyuumon" — rubikitch <rubikitch@...> 2001/07/09

From: NAWATE Masahiko <agul@mag.shimane-u.ac.jp>

[#30533] Re: Question about script on the book "Ruby nyuumon" — NAWATE Masahiko <agul@...> 2001/07/09

縄手@松江です。

[#30734] UML クラス図と Ruby の記述についての対応 — Ken-ichi HASHIMOTO <ken@...>

橋本@福井県在住です。

13 messages 2001/07/28

[#30764] int/int => float? — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

50 messages 2001/07/31
[#30785] Re: int/int => float? — Konishi@... (Hiromasa KONISHI) 2001/07/31

 KONISHI Hiromasaです。

[#30767] Re: int/int => float? — keiju@... (石塚圭樹) 2001/07/31

けいじゅ@日本ラショナルソフトウェアです.

[#30768] Re: int/int => float? — matz@... (Yukihiro Matsumoto) 2001/07/31

まつもと ゆきひろです

[#30770] Re: int/int => float? — Take_tk <ggb03124@...> 2001/07/31

たけ(tk)です。

[#30771] Re: int/int => float? — matz@... (Yukihiro Matsumoto) 2001/07/31

まつもと ゆきひろです

[ruby-list:30685] Indentation in XML::DOM::Document.to_s

From: "Ichiro Suzuki" <ichiro@...>
Date: 2001-07-20 19:23:31 UTC
List: ruby-list #30685
    XMLParseを使いはじめたのですが、XML::DOM::Document.to_sで
きちんと字下げされた出力を得るのにはどうしたらいいでしょうか?
    
    次のようなスクリプトを使っています。

---- 8< ----
#!/usr/local/bin/ruby

require 'xmltreebuilder'
require 'xmltreevisitor'
include XML::DOM

class MyVisitor < Visitor
    def visit_Document(d)
	d.children_accept_name(self)
    end

    def visit_name_A(e)
	e.children_accept_name(self)
    end

    def visit_name_B(e)
	e.appendChild(Element.new('C'))
    end
end

builder = Builder.new
tree = builder.parse($<.read)

tree.documentElement.normalize
tree.accept_name(MyVisitor.new)

print tree.to_s, "\n"
---- 8< ----

    これに以下のような入力をくわせると、
---- 8< ----
<A>
    <B/>
</A>
---- 8< ----

    見てくれがどうも良くない。(とくに、要素の数が増えてくると。)
---- 8< ----
<A>
    <B><C></C></B>
</A>
---- 8< ----

    結局、以下のようにしてしのいでいます。
---- 8< ----
....

class MyVisitor < Visitor
    def initialize
	(0..4).to_a.each { |width|
	    eval "@indent#{width} = Text.new(\"\n\" + ' ' * width * 4)"
	}
    end

    ....

    def visit_name_B(e, *rest)
	e.appendChild(@indent2)
	e.appendChild(Element.new('A'))
	e.appendChild(@indent1)
    end
end
....
---- 8< ---- ---- 8< ----

    全く対症療法的なやり方です。 他の方はどうして
いらっしゃるのでしょうか? (XSLT?)

----------------------------------------------------------------
Ichiro Suzuki     ichiro@fnal.gov, http://home.fnal.gov/~ichiro/
CD/CMS, Fermi National Accelerator Laboratory, Batavia, Illinois
----------------------------------------------------------------

In This Thread

Prev Next