smile-xml 1.0.2-jruby → 1.0.3-jruby

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,7 @@ import org.w3c.dom.NamedNodeMap;
41
41
  import org.w3c.dom.Node;
42
42
  import org.w3c.dom.NodeList;
43
43
 
44
+ import smile.xml.AttrJ;
44
45
  import smile.xml.EncodingJ;
45
46
 
46
47
  public class UtilJ {
@@ -231,17 +232,18 @@ public class UtilJ {
231
232
  }
232
233
  }
233
234
 
234
- public static void write( Writer writer, Node node, boolean intent, String encoding ) {
235
+ public static void write( Writer writer, Node node, boolean indent, String encoding) {
235
236
  try {
236
237
  StreamResult result = new StreamResult(writer);
237
238
  DOMSource source = new DOMSource(node);
238
239
  Transformer transformer = getTransformer();
239
240
 
241
+ transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no");
242
+
240
243
  if( encoding != null ) {
241
244
  transformer.setOutputProperty( OutputKeys.ENCODING, encoding );
242
245
  }
243
246
 
244
-
245
247
  transformer.transform( source, result);
246
248
 
247
249
  } catch( RuntimeException e) {
@@ -252,15 +254,15 @@ public class UtilJ {
252
254
  }
253
255
 
254
256
 
255
- public static String toString(Node node, boolean escape ) {
256
- return toString( node, escape, (String) null );
257
+ public static String toString(Node node, boolean indent) {
258
+ return toString(node, indent, (String) null );
257
259
  }
258
260
 
259
- public static String toString(Node node, boolean escape, EncodingJ encoding ) {
260
- return toString( node, escape, encoding == null ? null : encoding.asJavaString() );
261
+ public static String toString(Node node, boolean indent, EncodingJ encoding) {
262
+ return toString(node, indent, encoding == null ? null : encoding.asJavaString() );
261
263
  }
262
264
 
263
- public static String toString(Node node, boolean escape, String encoding ) {
265
+ public static String toString(Node node, boolean indent, String encoding) {
264
266
  StringWriter writer = new StringWriter();
265
267
  try {
266
268
  try {
@@ -268,6 +270,8 @@ public class UtilJ {
268
270
  DOMSource source = new DOMSource(node);
269
271
  Transformer transformer = getTransformer();
270
272
 
273
+ transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no");
274
+
271
275
  //OMIT_XML_DECLARATION
272
276
  if( encoding != null )
273
277
  transformer.setOutputProperty( OutputKeys.ENCODING, encoding );
@@ -421,4 +425,23 @@ public class UtilJ {
421
425
 
422
426
  return null;
423
427
  }
428
+
429
+ public static String getRubyClassName(IRubyObject rObject) {
430
+ if (rObject.isNil()) {
431
+ return "nil";
432
+ }
433
+ return rObject.getMetaClass().asString().asJavaString();
434
+ }
435
+
436
+ public static boolean isNamespace(Node node) {
437
+ String name = node.getNodeName();
438
+ if (name.startsWith("xmlns:") || name.equals("xmlns")) {
439
+ return true;
440
+ }
441
+ return false;
442
+ }
443
+
444
+ public static boolean isAttr(Node node) {
445
+ return ! isNamespace(node);
446
+ }
424
447
  }
data/src/main/main.iml ADDED
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
7
+ </content>
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ <orderEntry type="library" name="jruby-complete-1.7.3" level="project" />
11
+ </component>
12
+ </module>
13
+
@@ -1,2 +1,2 @@
1
- <?xml version="1.0"?>
2
- <test/>
1
+ <?xml version="1.0"?>
2
+ <test/>
@@ -1,13 +1,13 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <?xml-stylesheet type="text/xsl" href="my_stylesheet.xsl"?>
3
- <feed xmlns="http://www.w3.org/2005/Atom">
4
- <!-- Not a valid atom entry -->
5
- <entry>
6
- <title type="html"><![CDATA[<<strong>>]]></title>
7
- <content type="xhtml">
8
- <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
9
- <xhtml:p>hi there</xhtml:p>
10
- </xhtml:div>
11
- </content>
12
- </entry>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?xml-stylesheet type="text/xsl" href="my_stylesheet.xsl"?>
3
+ <feed xmlns="http://www.w3.org/2005/Atom">
4
+ <!-- Not a valid atom entry -->
5
+ <entry>
6
+ <title type="html"><![CDATA[<<strong>>]]></title>
7
+ <content type="xhtml">
8
+ <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
9
+ <xhtml:p>hi there</xhtml:p>
10
+ </xhtml:div>
11
+ </content>
12
+ </entry>
13
13
  </feed>
@@ -1,5 +1,5 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <bands genre="metal">
3
- <m�tley_cr�e country="us">M�tley Cr�e is an American heavy metal band formed in Los Angeles, California in 1981.</m�tley_cr�e>
4
- <iron_maiden country="uk">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <bands genre="metal">
3
+ <m�tley_cr�e country="us">M�tley Cr�e is an American heavy metal band formed in Los Angeles, California in 1981.</m�tley_cr�e>
4
+ <iron_maiden country="uk">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>
5
5
  </bands>
@@ -1,5 +1,5 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <bands genre="metal">
3
- <mötley_crüe country="us">Mötley Crüe is an American heavy metal band formed in Los Angeles, California in 1981.</mötley_crüe>
4
- <iron_maiden country="uk">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <bands genre="metal">
3
+ <mötley_crüe country="us">Mötley Crüe is an American heavy metal band formed in Los Angeles, California in 1981.</mötley_crüe>
4
+ <iron_maiden country="uk">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>
5
5
  </bands>
@@ -1,5 +1,5 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <bands genre="metal">
3
- <mötley_crüe country="us">An American heavy metal band formed in Los Angeles, California in 1981.</mötley_crüe>
4
- <iron_maiden country="uk">British heavy metal band formed in 1975.</iron_maiden>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <bands genre="metal">
3
+ <mötley_crüe country="us">An American heavy metal band formed in Los Angeles, California in 1981.</mötley_crüe>
4
+ <iron_maiden country="uk">British heavy metal band formed in 1975.</iron_maiden>
5
5
  </bands>
@@ -1,146 +1,146 @@
1
- <?xml version="1.0"?>
2
- <!-- Sample xml file from Microsoft.
3
- See http://msdn.microsoft.com/en-us/library/ms762271(VS.85).aspx -->
4
- <catalog>
5
- <book id="bk101">
6
- <author>Gambardella, Matthew</author>
7
- <title>XML Developer's Guide</title>
8
- <genre>Computer</genre>
9
- <price>44.95</price>
10
- <publish_date>2000-10-01</publish_date>
11
- <description>
12
- An in-depth look at creating applications
13
- with XML.
14
- </description>
15
- </book>
16
- <book id="bk102">
17
- <author>Ralls, Kim</author>
18
- <title>Midnight Rain</title>
19
- <genre>Fantasy</genre>
20
- <price>5.95</price>
21
- <publish_date>2000-12-16</publish_date>
22
- <description>
23
- A former architect battles corporate zombies,
24
- an evil sorceress, and her own childhood to become queen
25
- of the world.
26
- </description>
27
- </book>
28
- <book id="bk103">
29
- <author>Corets, Eva</author>
30
- <title>Maeve Ascendant</title>
31
- <genre>Fantasy</genre>
32
- <price>5.95</price>
33
- <publish_date>2000-11-17</publish_date>
34
- <description>
35
- After the collapse of a nanotechnology
36
- society in England, the young survivors lay the
37
- foundation for a new society.
38
- </description>
39
- </book>
40
- <book id="bk104">
41
- <author>Corets, Eva</author>
42
- <title>Oberon's Legacy</title>
43
- <genre>Fantasy</genre>
44
- <price>5.95</price>
45
- <publish_date>2001-03-10</publish_date>
46
- <description>
47
- In post-apocalypse England, the mysterious
48
- agent known only as Oberon helps to create a new life
49
- for the inhabitants of London. Sequel to Maeve
50
- Ascendant.
51
- </description>
52
- </book>
53
- <book id="bk105">
54
- <author>Corets, Eva</author>
55
- <title>The Sundered Grail</title>
56
- <genre>Fantasy</genre>
57
- <price>5.95</price>
58
- <publish_date>2001-09-10</publish_date>
59
- <description>
60
- The two daughters of Maeve, half-sisters,
61
- battle one another for control of England. Sequel to
62
- Oberon's Legacy.
63
- </description>
64
- </book>
65
- <book id="bk106">
66
- <author>Randall, Cynthia</author>
67
- <title>Lover Birds</title>
68
- <genre>Romance</genre>
69
- <price>4.95</price>
70
- <publish_date>2000-09-02</publish_date>
71
- <description>
72
- When Carla meets Paul at an ornithology
73
- conference, tempers fly as feathers get ruffled.
74
- </description>
75
- </book>
76
- <book id="bk107">
77
- <author>Thurman, Paula</author>
78
- <title>Splish Splash</title>
79
- <genre>Romance</genre>
80
- <price>4.95</price>
81
- <publish_date>2000-11-02</publish_date>
82
- <description>
83
- A deep sea diver finds true love twenty
84
- thousand leagues beneath the sea.
85
- </description>
86
- </book>
87
- <book id="bk108">
88
- <author>Knorr, Stefan</author>
89
- <title>Creepy Crawlies</title>
90
- <genre>Horror</genre>
91
- <price>4.95</price>
92
- <publish_date>2000-12-06</publish_date>
93
- <description>
94
- An anthology of horror stories about roaches,
95
- centipedes, scorpions and other insects.
96
- </description>
97
- </book>
98
- <book id="bk109">
99
- <author>Kress, Peter</author>
100
- <title>Paradox Lost</title>
101
- <genre>Science Fiction</genre>
102
- <price>6.95</price>
103
- <publish_date>2000-11-02</publish_date>
104
- <description>
105
- After an inadvertant trip through a Heisenberg
106
- Uncertainty Device, James Salway discovers the problems
107
- of being quantum.
108
- </description>
109
- </book>
110
- <book id="bk110">
111
- <author>O'Brien, Tim</author>
112
- <title>Microsoft .NET: The Programming Bible</title>
113
- <genre>Computer</genre>
114
- <price>36.95</price>
115
- <publish_date>2000-12-09</publish_date>
116
- <description>
117
- Microsoft's .NET initiative is explored in
118
- detail in this deep programmer's reference.
119
- </description>
120
- </book>
121
- <book id="bk111">
122
- <author>O'Brien, Tim</author>
123
- <title>MSXML3: A Comprehensive Guide</title>
124
- <genre>Computer</genre>
125
- <price>36.95</price>
126
- <publish_date>2000-12-01</publish_date>
127
- <description>
128
- The Microsoft MSXML3 parser is covered in
129
- detail, with attention to XML DOM interfaces, XSLT processing,
130
- SAX and more.
131
- </description>
132
- </book>
133
- <book id="bk112">
134
- <author>Galos, Mike</author>
135
- <title>Visual Studio 7: A Comprehensive Guide</title>
136
- <genre>Computer</genre>
137
- <price>49.95</price>
138
- <publish_date>2001-04-16</publish_date>
139
- <description>
140
- Microsoft Visual Studio 7 is explored in depth,
141
- looking at how Visual Basic, Visual C++, C#, and ASP+ are
142
- integrated into a comprehensive development
143
- environment.
144
- </description>
145
- </book>
1
+ <?xml version="1.0"?>
2
+ <!-- Sample xml file from Microsoft.
3
+ See http://msdn.microsoft.com/en-us/library/ms762271(VS.85).aspx -->
4
+ <catalog>
5
+ <book id="bk101">
6
+ <author>Gambardella, Matthew</author>
7
+ <title>XML Developer's Guide</title>
8
+ <genre>Computer</genre>
9
+ <price>44.95</price>
10
+ <publish_date>2000-10-01</publish_date>
11
+ <description>
12
+ An in-depth look at creating applications
13
+ with XML.
14
+ </description>
15
+ </book>
16
+ <book id="bk102">
17
+ <author>Ralls, Kim</author>
18
+ <title>Midnight Rain</title>
19
+ <genre>Fantasy</genre>
20
+ <price>5.95</price>
21
+ <publish_date>2000-12-16</publish_date>
22
+ <description>
23
+ A former architect battles corporate zombies,
24
+ an evil sorceress, and her own childhood to become queen
25
+ of the world.
26
+ </description>
27
+ </book>
28
+ <book id="bk103">
29
+ <author>Corets, Eva</author>
30
+ <title>Maeve Ascendant</title>
31
+ <genre>Fantasy</genre>
32
+ <price>5.95</price>
33
+ <publish_date>2000-11-17</publish_date>
34
+ <description>
35
+ After the collapse of a nanotechnology
36
+ society in England, the young survivors lay the
37
+ foundation for a new society.
38
+ </description>
39
+ </book>
40
+ <book id="bk104">
41
+ <author>Corets, Eva</author>
42
+ <title>Oberon's Legacy</title>
43
+ <genre>Fantasy</genre>
44
+ <price>5.95</price>
45
+ <publish_date>2001-03-10</publish_date>
46
+ <description>
47
+ In post-apocalypse England, the mysterious
48
+ agent known only as Oberon helps to create a new life
49
+ for the inhabitants of London. Sequel to Maeve
50
+ Ascendant.
51
+ </description>
52
+ </book>
53
+ <book id="bk105">
54
+ <author>Corets, Eva</author>
55
+ <title>The Sundered Grail</title>
56
+ <genre>Fantasy</genre>
57
+ <price>5.95</price>
58
+ <publish_date>2001-09-10</publish_date>
59
+ <description>
60
+ The two daughters of Maeve, half-sisters,
61
+ battle one another for control of England. Sequel to
62
+ Oberon's Legacy.
63
+ </description>
64
+ </book>
65
+ <book id="bk106">
66
+ <author>Randall, Cynthia</author>
67
+ <title>Lover Birds</title>
68
+ <genre>Romance</genre>
69
+ <price>4.95</price>
70
+ <publish_date>2000-09-02</publish_date>
71
+ <description>
72
+ When Carla meets Paul at an ornithology
73
+ conference, tempers fly as feathers get ruffled.
74
+ </description>
75
+ </book>
76
+ <book id="bk107">
77
+ <author>Thurman, Paula</author>
78
+ <title>Splish Splash</title>
79
+ <genre>Romance</genre>
80
+ <price>4.95</price>
81
+ <publish_date>2000-11-02</publish_date>
82
+ <description>
83
+ A deep sea diver finds true love twenty
84
+ thousand leagues beneath the sea.
85
+ </description>
86
+ </book>
87
+ <book id="bk108">
88
+ <author>Knorr, Stefan</author>
89
+ <title>Creepy Crawlies</title>
90
+ <genre>Horror</genre>
91
+ <price>4.95</price>
92
+ <publish_date>2000-12-06</publish_date>
93
+ <description>
94
+ An anthology of horror stories about roaches,
95
+ centipedes, scorpions and other insects.
96
+ </description>
97
+ </book>
98
+ <book id="bk109">
99
+ <author>Kress, Peter</author>
100
+ <title>Paradox Lost</title>
101
+ <genre>Science Fiction</genre>
102
+ <price>6.95</price>
103
+ <publish_date>2000-11-02</publish_date>
104
+ <description>
105
+ After an inadvertant trip through a Heisenberg
106
+ Uncertainty Device, James Salway discovers the problems
107
+ of being quantum.
108
+ </description>
109
+ </book>
110
+ <book id="bk110">
111
+ <author>O'Brien, Tim</author>
112
+ <title>Microsoft .NET: The Programming Bible</title>
113
+ <genre>Computer</genre>
114
+ <price>36.95</price>
115
+ <publish_date>2000-12-09</publish_date>
116
+ <description>
117
+ Microsoft's .NET initiative is explored in
118
+ detail in this deep programmer's reference.
119
+ </description>
120
+ </book>
121
+ <book id="bk111">
122
+ <author>O'Brien, Tim</author>
123
+ <title>MSXML3: A Comprehensive Guide</title>
124
+ <genre>Computer</genre>
125
+ <price>36.95</price>
126
+ <publish_date>2000-12-01</publish_date>
127
+ <description>
128
+ The Microsoft MSXML3 parser is covered in
129
+ detail, with attention to XML DOM interfaces, XSLT processing,
130
+ SAX and more.
131
+ </description>
132
+ </book>
133
+ <book id="bk112">
134
+ <author>Galos, Mike</author>
135
+ <title>Visual Studio 7: A Comprehensive Guide</title>
136
+ <genre>Computer</genre>
137
+ <price>49.95</price>
138
+ <publish_date>2001-04-16</publish_date>
139
+ <description>
140
+ Microsoft Visual Studio 7 is explored in depth,
141
+ looking at how Visual Basic, Visual C++, C#, and ASP+ are
142
+ integrated into a comprehensive development
143
+ environment.
144
+ </description>
145
+ </book>
146
146
  </catalog>
@@ -1,58 +1,58 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <template>
3
- <body>
4
- <section>
5
- <txt>Some Preset Data Here</txt>
6
- <txt>Some Preset Data Here</txt>
7
- <txt>name: quack!</txt>
8
- <txt>Some Preset Data Here</txt>
9
- <txt>Some Preset Data Here</txt>
10
- <txt>Some Preset Data Here</txt>
11
- <txt>Some Preset Data Here</txt>
12
- <txt>city: quack!</txt>
13
- <txt>Some Preset Data Here</txt>
14
- <txt>Some Preset Data Here</txt>
15
- <txt>Some Preset Data Here</txt>
16
- <txt>Some Preset Data Here</txt>
17
- <txt>state: quack!</txt>
18
- <txt>Some Preset Data Here</txt>
19
- <txt>Some Preset Data Here</txt>
20
- <txt>Some Preset Data Here</txt>
21
- <txt>Some Preset Data Here</txt>
22
- <row>
23
- <txt>year: Vroom!</txt>
24
- <txt>make: Vroom!</txt>
25
- <txt>model: Vroom!</txt>
26
- </row>
27
- <row>
28
- <txt>year: Vroom!</txt>
29
- <txt>make: Vroom!</txt>
30
- <txt>model: Vroom!</txt>
31
- </row>
32
- <row>
33
- <txt>year: Vroom!</txt>
34
- <txt>make: Vroom!</txt>
35
- <txt>model: Vroom!</txt>
36
- </row>
37
- <txt>Some Preset Data Here</txt>
38
- <txt>Some Preset Data Here</txt>
39
- <row>
40
- <txt>year: Vroom!</txt>
41
- <txt>make: Vroom!</txt>
42
- <txt>model: Vroom!</txt>
43
- </row>
44
- <row>
45
- <txt>year: Vroom!</txt>
46
- <txt>make: Vroom!</txt>
47
- <txt>model: Vroom!</txt>
48
- </row>
49
- <row>
50
- <txt>year: Vroom!</txt>
51
- <txt>make: Vroom!</txt>
52
- <txt>model: Vroom!</txt>
53
- </row>
54
- <txt>Some Preset Data Here</txt>
55
- <txt>Some Preset Data Here</txt>
56
- </section>
57
- </body>
58
- </template>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <template>
3
+ <body>
4
+ <section>
5
+ <txt>Some Preset Data Here</txt>
6
+ <txt>Some Preset Data Here</txt>
7
+ <txt>name: quack!</txt>
8
+ <txt>Some Preset Data Here</txt>
9
+ <txt>Some Preset Data Here</txt>
10
+ <txt>Some Preset Data Here</txt>
11
+ <txt>Some Preset Data Here</txt>
12
+ <txt>city: quack!</txt>
13
+ <txt>Some Preset Data Here</txt>
14
+ <txt>Some Preset Data Here</txt>
15
+ <txt>Some Preset Data Here</txt>
16
+ <txt>Some Preset Data Here</txt>
17
+ <txt>state: quack!</txt>
18
+ <txt>Some Preset Data Here</txt>
19
+ <txt>Some Preset Data Here</txt>
20
+ <txt>Some Preset Data Here</txt>
21
+ <txt>Some Preset Data Here</txt>
22
+ <row>
23
+ <txt>year: Vroom!</txt>
24
+ <txt>make: Vroom!</txt>
25
+ <txt>model: Vroom!</txt>
26
+ </row>
27
+ <row>
28
+ <txt>year: Vroom!</txt>
29
+ <txt>make: Vroom!</txt>
30
+ <txt>model: Vroom!</txt>
31
+ </row>
32
+ <row>
33
+ <txt>year: Vroom!</txt>
34
+ <txt>make: Vroom!</txt>
35
+ <txt>model: Vroom!</txt>
36
+ </row>
37
+ <txt>Some Preset Data Here</txt>
38
+ <txt>Some Preset Data Here</txt>
39
+ <row>
40
+ <txt>year: Vroom!</txt>
41
+ <txt>make: Vroom!</txt>
42
+ <txt>model: Vroom!</txt>
43
+ </row>
44
+ <row>
45
+ <txt>year: Vroom!</txt>
46
+ <txt>make: Vroom!</txt>
47
+ <txt>model: Vroom!</txt>
48
+ </row>
49
+ <row>
50
+ <txt>year: Vroom!</txt>
51
+ <txt>make: Vroom!</txt>
52
+ <txt>model: Vroom!</txt>
53
+ </row>
54
+ <txt>Some Preset Data Here</txt>
55
+ <txt>Some Preset Data Here</txt>
56
+ </section>
57
+ </body>
58
+ </template>