Skip to content

Instantly share code, notes, and snippets.

@superchris
Created January 8, 2011 19:38
Show Gist options
  • Save superchris/771088 to your computer and use it in GitHub Desktop.
Save superchris/771088 to your computer and use it in GitHub Desktop.
require 'java'
java_import javax.xml.XMLConstants
java_import javax.xml.transform.Source
java_import javax.xml.transform.stream.StreamSource
java_import javax.xml.validation.SchemaFactory
java_import javax.xml.validation.Schema
java_import javax.xml.validation.Validator
schema_factory = SchemaFactory.new_instance(XMLConstants::W3C_XML_SCHEMA_NS_URI)
schema = schema_factory.new_schema([
StreamSource.new(java.io.StringReader.new(File.read("./schemas/cct.xsd")), "urn:un:unece:uncefact:documentation:standard:CoreComponentType:2"),
StreamSource.new(java.io.StringReader.new(File.read("./schemas/CCOM-ML.xsd")))
].to_java(Source))
schema.new_validator.validate StreamSource.new(java.io.StringReader.new(File.read("asset.xml")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment