xml-smart 0.3.20 → 0.3.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/EXAMPLE.xml +10 -18
- data/example/xpath_visual.rb +5 -4
- data/lib/xml/smart.rb +6 -2
- data/test/EXAMPLE.xml +1 -1
- data/test/tc_relaxng.rb +4 -4
- data/test/tc_xmlschema.rb +4 -4
- 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: 40c589008681cdbad9093b1c87f76c021844e754
|
4
|
+
data.tar.gz: '00709426bbf58d6bf3443588ea0d4b2494160367'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fca7278e5139558178a7831c9017b300ae0a93d188420630b4d684545709acb29669b02e970435cf3e970f5aad1a65568b76d5b71501300148a346c6eba9be99
|
7
|
+
data.tar.gz: 7db350cd7a2b1cae4dfc17d0e0fae606cd7ebaa54cbc273fbcd483e2b7330145f12c210469fbc8e90b831776d4bb26b90b0d3a823fb7d6322b8d32084a185b06
|
data/example/EXAMPLE.xml
CHANGED
@@ -1,18 +1,10 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<colors>
|
12
|
-
<blue taint="true">Yeah</blue>
|
13
|
-
<red taint="true"/>
|
14
|
-
<green taint="true"/>
|
15
|
-
</colors>
|
16
|
-
<hallo>Hallo1</hallo>
|
17
|
-
<soap:hallo>Hallo2</soap:hallo>
|
18
|
-
</test>
|
1
|
+
<Customers>
|
2
|
+
<Customer ID="1">
|
3
|
+
Queen Falafel
|
4
|
+
<Address>Stollgasse</Address>
|
5
|
+
</Customer>
|
6
|
+
<Customer ID="2">
|
7
|
+
Queen Falafel
|
8
|
+
<Address>Wagramerstrasse</Address>
|
9
|
+
</Customer>
|
10
|
+
</Customers>
|
data/example/xpath_visual.rb
CHANGED
@@ -21,11 +21,12 @@ def prnTree(node,depth,mixed)
|
|
21
21
|
node.children.each { |n|
|
22
22
|
case n
|
23
23
|
when XML::Smart::Dom::Element; prnTree(n,depth+2,node.mixed? | mixed)
|
24
|
-
when XML::Smart::Dom::Text;
|
25
|
-
|
24
|
+
when XML::Smart::Dom::Text;
|
25
|
+
print rememberPath(n.path,n.text)
|
26
|
+
end
|
26
27
|
}
|
27
28
|
print " " * depth if node.element_only? && !mixed
|
28
|
-
print "</" + rememberPath(node.path,node.qname.to_s) + ">"
|
29
|
+
print "</" + rememberPath(node.path,node.qname.to_s) + ">"
|
29
30
|
print "\n" unless mixed
|
30
31
|
end
|
31
32
|
|
@@ -43,7 +44,7 @@ begin
|
|
43
44
|
@remember = doc.find(xpath).collect { |n| n.path }
|
44
45
|
else
|
45
46
|
message = tmp
|
46
|
-
end
|
47
|
+
end
|
47
48
|
rescue
|
48
49
|
puts "Invalid XPath!"
|
49
50
|
end
|
data/lib/xml/smart.rb
CHANGED
@@ -36,7 +36,9 @@ module Nokogiri
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def xpath_fast(path)
|
39
|
-
ctx = XPathContext.new(self)
|
39
|
+
@ctx = XPathContext.new(self) unless defined? @ctx
|
40
|
+
ctx = @ctx
|
41
|
+
#ctx = XPathContext.new(self)
|
40
42
|
ctx.register_namespaces(self.document.custom_namespace_prefixes.merge(self.document.user_custom_namespace_prefixes))
|
41
43
|
path = path.gsub(/xmlns:/, ' :') unless Nokogiri.uses_libxml?
|
42
44
|
ctx.evaluate(path)
|
@@ -86,7 +88,9 @@ module Nokogiri
|
|
86
88
|
# return xpath(path,self.document.custom_namespace_prefixes.merge(self.document.user_custom_namespace_prefixes))
|
87
89
|
return NodeSet.new(document) unless document
|
88
90
|
|
89
|
-
ctx = XPathContext.new(self)
|
91
|
+
@ctx = XPathContext.new(self) unless defined? @ctx
|
92
|
+
ctx = @ctx
|
93
|
+
#ctx = XPathContext.new(self)
|
90
94
|
ctx.register_namespaces(self.document.custom_namespace_prefixes.merge(self.document.user_custom_namespace_prefixes))
|
91
95
|
path = path.gsub(/xmlns:/, ' :') unless Nokogiri.uses_libxml?
|
92
96
|
ctx.evaluate(path)
|
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">
|
3
|
+
<name team="0" a="3">2017-12-01 11:51:05 +0100</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/tc_relaxng.rb
CHANGED
@@ -20,9 +20,9 @@ class TestRelaxng < Minitest::Test
|
|
20
20
|
h.qname.name = 'test'
|
21
21
|
end
|
22
22
|
assert(!doc.validate_against(xsd))
|
23
|
-
|
23
|
+
|
24
24
|
doc.validate_against(xsd) do |err|
|
25
|
-
assert("#{err.file} line #{err.line}: #{err.to_s}" =~ /HELLO.xml
|
25
|
+
assert("#{err.file} line #{err.line}: #{err.to_s}" =~ /HELLO.xml .* Did not expect element test there/)
|
26
26
|
end
|
27
|
-
end
|
28
|
-
end
|
27
|
+
end
|
28
|
+
end
|
data/test/tc_xmlschema.rb
CHANGED
@@ -20,9 +20,9 @@ class TestXmlSchema < Minitest::Test
|
|
20
20
|
h.qname.name = 'test'
|
21
21
|
end
|
22
22
|
assert(!doc.validate_against(xsd))
|
23
|
-
|
23
|
+
|
24
24
|
doc.validate_against(xsd) do |err|
|
25
|
-
assert("#{err.file} line #{err.line}: #{err.to_s}" =~ /HELLO.xml
|
25
|
+
assert("#{err.file} line #{err.line}: #{err.to_s}" =~ /HELLO.xml .* Did not expect element test there/)
|
26
26
|
end
|
27
|
-
end
|
28
|
-
end
|
27
|
+
end
|
28
|
+
end
|
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.21
|
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:
|
11
|
+
date: 2017-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|