xml-smart 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfea354650019ab5f80ac4522562ba55fb0e71b88885a74ada76b3f948c936b8
4
- data.tar.gz: bcccdac2fb2eb4492af1301092fcbbb89f7458dea67854d857696586c3042eb7
3
+ metadata.gz: 97b3d4716521c2db8484f9bcfbfbf3e94f6860fcca2edef1525f5e6bb72e6a06
4
+ data.tar.gz: 25dfd08f00306769c64fd556d9f589aa649bf2760c32f0acfe07f5dbb7df9e48
5
5
  SHA512:
6
- metadata.gz: 4cf2e0c62c1f8be0d82a326c2c396e6849ce6670335296cb693168c11c4e8d4f1c239de944af2ab9d560b2d8720c2f7677951d8eb772eb10401d22a5096a60c9
7
- data.tar.gz: 452a5dddb8f0235cb3a1d0839b9a72e060165177557fd439736f43d804a1918fa881e4b62c84627c0fd4c429bb626f6bdf3f4cb0db6fab1c5071d6a13caf4f1c
6
+ metadata.gz: 2764ddbf57f7b2ef45e07da667fa9a4f32fb505633a559e5ef759af9ac7c5b7482a93a367f3d8ab9b08bb82b9350211016d18a2f5fd98cdad8e5f7869424ea9b
7
+ data.tar.gz: 7a0c5de212141c7e1d86864c1880d1f997aa943cb87adc72f1c8df12000234393d72fef4ef6d04b7fe3953c31716ced533aee44d19557d37c7d73612b93f6909
@@ -31,7 +31,7 @@ def prnTree(node,depth,mixed)
31
31
  end
32
32
 
33
33
  def help
34
- puts "Usage: xpath_visual.rb FILE \"XPATH\""
34
+ puts "Usage: xpath_visual FILE \"XPATH\""
35
35
  exit
36
36
  end
37
37
 
@@ -13,7 +13,7 @@ module XML
13
13
  Element.new(@dom.root)
14
14
  end
15
15
  def root=(nr)
16
- @dom.root.replace(nr.instance_variable_get(:@element)) if nr.instance_of? Element
16
+ @dom.root.replace(nr.instance_variable_get(:@node)) if nr.instance_of? Element
17
17
  end
18
18
 
19
19
  def find(path)
@@ -70,20 +70,20 @@ module XML
70
70
 
71
71
  def xinclude!(basedir=nil)
72
72
  Element.new(@dom.root).xinclude!(basedir)
73
- end
73
+ end
74
74
 
75
75
  def self::smart_helper(node)
76
76
  if node.instance_of? Nokogiri::XML::Element
77
77
  XML::Smart::Dom::Element.new(node)
78
78
  elsif node.instance_of? Nokogiri::XML::Attr
79
79
  XML::Smart::Dom::Attribute.new(node)
80
- elsif node.instance_of? Nokogiri::XML::NodeSet
80
+ elsif node.instance_of? Nokogiri::XML::NodeSet
81
81
  XML::Smart::Dom::NodeSet.new(node)
82
- elsif node.instance_of?(String) || node.instance_of?(TrueClass) || node.instance_of?(FalseClass) || node.instance_of?(Float)
82
+ elsif node.instance_of?(String) || node.instance_of?(TrueClass) || node.instance_of?(FalseClass) || node.instance_of?(Float)
83
83
  node
84
- elsif node.instance_of? Nokogiri::XML::Text
84
+ elsif node.instance_of? Nokogiri::XML::Text
85
85
  XML::Smart::Dom::Text.new(node)
86
- elsif node.instance_of? Nokogiri::XML::Namespace
86
+ elsif node.instance_of? Nokogiri::XML::Namespace
87
87
  XML::Smart::Dom::Namespace.new(node)
88
88
  elsif node.instance_of? Nokogiri::XML::Document
89
89
  XML::Smart::Dom.new(node)
@@ -93,7 +93,7 @@ module XML
93
93
  nil
94
94
  else
95
95
  XML::Smart::Dom::Other.new(node)
96
- end
96
+ end
97
97
  end
98
98
 
99
99
  def validate_against(doc,&errbl)
@@ -114,9 +114,9 @@ module XML
114
114
  res = Nokogiri::XSLT::Stylesheet.parse_stylesheet_doc(doc.instance_variable_get(:@dom)).transform(@dom,params)
115
115
  if res.children.length != 0 && res.children.first.class == Nokogiri::XML::Text
116
116
  Text.new(res.children.first).text
117
- else
117
+ else
118
118
  Dom::smart_helper(res)
119
- end
119
+ end
120
120
  end
121
121
 
122
122
  end
@@ -171,6 +171,14 @@ module XML
171
171
  end
