kwaff 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. data/COPYING +340 -0
  2. data/ChangeLog.txt +118 -0
  3. data/README.txt +96 -0
  4. data/bin/kwaff +131 -0
  5. data/doc/docstyle.css +307 -0
  6. data/doc/examples.html +1283 -0
  7. data/doc/users-guide.html +395 -0
  8. data/examples/Makefile +17 -0
  9. data/examples/ant/Makefile +7 -0
  10. data/examples/ant/build.kwaff +57 -0
  11. data/examples/hibernate/AuctionItem.hbm.kwaff +45 -0
  12. data/examples/hibernate/Bid.hbm.kwaff +42 -0
  13. data/examples/hibernate/Makefile +9 -0
  14. data/examples/hibernate/User.hbm.kwaff +65 -0
  15. data/examples/hibernate/hibernate.cfg.kwaff +17 -0
  16. data/examples/seasar2/Makefile +9 -0
  17. data/examples/seasar2/seasar2.kwaff +62 -0
  18. data/examples/servlet/Makefile +9 -0
  19. data/examples/servlet/web.kwaff +37 -0
  20. data/examples/spring/Makefile +9 -0
  21. data/examples/spring/applicationContext.kwaff +147 -0
  22. data/examples/xhtml/Makefile +9 -0
  23. data/examples/xhtml/README.kwaff +84 -0
  24. data/examples/xi/Makefile +9 -0
  25. data/examples/xi/bbs.kwaff +58 -0
  26. data/lib/kwaff.rb +85 -0
  27. data/lib/kwaff/doctype.rb +124 -0
  28. data/lib/kwaff/doctypes.yaml +138 -0
  29. data/lib/kwaff/errors.rb +26 -0
  30. data/lib/kwaff/node.rb +101 -0
  31. data/lib/kwaff/optparse.rb +101 -0
  32. data/lib/kwaff/orderedhash.rb +56 -0
  33. data/lib/kwaff/parser.rb +342 -0
  34. data/lib/kwaff/rexml.rb +394 -0
  35. data/lib/kwaff/translator.rb +275 -0
  36. data/setup.rb +1331 -0
  37. data/test/ex101.exp +10 -0
  38. data/test/ex101.in +8 -0
  39. data/test/ex102.exp +14 -0
  40. data/test/ex102.in +16 -0
  41. data/test/ex103.exp +13 -0
  42. data/test/ex103.in +13 -0
  43. data/test/ex104.exp +24 -0
  44. data/test/ex104.in +24 -0
  45. data/test/ex105.exp +12 -0
  46. data/test/ex105.in +18 -0
  47. data/test/ex106.exp +22 -0
  48. data/test/ex106.in +21 -0
  49. data/test/ex107.exp +14 -0
  50. data/test/ex107.in +14 -0
  51. data/test/ex111.exp +7 -0
  52. data/test/ex111.in +13 -0
  53. data/test/ex112.exp +15 -0
  54. data/test/ex112.in +16 -0
  55. data/test/ex113.exp +23 -0
  56. data/test/ex113.in +22 -0
  57. data/test/ex114.exp +12 -0
  58. data/test/ex114.in +17 -0
  59. data/test/ex115.exp +9 -0
  60. data/test/ex115.in +12 -0
  61. data/test/ex121.exp +10 -0
  62. data/test/ex121.in +8 -0
  63. data/test/ex122.exp +10 -0
  64. data/test/ex122.in +8 -0
  65. data/test/ex301.exp +13 -0
  66. data/test/ex301.in +14 -0
  67. data/test/ex302.exp +15 -0
  68. data/test/ex302.in +18 -0
  69. data/test/ex303.exp +15 -0
  70. data/test/ex303.in +16 -0
  71. data/test/ex304.exp +17 -0
  72. data/test/ex304.in +15 -0
  73. data/test/ex311.exp +18 -0
  74. data/test/ex311.in +32 -0
  75. data/test/ex312.exp +21 -0
  76. data/test/ex312.in +18 -0
  77. data/test/ex313.exp +20 -0
  78. data/test/ex313.in +33 -0
  79. data/test/ex314.exp +34 -0
  80. data/test/ex314.in +24 -0
  81. data/test/ex801.exp +16 -0
  82. data/test/ex801.in +15 -0
  83. data/test/test.rb +273 -0
  84. data/todo.txt +1 -0
  85. metadata +132 -0
