private static XmlReader GetSchemaXmlStream(string schemaUri, NvdlConfig config, NvdlValidate validate) { var r = config.XmlResolverInternal; if (r == null) { return(null); } Uri baseUri = r.ResolveUri(null, validate.SourceUri); Uri uri = r.ResolveUri(baseUri, validate.SchemaUri); Stream stream = (Stream)r.GetEntity( uri, null, typeof(Stream)); if (stream == null) { return(null); } #if PORTABLE var xtr = XmlReader.Create(stream); #else var xtr = new XmlTextReader(uri != null ? uri.ToString() : String.Empty, stream); xtr.XmlResolver = r; #endif xtr.MoveToContent(); return(xtr); }
public override NvdlValidatorGenerator CreateGenerator ( NvdlValidate validate, string schemaType, NvdlConfig config) { if (schemaType == RncMimeType) return CreateRncGenerator (validate, config); return base.CreateGenerator (validate, schemaType, config); }
public NvdlValidatingReader(XmlReader reader, NvdlRules rules, XmlResolver resolver, NvdlConfig config) : base(reader) { dispatcher = new NvdlDispatcher(new SimpleRules( new NvdlCompileContext( rules, config, resolver)), this); }
static Nvdl() { defaultConfig = new NvdlConfig(); #if !PORTABLE defaultConfig.AddProvider(new NvdlXsdValidatorProvider()); #endif defaultConfig.AddProvider(new NvdlRelaxngValidatorProvider()); }
public NvdlValidatingReader (XmlReader reader, NvdlRules rules, XmlResolver resolver, NvdlConfig config) : base (reader) { dispatcher = new NvdlDispatcher (new SimpleRules ( new NvdlCompileContext ( rules, config, resolver)), this); }
public override NvdlValidatorGenerator CreateGenerator ( XmlReader reader, NvdlConfig config) { if (reader.NamespaceURI != RelaxngGrammar.NamespaceURI) return null; return new NvdlRelaxngValidatorGenerator (RelaxngPattern.Read (reader), config); }
public override NvdlValidatorGenerator CreateGenerator ( XmlReader reader, NvdlConfig config) { reader.MoveToContent (); if (reader.NodeType != XmlNodeType.Element || reader.NamespaceURI != Nvdl.BuiltInValidationNamespace) return null; return new NvdlBuiltInValidatorGenerator (reader.LocalName == "allow"); }
public override NvdlValidatorGenerator CreateGenerator( NvdlValidate validate, string schemaType, NvdlConfig config) { if (schemaType == RncMimeType) { return(CreateRncGenerator(validate, config)); } return(base.CreateGenerator(validate, schemaType, config)); }
public override NvdlValidatorGenerator CreateGenerator( XmlReader reader, NvdlConfig config) { if (reader.NamespaceURI != RelaxngGrammar.NamespaceURI) { return(null); } return(new NvdlRelaxngValidatorGenerator(RelaxngPattern.Read(reader), config)); }
public override NvdlValidatorGenerator CreateGenerator( XmlReader reader, NvdlConfig config) { reader.MoveToContent(); if (reader.NodeType != XmlNodeType.Element || reader.NamespaceURI != Nvdl.BuiltInValidationNamespace) { return(null); } return(new NvdlBuiltInValidatorGenerator(reader.LocalName == "allow")); }
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)); }
private NvdlValidatorGenerator CreateRncGenerator (NvdlValidate validate, NvdlConfig config) { XmlResolver resolver = config.XmlResolverInternal; string schemaUri = GetSchemaUri (validate); if (schemaUri == null) return null; Uri baseUri = resolver.ResolveUri (null, validate.SourceUri); Uri absUri = resolver.ResolveUri (baseUri, schemaUri); RelaxngPattern p = RncParser.ParseRnc ( new StreamReader ((Stream) resolver.GetEntity ( absUri, null, typeof (Stream))), null, absUri.ToString ()); return new NvdlRelaxngValidatorGenerator (p, config); }
private static XmlReader GetSchemaXmlStream (string schemaUri, NvdlConfig config, NvdlValidate validate) { XmlResolver r = config.XmlResolverInternal; if (r == null) return null; Uri baseUri = r.ResolveUri (null, validate.SourceUri); Uri uri = r.ResolveUri (baseUri, validate.SchemaUri); Stream stream = (Stream) r.GetEntity ( uri, null, typeof (Stream)); if (stream == null) return null; XmlTextReader xtr = new XmlTextReader (uri != null ? uri.ToString () : String.Empty, stream); xtr.XmlResolver = r; xtr.MoveToContent (); return xtr; }
public override NvdlValidatorGenerator CreateGenerator ( XmlReader reader, NvdlConfig config) { if (reader.NamespaceURI != XmlSchema.Namespace) return null; ArrayList al = new ArrayList (); while (!reader.EOF) { if (reader.NodeType != XmlNodeType.Element) { reader.Read (); continue; } reader.MoveToContent (); XmlSchema xs = XmlSchema.Read (reader, null); xs.Compile (null, config.XmlResolverInternal); al.Add (xs); reader.Read (); } return new NvdlXsdValidatorGenerator (al.ToArray (typeof (XmlSchema)) as XmlSchema []); }
private NvdlValidatorGenerator CreateRncGenerator(NvdlValidate validate, NvdlConfig config) { XmlResolver resolver = config.XmlResolverInternal; string schemaUri = GetSchemaUri(validate); if (schemaUri == null) { return(null); } Uri baseUri = resolver.ResolveUri(null, validate.SourceUri); Uri absUri = resolver.ResolveUri(baseUri, schemaUri); RelaxngPattern p = RncParser.ParseRnc( new StreamReader((Stream)resolver.GetEntity( absUri, null, typeof(Stream))), null, absUri.ToString()); return(new NvdlRelaxngValidatorGenerator(p, config)); }
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); }
public override NvdlValidatorGenerator CreateGenerator( XmlReader reader, NvdlConfig config) { if (reader.NamespaceURI != XmlSchema.Namespace) { return(null); } ArrayList al = new ArrayList(); while (!reader.EOF) { if (reader.NodeType != XmlNodeType.Element) { reader.Read(); continue; } reader.MoveToContent(); XmlSchema xs = XmlSchema.Read(reader, null); xs.Compile(null, config.XmlResolverInternal); al.Add(xs); reader.Read(); } return(new NvdlXsdValidatorGenerator(al.ToArray(typeof(XmlSchema)) as XmlSchema [])); }
static Nvdl() { defaultConfig = new NvdlConfig(); defaultConfig.AddProvider(new NvdlXsdValidatorProvider()); defaultConfig.AddProvider(new NvdlRelaxngValidatorProvider()); }
public NvdlRelaxngValidatorGenerator (RelaxngPattern p, NvdlConfig config) { // FIXME: use XmlResolver pattern = p; }
public NvdlCompileContext(NvdlRules rules, NvdlConfig config, XmlResolver resolver) { this.rules = rules; this.config = config; this.resolver = resolver; }
public NvdlRelaxngValidatorGenerator(RelaxngPattern p, NvdlConfig config) { // FIXME: use XmlResolver pattern = p; }
public virtual NvdlValidatorGenerator CreateGenerator(XmlReader schema, NvdlConfig config) { return(null); }
public NvdlCompileContext (NvdlRules rules, NvdlConfig config, XmlResolver resolver) { this.rules = rules; this.config = config; this.resolver = resolver; }
static Nvdl () { defaultConfig = new NvdlConfig (); defaultConfig.AddProvider (new NvdlXsdValidatorProvider ()); defaultConfig.AddProvider (new NvdlRelaxngValidatorProvider ()); }
public virtual NvdlValidatorGenerator CreateGenerator (XmlReader schema, NvdlConfig config) { return null; }