xml-smart 0.3.15 → 0.3.16
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.
- checksums.yaml +4 -4
- data/lib/xml/smart.rb +12 -1
- data/lib/xml/smart_domelement.rb +15 -10
- data/test/EXAMPLE.xml +1 -1
- data/test/concurrent.xml +1 -7
- data/test/tc_basic.rb +3 -3
- data/test/tc_copy.rb +3 -1
- data/test/tc_namespace_default.rb +1 -1
- data/xml-smart.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d05696d426518de0bfd9786c6409993a8bda165
|
4
|
+
data.tar.gz: 9be92beef9e765e91b72b8afffda5f79cf694122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88aee8b8411d3b91a40373e5befe6897446f88960f0aa0453969f142f761a3ac41fe224729a003154b66b7f2b1a432025f703902e057b0dcc74a930b4bbad03d
|
7
|
+
data.tar.gz: 4570b4d8d349747b80be0e66a56c50904316786749ba57b782cb11da919447e6ffc3d713e42eee59d9d4c1299bb14dbecde067ef9213760156f5f6c494313b20
|
data/lib/xml/smart.rb
CHANGED
@@ -102,7 +102,7 @@ module Nokogiri
|
|
102
102
|
name = path + name if name !~ /^(https?:|ftp:)/
|
103
103
|
content = open(name,{ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).read
|
104
104
|
insert = begin
|
105
|
-
Nokogiri::XML::parse(content){|config| config.noblanks.noent.
|
105
|
+
Nokogiri::XML::parse(content).root # {|config| config.noblanks.noent.strict }.root
|
106
106
|
rescue
|
107
107
|
content
|
108
108
|
end
|
@@ -117,6 +117,17 @@ module Nokogiri
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
+
alias __replace replace
|
121
|
+
def replace(node_or_tags)
|
122
|
+
x = __replace(node_or_tags)
|
123
|
+
x.xpath('.|.//*|.//@*').each do |rns|
|
124
|
+
x.namespace_scopes.each do |nss|
|
125
|
+
rns.namespace = nss if rns.namespace && rns.namespace.href == nss.href
|
126
|
+
end
|
127
|
+
end
|
128
|
+
x
|
129
|
+
end
|
130
|
+
|
120
131
|
def xpath_experimental
|
121
132
|
return NodeSet.new(document) unless document
|
122
133
|
@nsc ||= 0
|
data/lib/xml/smart_domelement.rb
CHANGED
@@ -25,13 +25,13 @@ module XML
|
|
25
25
|
if @element.document.user_custom_namespace_prefixes[pfx] == v
|
26
26
|
ns = @element.document.user_custom_namespace_prefixes[pfx]
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
29
29
|
end
|
30
|
-
if ns.nil?
|
30
|
+
if ns.nil?
|
31
31
|
if @element.document.custom_namespace_prefixes.has_key?(pfx)
|
32
32
|
ns = @element.document.custom_namespace_prefixes[pfx]
|
33
33
|
else
|
34
|
-
raise Error, 'No valid namespace'
|
34
|
+
raise Error, 'No valid namespace'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -86,10 +86,10 @@ module XML
|
|
86
86
|
if attrs[1] == XML::Smart::COPY
|
87
87
|
tnos = nos.map{|e|e.dup}
|
88
88
|
nos = Nokogiri::XML::NodeSet.new(nos.first.document,tnos)
|
89
|
-
end
|
89
|
+
end
|
90
90
|
return [Nokogiri::XML::NodeSet.new(nos.first.document,tnos), true]
|
91
91
|
return [nos, !same]
|
92
|
-
else
|
92
|
+
else
|
93
93
|
return [nos, false]
|
94
94
|
end
|
95
95
|
elsif attrs.length == 2 && attrs[0].is_a?(String) && attrs[1].is_a?(String) && attrs[0][0] == '?'
|
@@ -105,7 +105,7 @@ module XML
|
|
105
105
|
if update
|
106
106
|
@element.document.custom_namespace_prefixes_update
|
107
107
|
@element.document.ns_update
|
108
|
-
end
|
108
|
+
end
|
109
109
|
res
|
110
110
|
end
|
111
111
|
def append(*attrs)
|
@@ -121,7 +121,7 @@ module XML
|
|
121
121
|
if update
|
122
122
|
@element.document.custom_namespace_prefixes_update
|
123
123
|
@element.document.ns_update
|
124
|
-
end
|
124
|
+
end
|
125
125
|
res
|
126
126
|
end
|
127
127
|
def add_after(*attrs)
|
@@ -130,11 +130,16 @@ module XML
|
|
130
130
|
if update
|
131
131
|
@element.document.custom_namespace_prefixes_update
|
132
132
|
@element.document.ns_update
|
133
|
-
end
|
133
|
+
end
|
134
134
|
res
|
135
135
|
end
|
136
136
|
|
137
|
-
def dump
|
137
|
+
def dump
|
138
|
+
doc = Nokogiri::XML::Document.new
|
139
|
+
doc.root = @element
|
140
|
+
doc.root.to_s
|
141
|
+
end
|
142
|
+
|
138
143
|
def to_s; @element.content; end
|
139
144
|
def to_i; @element.content.to_i; end
|
140
145
|
def to_f; @element.content.to_f; end
|
@@ -149,7 +154,7 @@ module XML
|
|
149
154
|
n
|
150
155
|
else
|
151
156
|
return
|
152
|
-
end
|
157
|
+
end
|
153
158
|
tmp = @element.document.custom_namespace_prefixes[n] || @element.document.user_custom_namespace_prefixes[n]
|
154
159
|
unless tmp.nil?
|
155
160
|
@element.namespace_scopes.each do |nss|
|
data/test/EXAMPLE.xml
CHANGED
@@ -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">2015-07-
|
3
|
+
<name team="0" a="3">2015-07-27 20:41:24 +0200</name>
|
4
4
|
<name team="1">Jürgen</name>
|
5
5
|
<name team="1">Michel</name>
|
6
6
|
<name team="1">Raphi</name>
|
data/test/concurrent.xml
CHANGED
@@ -1,7 +1 @@
|
|
1
|
-
<solutions>
|
2
|
-
<solution matnr="9906264" name="mangler" secid="1" when="2015-07-23T21:37:19+02:00" assessment="16">
|
3
|
-
<question block="1" question="2"/>
|
4
|
-
<question block="2" question="4"/>
|
5
|
-
<question block="3" question="6"/>
|
6
|
-
</solution>
|
7
|
-
</solutions>
|
1
|
+
<solutions><solution matnr="9906264" name="mangler" secid="1" assessment="16"><question block="1" question="2"/><question block="2" question="4"/><question block="3" question="6"/></solution></solutions>
|
data/test/tc_basic.rb
CHANGED
@@ -82,7 +82,7 @@ class TestBasic < MiniTest::Test
|
|
82
82
|
|
83
83
|
doc = XML::Smart.open(::File.dirname(__FILE__) + "/EXAMPLE-NS.xml")
|
84
84
|
assert(doc.namespaces == {"xmlns0"=>"http://example.org", "xmlns1"=>"http://example1.org", "soap"=>"http://schemas.xmlsoap.org/wsdl/soap/"})
|
85
|
-
assert(doc.find('//xmlns0:names/xmlns0:name')[2].dump == "<name team=\"1\">Michel</name>")
|
85
|
+
assert(doc.find('//xmlns0:names/xmlns0:name')[2].dump == "<name xmlns=\"http://example.org\" team=\"1\">Michel</name>")
|
86
86
|
|
87
87
|
doc = XML::Smart.open(::File.dirname(__FILE__) + "/EXAMPLE-NSE.xml")
|
88
88
|
node = doc.find("//soap:hallo")[0]
|
@@ -94,10 +94,10 @@ class TestBasic < MiniTest::Test
|
|
94
94
|
assert(node.qname.href == "http://schemas.xmlsoap.org/wsdl/soap/")
|
95
95
|
|
96
96
|
node.namespace = 'x'
|
97
|
-
assert(node.dump == "<test:hallo/>")
|
97
|
+
assert(node.dump == "<test:hallo xmlns:test=\"http://xxx.org\"/>")
|
98
98
|
assert(doc.root.namespaces.length == 3)
|
99
99
|
node.namespace = 'xmlns'
|
100
|
-
assert(node.dump == "<hallo/>")
|
100
|
+
assert(node.dump == "<hallo xmlns=\"http://default.org\"/>")
|
101
101
|
|
102
102
|
node = doc.find("/xmlns:test")[0]
|
103
103
|
assert(node.qname.prefix == "")
|
data/test/tc_copy.rb
CHANGED
@@ -32,7 +32,9 @@ class TestCopy < Minitest::Test
|
|
32
32
|
assert(doc.find("/test/*[7]").first.dump == "<name team=\"2\">Kathrin <b>Fiedler</b></name>")
|
33
33
|
assert(doc.find("/test/*[8]").first.dump == "<name team=\"2\">Kathrin <b>Fiedler</b></name>")
|
34
34
|
assert(doc.find("/test/*[9]").first.dump == "<node id=\"1\">\n <text xmlns=\"http://aaa\">I am a text</text>\n</node>")
|
35
|
-
|
35
|
+
|
36
|
+
|
37
|
+
assert(doc.find("/test/*[10]").first.dump == "<soap:node xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" id=\"2\"/>")
|
36
38
|
|
37
39
|
assert(soc.root.dump == "<root xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\">\n <node id=\"1\">\n <text xmlns=\"http://aaa\">I am a text</text>\n </node>\n <soap:node id=\"2\"/>\n</root>")
|
38
40
|
end
|
@@ -27,7 +27,7 @@ class TestNamespaceDefault < Minitest::Test
|
|
27
27
|
n = nsnode.add('x:test') rescue success = false
|
28
28
|
assert(success)
|
29
29
|
|
30
|
-
assert(nsnode.dump == "<hallo>\n <soap:test/>\n</hallo>")
|
30
|
+
assert(nsnode.dump == "<hallo xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\">\n <soap:test/>\n</hallo>")
|
31
31
|
|
32
32
|
assert(nsnode.qname.name == "hallo")
|
33
33
|
assert(nsnode.qname.to_s == "hallo")
|
data/xml-smart.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xml-smart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|