Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
#329 xslversions extra check
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Mar 15, 2018
1 parent 95aa103 commit 8fba4ae
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CLEAN.include 'target'

task :default, [:version] => %i[
clean xsd
xslversions
xsl xsltest auto xcop underscores
rubocop copyright
]
Expand Down Expand Up @@ -109,6 +110,19 @@ task :upgrades, [:version] do |_, args|
puts "\nAll XSL upgrades are clean\n\n"
end

desc 'Validate all XSL files for versions'
task :xslversions do
puts 'Checking versions of XSL files...'
Dir['**/*.xsl'].each do |p|
stylesheet = Nokogiri::XML(File.open(p))
ver = stylesheet.xpath(
'/xsl:stylesheet/@version',
'xsl' => 'http://www.w3.org/1999/XSL/Transform'
)[0].to_s
raise "XSL version #{ver} is not 2.0 in #{p}" unless ver == '2.0'
end
end

desc 'Validate all XML/XSL files'
task :xsl do
puts 'Checking XML and XSL files...'
Expand All @@ -121,12 +135,6 @@ task :xsl do
total = 0
xsls = Dir['xsl/**/*.xsl']
xsls.each do |p|
stylesheet = Nokogiri::XML(File.open(p))
ver = stylesheet.xpath(
'/xsl:stylesheet/@version',
'xsl' => 'http://www.w3.org/1999/XSL/Transform'
)[0].to_s
raise "XSL version #{ver} is not 2.0 in #{p}" unless ver == '2.0'
next if File.basename(p) == 'templates.xsl'
f = p.sub(%r{xsl/}, 'xml/').sub(%r{/([^/]+)\.xsl$}, '/\1/simple.xml')
xslt = Nokogiri::XSLT(File.open(p))
Expand Down

0 comments on commit 8fba4ae

Please sign in to comment.