@@ -0,0 +1,96 @@
1
+ .=title: README
2
+ .?lastupdate: $Date: 2005-06-17 13:21:00 +0900 (Fri, 17 Jun 2005) $
3
+ .?release: $Release: 1.0.0 $
4
+ .?copyright: copyright(c) 2005 kuwata-lab.com all rights reserved
5
+
6
+
7
+ .$ What is Kwaff?
8
+
9
+ Kwaff is a simplified and structured data format.
10
+ See examples directory for detail.
11
+
12
+ Name of 'Kwaff' is derived from "kwa's friendly formatter".
13
+
14
+
15
+ .$ Installation
16
+
17
+ There are three ways to install Kwaff.
18
+
19
+ .: If you have installed RubyGems:
20
+ .====================
21
+ $ su
22
+ # gem install --remote kwaff
23
+ .====================
24
+
25
+ .: If you can be root user:
26
+ .====================
27
+ $ ruby setup.rb config
28
+ $ ruby setup.rb setup
29
+ $ su
30
+ # ruby setup.rb install
31
+ .====================
32
+
33
+ .: If you cannot be root user:
34
+ .====================
35
+ ### copy command file to appropriate directory.
36
+ $ cp bin/kwaff $HOME/bin/
37
+ ### copy library files to appropriate directory.
38
+ $ mkdir -p $HOME/lib/ruby
39
+ $ cp -r lib/kwaff* $HOME/lib/ruby
40
+ ### set environment variable RUBYLIB
41
+ $ export RUBYLIB=$HOME/lib/ruby
42
+ .====================
43
+
44
+
45
+ .$ Usage
46
+
47
+ You can convert Kwaff document into XML document.
48
+ .====================
49
+ $ kwaff example.kwaff > example.xml
50
+ .====================
51
+
52
+ You can also convert XML document into Kwaff document.
53
+ .====================
54
+ $ kwaff -r example.xml > example.kwaff
55
+ .====================
56
+
57
+ Type `kwaff -h' for detail.
58
+
59
+
60
+ .$ Manifest
61
+
62
+ .% README.txt
63
+ This file.
64
+
65
+ .% COPYING
66
+ GPL file.
67
+
68
+ .% CangeLog.txt
69
+ Change log file.
70
+
71
+ .% setup.rb
72
+ Setup file for installation.
73
+
74
+ .% bin/kwaff
75
+ Command file.
76
+
77
+ .% lib/kwaff.rb, lib/kwaff/*.rb
78
+ Library file.
79
+
80
+ .% examples/*
81
+ Examples of Kwaff.
82
+ .% doc/users-guide.html
83
+ Users' Guide.
84
+ .% test/test.rb, test/ex*.*
85
+ Unit test script and test data.
86
+
87
+
88
+ .$ License
89
+
90
+ GPL (GNU General Public License) ver 2.
91
+
92
+
93
+ .$ Author
94
+
95
+ Makoto Kuwata <kwa(at)kuwata-lab.com>
96
+
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/ruby
2
+
3
+ ##
4
+ ## convert Kwaff document to XML document
5
+ ##
6
+ ## $Id: kwaff 22 2005-06-18 05:44:23Z kwatch $
7
+ ## $Release: 1.0.0 $
8
+ ## copyright(c) 2005 kuwata-lab.com all rights reserved
9
+ ##
10
+
11
+ require 'kwaff'
12
+ require 'kwaff/optparse'
13
+ require 'kwaff/rexml'
14
+
15
+
16
+ module Kwaff
17
+
18
+ class MainCommand
19
+ VERSION = ('$Rev: 22 $' =~ /\d+(?:\.\d+)*/) && $&
20
+ LAST_UPDATE = ('$Date: 2005-06-18 14:44:23 +0900 (Sat, 18 Jun 2005) $' =~ /\d\d\d\d[-\/]\d\d[-\/]\d\d/) && $&
21
+ RELEASE = ('$Release: 1.0.0 $' =~ /[\.\d]+/) && $&
22
+
23
+
24
+ def help_msg
25
+ msg = <<END
26
+ Usage: #{@command} [-hvr] [-D[@doctpe]] [-iN] [-IN] [file]
27
+ -h, --help : help
28
+ -v : version
29
+ -r : revert XML to Kwaff
30
+ -D[@doctype] : describe doctype
31
+ -iN : set output indent-width to N (default 2)
32
+ -IN : set input indent-width to N (default 2)
33
+ END
34
+ #'
35
+ return msg
36
+ end
37
+
38
+
39
+ def version_msg
40
+ #msg = "#{File.basename(__FILE__)}: #{VERSION} (#{LAST_UPDATE}), kwaff.rb: #{Kwaff::VERSION} (#{Kwaff::LAST_UPDATE})"
41
+ msg = "kwaff (release #{RELEASE})\n"
42
+ msg << "copyright(c) 2005 kuwata-lab.com all rights reserved\n"
43
+ return msg
44
+ end
45
+
46
+
47
+ def initialize(command=nil)
48
+ @command = command || File::basename($0)
49
+ end
50
+
51
+
52
+ ## main routine
53
+ def execute(argv=ARGV)
54
+ optparser = Kwaff::CommandOptionParser.new("hvr", "iI", "D")
55
+ options, properties = optparser.parse(argv)
56
+
57
+ options[?h] = true if properties[:help]
58
+ if options[?h] || options[?v]
59
+ $stdout.print version_msg() if options[?v]
60
+ $stdout.print help_msg() if options[?h]
61
+ return nil
62
+ end
63
+
64
+ properties[:output_indent_width] = options[?i].to_i if options[?i]
65
+ properties[:indent_width] = options[?I].to_i if options[?I]
66
+
67
+ if options[?D] # describe doctypes
68
+ doctypes = nil
69
+ if options[?D] == true
70
+ doctypes = DocType.instances
71
+ else
72
+ name = options[?D]
73
+ doctype = DocType.get(name)
74
+ doctypes = [ doctype ] if doctype
75
+ end
76
+ return nil unless doctypes
77
+ output = "doctypes:\n"
78
+ doctypes.each do |doctype|
79
+ output << " - desc: #{doctype.desc}\n"
80
+ output << " root-tag: #{doctype.root_tag}\n"
81
+ output << " public-id: #{doctype.public_id}\n"
82
+ output << " system-id: #{doctype.system_id}\n"
83
+ output << " names:\n"
84
+ doctype.names.each do |name|
85
+ output << " - #{name}\n"
86
+ end if doctype.names
87
+ output << "\n"
88
+ end
89
+ return output
90
+ end
91
+
92
+ input = ARGF.read
93
+ return if input == nil || input.empty?
94
+
95
+ if !properties.key?(:newline)
96
+ pos = input.index(?\n)
97
+ properties[:newline] = "\r\n" if pos && input[pos - 1] == ?\r
98
+ end
99
+
100
+ mode = options[?r] ? :revert : :convert
101
+ case mode
102
+ when :convert
103
+ kwaff_str = input
104
+ xml_str = Kwaff::convert(kwaff_str, properties)
105
+ output = xml_str
106
+ when :revert
107
+ require 'rexml/document'
108
+ xml_str = input
109
+ kwaff_str = Kwaff::Rexml::revert(xml_str, properties)
110
+ output = kwaff_str
111
+ else
112
+ Kwaff::assert()
113
+ end
114
+
115
+ return output
116
+ end
117
+
118
+ end
119
+
120
+ end
121
+
122
+
123
+ #if $0 == __FILE__
124
+ main = Kwaff::MainCommand.new(File.basename($0))
125
+ begin
126
+ output = main.execute(ARGV)
127
+ print output if output
128
+ rescue Kwaff::KwaffError => ex
129
+ $stderr.puts '[ERROR] ' + ex.message
130
+ end
131
+ #end
@@ -0,0 +1,307 @@
1
+ body {
2
+ color: #333333;
3
+ background-color: #FFFFFF;
4
+ margin: 0px 0px 0px 0px;
5
+ font: 16px 'Lucida Grande', Geneva, Arial, Verdana,'Hiragino Kaku Gothic Pro','�ҥ饮�γѥ� Pro W3','�ͣ� �Х����å�', /*sans-serif*/ gothic;
6
+ }
7
+
8
+
9
+ #logo1 {
10
+ /*
11
+ color: #FF9900;
12
+ font-size: xx-large;
13
+ font-weight: bold;
14
+ */
15
+ color: #FFFFFF;
16
+ font-size: 32px; /* xx-large; */
17
+ font-weight: bold;
18
+ background-color: #FF9900; /* or orange */
19
+ padding: 10px 0px 10px 20px;
20
+ margin: 0px 0px 20px 0px;
21
+ }
22
+
23
+ #logo2 {
24
+ color: #FFFFFF;
25
+ background-color: #FF9900;
26
+ font-size: 32px; /* xx-large; */
27
+ font-weight: bold;
28
+ padding: 10px 0px 10px 20px;
29
+ }
30
+
31
+ /*
32
+ #logo2 #copyright {
33
+ font-size: 12px;
34
+ }
35
+ */
36
+
37
+ #counter {
38
+ /* text-align: right; */
39
+ float: right;
40
+ margin: 10px 20px 10px 0px;
41
+ }
42
+
43
+ #copyright {
44
+ color: #999999;
45
+ font-size: 12px /* x-small */;
46
+ margin: 10px 0px 10px 20px;
47
+ }
48
+
49
+
50
+ .tabs {
51
+ xborder-style: solid; /* �����μ����solid��ľ���� */
52
+ xborder-color: #FF9900; /* �����ο� */
53
+ xborder-width: 0px 0px 1px 0px; /* �����������ʾ塢������������ */
54
+ font-size: 14px;
55
+ }
56
+ .tabs a {
57
+ border-style: solid; /* �����μ����solid��ľ���� */
58
+ border-color: #FF9900; /* �����ο� */
59
+ border-width: 1px 1px 0px 1px; /* �����������ʾ塢������������ */
60
+ color: #FF9900; /* �ե���Ȥο� */
61
+ text-decoration: none; /* ������ä� */
62
+ padding: 4px 20px 0px 20px; /* �Ȥ�ʸ���ȤΤ����֡ʾ塢������������ */
63
+ margin: 0px 0px 0px 20px; /* ���֤κ�¦������� */
64
+ /* background-color: #FFE090; */
65
+ /* width: 20em; */
66
+ }
67
+ .tabs a.current {
68
+ background-color: #FF9900; /* ���򤷤����֤��طʿ� */
69
+ border-bottom: 1px solid #FF9900; /* �����طʿ��Dz�������� */
70
+ color: #FFFFFF;
71
+ font-weight: bold;
72
+ }
73
+ .tabs a:hover, .tabs a:active {
74
+ background-color: #FFDDCC; /* �ޥ�����Ťͤ��Ȥ����طʿ� */
75
+ text-decoration: underline; /* ��󥯤β�����ɽ�� */
76
+ }
77
+
78
+ //.contents {
79
+ // background-color: #CCEEFF; /* ���򤷤����֤��طʿ���Ʊ���� */
80
+ // border-bottom: 1px solid #6699FF; /* �����طʿ��Dz�������� */
81
+ //}
82
+
83
+
84
+ #mainbody {
85
+ margin: 0px;
86
+ padding: 10px 20px 10px 20px;
87
+ border-style: solid;
88
+ border-color: #FF9900;
89
+ border-width: 1px 1px 1px 1px;
90
+ line-height: 150%;
91
+ padding-bottom: 40px;
92
+ }
93
+
94
+ /*
95
+ #breadcrumbs {
96
+ padding: 10px 20px 10px 20px;
97
+ }
98
+ */
99
+
100
+ #breadcrumbs a {
101
+ color: #FF9900;
102
+ font-weight: bold;
103
+ text-decoration: none;
104
+ }
105
+
106
+ #breadcrumbs a:hover, #breadcrumbs a:active {
107
+ background-color: #FFDDCC; /* �ޥ�����Ťͤ��Ȥ����طʿ� */
108
+ text-decoration: underline; /* ��󥯤β�����ɽ�� */
109
+ }
110
+
111
+
112
+
113
+ a:link, a:active, a:hover {
114
+ color:#CC6600;
115
+ }
116
+
117
+ a:visited {
118
+ color:#DD9900;
119
+ }
120
+
121
+ p {
122
+ color:#333333;
123
+ }
124
+
125
+ pre {
126
+ /* width: 100%; */
127
+ line-height:130%;
128
+ white-space:pre;
129
+ }
130
+
131
+ .program {
132
+ border-style:solid;
133
+ /*
134
+ border-width:0px 2px 2px 0px;
135
+ border-color:#999999;
136
+ */
137
+ border-width:1px;
138
+ border-color:#FF9900;
139
+ background-color:#FFE090;
140
+ padding:8px 9px 8px 9px;
141
+ margin:0px;
142
+ word-break:break-all;
143
+ }
144
+
145
+ .terminal {
146
+ border-style:solid;
147
+ border-width:1px;
148
+ border-color:#999999;
149
+ background-color:#DDDDDD;
150
+ padding:9px 10px 9px 10px;
151
+ margin:0px;
152
+ word-break:break-all;
153
+ }
154
+
155
+ .output {
156
+ border-style:solid;
157
+ border-width:1px;
158
+ border-color:#CCCCCC;
159
+ background-color:#FFFFFF;
160
+ padding:8px 9px 8px 9px;
161
+ margin:0px;
162
+ word-break:break-all;
163
+ }
164
+
165
+ .program_caption {
166
+ margin-top: 20px;
167
+ }
168
+
169
+ .terminal_caption {
170
+ margin-top: 20px;
171
+ }
172
+
173
+ .output_caption {
174
+ margin-top: 20px;
175
+ }
176
+
177
+
178
+ .ol1 {
179
+ list-style-type:1;
180
+ }
181
+ .ol2 {
182
+ list-style-type:A;
183
+ }
184
+ .ol3 {
185
+ list-style-type:i;
186
+ }
187
+
188
+ .ul1 {
189
+ list-style-type:disc;
190
+ }
191
+ .ul2 {
192
+ list-style-type:circle;
193
+ }
194
+ .ul3 {
195
+ list-style-type:square;
196
+ }
197
+
198
+
199
+ .dt2, .dt3 {
200
+ font-weight:bold;
201
+ }
202
+
203
+ .table1 {
204
+ padding:2px;
205
+ background-color:#DDDDCC;
206
+ /*
207
+ border-width:1;
208
+ border-style:solid;
209
+ border-color:#FFFFFF;
210
+ */
211
+ margin:5px;
212
+ }
213
+
214
+ .th1, .th2 {
215
+ padding:1px;
216
+ /* background-color:#DDDDCC; */
217
+ background-color:#CCCCBB;
218
+ }
219
+
220
+ .td1, .th2 {
221
+ padding:1px;
222
+ color:#333333;
223
+ background-color:#EEEEDD;
224
+ }
225
+
226
+ .caption1, .caption2 {
227
+ /* font-size:x-small; */
228
+ }
229
+
230
+ .table2 {
231
+ padding:1px;
232
+ background-color:#DDDDCC;
233
+ /*
234
+ border-width:1;
235
+ border-style:solid;
236
+ border-color:#FFFFFF;
237
+ */
238
+ margin:5px;
239
+ }
240
+
241
+ /*
242
+ h1, .chapter, .doctitle {
243
+ color:#333333;
244
+ font-weight:bold;
245
+ padding:30 0 10 0;
246
+ }
247
+ */
248
+
249
+ h2 {
250
+ font-weight:bold;
251
+ border-style:solid;
252
+ border-color:#FF9900;
253
+ border-width:0px 0px 1px 30px;
254
+ padding:10px 20px 0px 5px;
255
+ margin: 50px 0px 0px 0px;
256
+ }
257
+
258
+ h3 {
259
+ font-weight:bold;
260
+ border-style:solid;
261
+ border-color:#FF9900;
262
+ border-width: 0px 0px 0px 15px;
263
+ padding: 10px 20px 0px 5px;
264
+ margin: 40px 0px 0px 0px;
265
+ }
266
+
267
+ .em {
268
+ font-weight:bold;
269
+ }
270
+
271
+ .toc {
272
+ /* font-size:small; */
273
+ }
274
+
275
+ .footnote {
276
+ font-size:small;
277
+ }
278
+
279
+ code {
280
+ font-size: 16px;
281
+ }
282
+
283
+ .footnote code {
284
+ font-size: small;
285
+ }
286
+
287
+ .note {
288
+ background-color:#FFFFDD;
289
+ border-style:solid;
290
+ border-width:0px 1px 0px 1px;
291
+ border-color:#DDDD66;
292
+ /* font-size:small; */
293
+ line-height:120%;
294
+ padding: 5px 20px 5px 20px;
295
+ }
296
+
297
+ .figure {
298
+ /*
299
+ border-width:1;
300
+ border-color:#DDDD66;
301
+ white-space:pre;
302
+ */
303
+ }
304
+
305
+ .page_navigation {
306
+ text-align: center;
307
+ }