172
172
 
173
173
  def replace_by(n)
174
+ case n
175
+ when Element; Element.new @node.replace(n.instance_variable_get(:@node))
176
+ when NodeSet; NodeSet.new @node.replace(n.instance_variable_get(:@nodeset))
177
+ else
178
+ nil
179
+ end
180
+ end
181
+ def replace_by_copy(n)
174
182
  case n
175
183
  when Element; Element.new @node.replace(n.instance_variable_get(:@node).dup)
176
184
  when NodeSet; NodeSet.new @node.replace(n.instance_variable_get(:@nodeset).dup)
@@ -45,7 +45,7 @@ module XML
45
45
  nnew.add(nold.children)
46
46
  nold.replace_by(nnew)
47
47
  @node = nnod
48
- @parent.instance_variable_set(:@element,@node)
48
+ @parent.instance_variable_set(:@node,@node)
49
49
  @node.document.custom_namespace_prefixes_update
50
50
  @node.document.ns_update
51
51
  Namespace.new(ns)
@@ -64,7 +64,7 @@ module XML
64
64
  nnew.add(nold.children)
65
65
  nold.replace_by(nnew)
66
66
  @node = nnod
67
- @parent.instance_variable_set(:@element,@node)
67
+ @parent.instance_variable_set(:@node,@node)
68
68
  @node.document.custom_namespace_prefixes_update
69
69
  @node.document.ns_update
70
70
  nil
@@ -92,7 +92,7 @@ module XML
92
92
  nnew.add(nold.children)
93
93
  nold.replace_by(nnew)
94
94
  @node = nnod
95
- @parent.instance_variable_set(:@element,@node)
95
+ @parent.instance_variable_set(:@node,@node)
96
96
  @node.document.custom_namespace_prefixes_update
97
97
  @node.document.ns_update
98
98
  true
@@ -115,7 +115,7 @@ module XML
115
115
  nnew.add(nold.children)
116
116
  nold.replace_by(nnew)
117
117
  @node = nnod
118
- @parent.instance_variable_set(:@element,@node)
118
+ @parent.instance_variable_set(:@node,@node)
119
119
  @node.document.custom_namespace_prefixes_update
120
120
  @node.document.ns_update
121
121
  self
@@ -4,13 +4,13 @@ module XML
4
4
 
5
5
  class Other < Text
6
6
  def otype
7
- case @text
7
+ case @node
8
8
  when Nokogiri::XML::Comment; :comment
9
9
  else; :unknown
10
10
  end
11
11
  end
12
12
  end
13
-
13
+
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -1,6 +1,6 @@
1
1
  <test xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xml:lang="de">
2
2
  <names>
3
- <name team="0" a="3">2017-12-01 11:51:05 +0100</name>
3
+ <name team="0" a="3">2020-06-05 23:34:48 +0200</name>
4
4
  <name team="1">Jürgen</name>
5
5
  <name team="1">Michel</name>
6
6
  <name team="1">Raphi</name>
@@ -12,7 +12,7 @@ class TestNamespaceDefault < Minitest::Test
12
12
  assert(doc.namespaces.length == 2)
13
13
  assert(doc.namespaces.key? 'soap')
14
14
  assert(doc.namespaces.key? 'x')
15
-
15
+
16
16
  # add an element hallo to root
17
17
  nsnode = doc.root.add("hallo")
18
18
 
@@ -50,7 +50,7 @@ class TestNamespaceDefault < Minitest::Test
50
50
  nsnode.namespaces.add("aaa","http://heise2")
51
51
 
52
52
  assert(nsnode.namespaces[nil] == nil)
53
-
53
+
54
54
  nsnode.namespaces.add(nil,"http://heise")
55
55
  nsnode.namespaces[nil] = "http://heiser"
56
56
 
@@ -61,13 +61,13 @@ class TestNamespaceDefault < Minitest::Test
61
61
  assert(nsnode.namespaces['xmlns'].href == "http://heiser")
62
62
  assert(nsnode.namespaces['aaa'].href == "http://heise2")
63
63
  assert(nsnode.namespaces['test'].href == "http://heise1")
64
-
64
+
65
65
  assert(doc.namespaces.length == 5)
66
66
  nsnode.namespaces.delete_at('aaa')
67
67
  assert(nsnode.namespaces['aaa'].nil?)
68
-
68
+
69
69
  assert(doc.namespaces.length == 4)
70
70
  nsnode.namespaces.delete_all!
71
71
  assert(doc.namespaces.length == 2)
72
- end
73
- end
72
+ end
73
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "xml-smart"
3
- s.version = "0.4.2"
3
+ s.version = "0.4.3"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "An xml library that doesn't suck - since 2004."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-smart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler