I have found several sources regarding how to validate an xml document against a schema, but I have an application in ruby in which I need to validate that a user supplied schema is a valid schema itself. Is there a way to that I can check this? Is there an XSD schema to validate an XSD schema? Or are there libraries or gems that do this for me?
The WSRR web user interface validates each definition file when starting, and when new or updated definition files are loaded. This is done according to the definition XML Schema Definition (XSD).
You can use Nokogiri for this:
begin
schema = Nokogiri::XML::Schema(File.read('invalid_schema.xsd'))
rescue Nokogiri::XML::SyntaxError => e
puts "Invalid XML Schema!"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With