// create a validator for the package.xml
XMLValidationSchemaFactory validationSchemaFactory = XMLValidationSchemaFactory
.newInstance(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA);
// TODO: Is this good enough to get hold of package.xsd? Need to think about this.
URL packageXsd = Thread.currentThread().getContextClassLoader().getResource("package.xsd");
XMLValidationSchema schema = validationSchemaFactory.createSchema(packageXsd);;
// enable validation (note: validation will happen during parse)
xmlStreamReader.validateAgainst(schema);
// parse the xml
PackageType pkgMetadata = null;