xcop 0.10.1 → 0.10.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa89e4f1fcf4bd98059669b6fdd5dfae445a9c6fc43bbee41486f974b8d7af6e
4
- data.tar.gz: 32f664bba8e5dc4450919c6af6f19146a80d97ef9bc5db595cbd4800afd8d9e2
3
+ metadata.gz: d60b5b604d878305feaee1897024cdb25f422e817e3c8fdd6ad03763d055e9fe
4
+ data.tar.gz: 5d778bf7c386b682cb8f0d1df07c927e0c978c2a3c6c80d85b6cbfe5511f5052
5
5
  SHA512:
6
- metadata.gz: 9fc34e6689bb4f67f3f14c764f2443764daf856b6b4c5be763b07bc9b4ab0003b3841fdb38c3120478dfc9e1f93d23462c8021c4d189ec9a4cf69a60c588200d
7
- data.tar.gz: 71fae53f841ad1cb2ff31e3ca741d4d167643099daad5d270aac8aaac86732b3851c659d18974a707d51f01f4fae1eb7742324681d3ce7aca3b295ddd38776a2
6
+ metadata.gz: b2ab0ed8903b36aa5dd062e6056209166425c39801ef03dc61650e721af42715b39aaa11f325ea8f8f860aad3acaf826ae469591154337a8aab73dd98e564b64
7
+ data.tar.gz: e8127c93fe4d435a775394a77bd737d3203243fdbb957207c32257f7905060a1eb264ce39484f1a1e518ce85528990bc9d30bcb7f239df2d33b7b08a235fcbbd
data/lib/xcop/document.rb CHANGED
@@ -46,6 +46,8 @@ class Xcop::Document
46
46
 
47
47
  XSI_NS = 'http://www.w3.org/2001/XMLSchema-instance'.freeze
48
48
 
49
+ PREFIX_LISTS = %w[exclude-result-prefixes extension-element-prefixes].freeze
50
+
49
51
  private
50
52
 
51
53
  # The canonical, well-formatted version of the document.
@@ -110,7 +112,13 @@ class Xcop::Document
110
112
  # prefix only inside +select+, +test+, +match+, +as+, +use+ and
111
113
  # similar attributes (e.g. +as="xs:integer"+ or +select="eo:foo()"+),
112
114
  # so stripping such a "declared but not QName-used" prefix would break
113
- # the stylesheet. See #161.
115
+ # the stylesheet. See #161. A prefix is used, too, when it is named in an
116
+ # +exclude-result-prefixes+ or +extension-element-prefixes+ attribute;
117
+ # these list bare prefixes with no colon, so the +prefix:+ scan never
118
+ # catches them, yet XSLT requires every prefix named there to resolve to
119
+ # a declared namespace (dropping the declaration is the static error
120
+ # XTSE0808). The token +#default+ refers to the default namespace. See
121
+ # #165.
114
122
  def unused(xml)
115
123
  used = Set.new
116
124
  declared = Set.new
@@ -120,12 +128,24 @@ class Xcop::Document
120
128
  node.attribute_nodes.each do |attr|
121
129
  used << attr.namespace.prefix if attr.namespace
122
130
  attr.value.scan(/([A-Za-z_][\w.-]*):/) { |m| used << m.first }
131
+ next unless PREFIX_LISTS.include?(attr.name)
132
+ attr.value.split.each { |token| used << (token == '#default' ? nil : token) }
123
133
  end
124
134
  node.namespace_definitions.each { |ns| declared << ns.prefix }
125
135
  end
126
136
  declared - used
127
137
  end
128
138
 
139
+ # Returns the absolute path of the local XSD schema declared by +xml+,
140
+ # or +nil+ when no schema is declared or the declared location is not a
141
+ # local file. The location comes from +xsi:noNamespaceSchemaLocation+
142
+ # or, failing that, from the second token of +xsi:schemaLocation+.
143
+ #
144
+ # A +schemaLocation+ is a URI, not a file path, so a remote schema such
145
+ # as +http://maven.apache.org/xsd/maven-4.0.0.xsd+ (the normal case for
146
+ # Maven +pom.xml+, +settings.xml+ and +site.xml+) must not be treated as
147
+ # a local file. Any location that carries a URL scheme is therefore
148
+ # skipped, leaving only truly local schemas to be validated. See #163.
129
149
  def schema(xml)
130
150
  root = xml.root
131
151
  return unless root
@@ -138,6 +158,7 @@ class Xcop::Document
138
158
  mapped.value.split.last
139
159
  end
140
160
  return unless location
161
+ return if location.match?(%r{\A[a-z][a-z0-9+.-]*://}i)
141
162
  File.expand_path(location, File.dirname(@path))
142
163
  end
143
164
 
data/lib/xcop/version.rb CHANGED
@@ -6,5 +6,5 @@
6
6
  # Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
7
7
  # License:: MIT
8
8
  module Xcop
9
- VERSION = '0.10.1'.freeze
9
+ VERSION = '0.10.3'.freeze
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko