If you are referencing remote schemas, download them and put them together in the same directory. If you already have xsd files on your computer, just merge them into one directory. Then change xsd to use relative path. For instance:
Change it
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
to
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
Then wrap the verification code inside the call to Dir.chdir. Like this:
Dir.chdir(somewhere) do schema = Nokogiri::XML::Schema(IO.read('your-schema.xsd')) doc = Nokogiri::XML(IO.read(doc_path)) schema.validate(doc) end
Found a solution in this post:
http://ktulu.com.ar/blog/2011/06/26/resolving-validation-errors-using-nokogiri-and-schemas/
source share