public virtual NvdlValidatorGenerator CreateGenerator (NvdlValidate validate, string schemaType, NvdlConfig config)
{
this.validate = validate;
this.schema_type = schemaType;
this.config = config;
XmlReader schema = null;
// FIXME: we need a bit more strict check.
if (schemaType.Length < 5 ||
!schemaType.EndsWith ("xml") ||
Char.IsLetter (schemaType, schemaType.Length - 4))
return null;
string schemaUri = validate.SchemaUri;
XmlElement schemaBody = validate.SchemaBody;
if (schemaUri != null) {
if (schemaBody != null)
throw new NvdlCompileException ("Both 'schema' attribute and 'schema' element are specified in a 'validate' element.", validate);
schema = GetSchemaXmlStream (schemaUri, config, validate);
}
else if (validate.SchemaBody != null) {
XmlReader r = new XmlNodeReader (schemaBody);
r.MoveToContent ();
r.Read (); // Skip "schema" element
r.MoveToContent ();
if (r.NodeType == XmlNodeType.Element)
schema = r;
else
schema = GetSchemaXmlStream (r.ReadString (), config, validate);
}
if (schema == null)
return null;
return CreateGenerator (schema, config);
}