Ejemplo n.º 1
0
        public RelaxngPattern ReadExternalResource(RelaxngGrammar grammar, Uri uri, string nsContext)
        {
            XmlReader      xtr = null;
            RelaxngGrammar g   = null;
            RelaxngPattern p;

            try {
                if (uri.AbsolutePath.EndsWith(".rnc", StringComparison.OrdinalIgnoreCase))
                {
                    p = RncParser.ParseRnc(new StreamReader((Stream)grammar.Resolver.GetEntity(uri, null, typeof(Stream))), null, uri.AbsoluteUri, nsContext);
                }
                else
                {
#if PORTABLE
                    xtr = XmlReader.Create((Stream)grammar.Resolver.GetEntity(uri, null, typeof(Stream)));
#else
                    xtr = new XmlTextReader(uri.AbsoluteUri, (Stream)grammar.Resolver.GetEntity(uri, null, typeof(Stream)));
#endif
                    RelaxngReader r = new RelaxngReader(xtr, nsContext, grammar.Resolver);
                    r.MoveToContent();
                    p = r.ReadPattern();
                }
            } catch (Exception ex) {             // umm, bad catch though :-(
                throw new RelaxngException(this, String.Format("Could not include grammar {0}: {1}", uri.AbsoluteUri, ex.Message), ex);
            } finally {
                if (xtr != null)
                {
                    xtr.Dispose();
                }
            }
            p.XmlResolver = grammar.Resolver;
            return(p);
        }
Ejemplo n.º 2
0
        public RelaxngPattern ReadExternalResource(RelaxngGrammar grammar, Uri uri, string nsContext)
        {
            XmlTextReader  xtr = null;
            RelaxngGrammar g   = null;
            RelaxngPattern p;

            try {
                if (grammar.IsSourceCompactSyntax)
                {
                    p = RncParser.ParseRnc(new StreamReader((Stream)grammar.Resolver.GetEntity(uri, null, typeof(Stream))), null, BaseUri, nsContext);
                }
                else
                {
                    xtr = new XmlTextReader(uri.AbsoluteUri, (Stream)grammar.Resolver.GetEntity(uri, null, typeof(Stream)));
                    RelaxngReader r = new RelaxngReader(xtr, nsContext, grammar.Resolver);
                    r.MoveToContent();
                    p = r.ReadPattern();
                }
            } catch (Exception ex) {             // umm, bad catch though :-(
                throw new RelaxngException(this, String.Format("Could not include grammar {0}: {1}", uri.AbsoluteUri, ex.Message), ex);
            } finally {
                if (xtr != null)
                {
                    xtr.Close();
                }
            }
            p.XmlResolver = grammar.Resolver;
            return(p);
        }
Ejemplo n.º 3
0
		public static RelaxngPattern Read (XmlReader xmlReader, RelaxngDatatypeProvider provider, XmlResolver xmlResolver)
		{
			RelaxngReader r = new RelaxngReader (xmlReader, null, xmlResolver);
			if (r.ReadState == ReadState.Initial)
				r.Read ();
			r.MoveToContent ();
			RelaxngPattern p = r.ReadPattern ();
			p.DataProvider = provider;
			p.XmlResolver = xmlResolver;
			return p;
		}
Ejemplo n.º 4
0
		public RelaxngPattern ReadExternalResource (RelaxngGrammar grammar, Uri uri, string nsContext)
		{
			XmlTextReader xtr = null;
			RelaxngGrammar g = null;
			RelaxngPattern p;
			try {
				if (uri.AbsolutePath.EndsWith(".rnc", StringComparison.InvariantCultureIgnoreCase)) {
					p = RncParser.ParseRnc (new StreamReader ((Stream) grammar.Resolver.GetEntity (uri, null, typeof (Stream))), null, uri.AbsoluteUri, nsContext);
				} else {
					xtr = new XmlTextReader (uri.AbsoluteUri, (Stream) grammar.Resolver.GetEntity (uri, null, typeof (Stream)));
					RelaxngReader r = new RelaxngReader (xtr, nsContext, grammar.Resolver);
					r.MoveToContent ();
					p = r.ReadPattern ();
				}
			} catch (Exception ex) { // umm, bad catch though :-(
				throw new RelaxngException (this, String.Format("Could not include grammar {0}: {1}", uri.AbsoluteUri, ex.Message), ex);
			} finally {
				if (xtr != null)
					xtr.Close ();
			}
			p.XmlResolver = grammar.Resolver;
			return p;
		}
Ejemplo n.º 5
0
		public static RelaxngPattern Read (XmlReader xmlReader, RelaxngDatatypeProvider provider, XmlResolver xmlResolver)
		{
			RelaxngReader r = new RelaxngReader (xmlReader, null, xmlResolver);
			if (r.ReadState == ReadState.Initial)
				r.Read ();
			r.MoveToContent ();
			RelaxngPattern p = r.ReadPattern ();
			p.DataProvider = provider;
			p.XmlResolver = xmlResolver;
			return p;
		}
		public RelaxngPattern ReadExternalResource (RelaxngGrammar grammar, Uri uri, string nsContext)
		{
			XmlTextReader xtr = null;
			RelaxngGrammar g = null;
			try {
				if (grammar.IsSourceCompactSyntax) {
					return RncParser.ParseRnc (new StreamReader ((Stream) grammar.Resolver.GetEntity (uri, null, typeof (Stream))), null, BaseUri, nsContext);
				} else {
					xtr = new XmlTextReader (uri.AbsoluteUri, (Stream) grammar.Resolver.GetEntity (uri, null, typeof (Stream)));
					RelaxngReader r = new RelaxngReader (xtr, nsContext, grammar.Resolver);
					r.MoveToContent ();
					return r.ReadPattern ();
				}
			} catch (Exception ex) { // umm, bad catch though :-(
				throw new RelaxngException (this, String.Format("Could not include grammar {0}: {1}", uri.AbsoluteUri, ex.Message), ex);
			} finally {
				if (xtr != null)
					xtr.Close ();
			}
		}