public void Compile() { RelaxngGrammar g = null; if (this is RelaxngGrammar) { g = (RelaxngGrammar)this; } else { g = new RelaxngGrammar(); g.XmlResolver = this.Resolver; g.BaseUri = this.BaseUri; g.LineNumber = this.LineNumber; g.LinePosition = this.LinePosition; RelaxngStart st = new RelaxngStart(); st.BaseUri = this.BaseUri; st.LineNumber = this.LineNumber; st.LinePosition = this.LinePosition; st.Pattern = this; g.Starts.Add(st); g.Provider = provider; } startRelaxngPattern = g.Compile(null); this.IsCompiled = true; }
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); }
void WriteCompact (RncWriter writer) { RelaxngGrammar g = this as RelaxngGrammar; string ns = (g != null ? g.DefaultNamespace : null); writer.WriteNamespaces (ns); WriteRnc (writer); }
internal override RdpPattern Compile(RelaxngGrammar grammar) { // RdpParamList rdpl = new RdpParamList (); // foreach (RelaxngParam prm in this.paramList) // rdpl.Add (prm.Compile (grammar)); RdpPattern p = null; if (this.except != null) { if (except.Patterns.Count == 0) { throw new RelaxngException(this, "data except pattern have no children."); } p = except.Patterns [0].Compile(grammar); for (int i = 1; i < except.Patterns.Count; i++) { p = new RdpChoice(p, except.Patterns [i].Compile(grammar)); } } IsCompiled = true; if (this.except != null) { return(new RdpDataExcept(new RdpDatatype(DatatypeLibrary, Type, ParamList, grammar.Provider), p)); } else { return(new RdpData(new RdpDatatype(DatatypeLibrary, Type, ParamList, grammar.Provider))); } }
internal RdpPattern makeBinary (RelaxngGrammar g) { // Flatten patterns. See 4.12. if (patterns.Count == 0) throw new RelaxngException (this, "No pattern contents."); RdpPattern p = ((RelaxngPattern) patterns [0]).Compile (g); if (patterns.Count == 1) return p; for (int i=1; i<patterns.Count; i++) { RdpPattern cp = ((RelaxngPattern) patterns [i]).Compile (g); switch (this.PatternType) { case RelaxngPatternType.Choice: p = new RdpChoice (p, cp); break; case RelaxngPatternType.Group: p = new RdpGroup (p, cp); break; case RelaxngPatternType.Interleave: p = new RdpInterleave (p, cp); break; } } return p; }
internal override RdpPattern Compile(RelaxngGrammar grammar) { IsCompiled = true; return(new RdpChoice( new RdpOneOrMore(makeSingle(grammar)), RdpEmpty.Instance)); }
public RelaxngGrammar InferSchema (XmlReader xmlReader, RelaxngGrammar grammar) { return RngInference.Process (xmlReader, grammar, occurrence == InferenceOption.Relaxed, typeInference == InferenceOption.Relaxed); }
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); }
public static RelaxngGrammar Process (XmlReader xmlReader, RelaxngGrammar grammar, bool laxOccurence, bool laxTypeInference) { RngInference impl = new RngInference (xmlReader, grammar, laxOccurence, laxTypeInference); impl.Run (); return impl.grammar; }
internal override RdpPattern Compile (RelaxngGrammar grammar) { IsCompiled = true; RdpNameClass cnc = nc.Compile (grammar); this.checkInvalidAttrNameClass (cnc); return new RdpAttribute (cnc, (p != null) ? p.Compile (grammar) : RdpText.Instance); }
private static string GetUniqueName(string name, RelaxngGrammar grammar) { foreach (RelaxngDefine def in grammar.Defines) { if (def.Name == name) { return(GetUniqueName(name + '_', grammar)); } } return(name); }
internal void Compile (RelaxngGrammar grammar) { foreach (RelaxngDiv div in divs) div.Compile (grammar); foreach (RelaxngInclude inc in includes) inc.Compile (grammar).Compile (grammar); // compile compiled divs foreach (RelaxngStart start in starts) grammar.Starts.Add (start); foreach (RelaxngDefine define in defines) grammar.Defines.Add (define); }
private RelaxngGrammar ReadGrammarPattern() { RelaxngGrammar grammar = new RelaxngGrammar(); FillLocation(grammar); grammar.DefaultNamespace = Reader.GetAttribute("ns"); Read(); this.readGrammarIncludeContent(grammar.Starts, grammar.Defines, grammar.Divs, grammar.Includes); expectEnd("grammar"); return(grammar); }
private void ResetCompileState() { startPattern = null; assembledDefs.Clear(); assembledStart = null; compiledStart = null; elementReplacedDefs.Clear(); includedUris.Clear(); parentGrammar = null; refPatterns.Clear(); checkedDefs.Clear(); unresolvedPatterns.Clear(); ElementDefMap.Clear(); }
private RdpPattern makeSingle (RelaxngGrammar g) { // Flatten patterns into RdpGroup. See 4.12. if (patterns.Count == 0) throw new RelaxngException (this, "No pattern contents."); RdpPattern p = ((RelaxngPattern) patterns [0]).Compile (g); if (patterns.Count == 1) return p; for (int i=1; i<patterns.Count; i++) { p = new RdpGroup (p, ((RelaxngPattern) patterns [i]).Compile (g)); } return p; }
internal override RdpNameClass Compile(RelaxngGrammar g) { if (except != null) { RdpNameClass exc = except.Compile(g); if (FindInvalidType(exc, true)) { throw new RelaxngException(except, "anyName except cannot have anyName children."); } return(new RdpAnyNameExcept(exc)); } else { return(RdpAnyName.Instance); } }
internal override RdpNameClass Compile(RelaxngGrammar g) { if (except != null) { RdpNameClass exc = except.Compile(g); if (FindInvalidType(exc, false)) { throw new RelaxngException(except, "nsName except cannot have anyName nor nsName children."); } return(new RdpNsNameExcept(ns, exc)); } else { return(new RdpNsName(ns)); } }
internal override RdpPattern Compile (RelaxngGrammar grammar) { grammar.CheckIncludeRecursion (Href); grammar.IncludedUris.Add (Href, Href); if (grammar.Resolver == null) throw new RelaxngException (this, "To compile 'include' element, XmlResolver is required."); Uri uri = grammar.Resolver.ResolveUri (BaseUri != String.Empty ? new Uri (BaseUri) : null, Href); RelaxngPattern p = ReadExternalResource (grammar, uri, ns); p.DataProvider = grammar.Provider; RdpPattern ret = p.Compile (grammar); grammar.IncludedUris.Remove (Href); return ret; }
internal RdpNameClass Compile(RelaxngGrammar g) { // Flatten names into RdpGroup. See 4.12. if (names.Count == 0) { return(null); } RdpNameClass p = ((RelaxngNameClass)names [0]).Compile(g); for (int i = 1; i < names.Count; i++) { p = new RdpNameClassChoice( ((RelaxngNameClass)names [i]).Compile(g), p); } return(p); }
internal override RdpNameClass Compile(RelaxngGrammar g) { // Flatten names into RdpChoice. See 4.12. if (names.Count == 0) { return(null); } RdpNameClass p = ((RelaxngNameClass)names [0]).Compile(g); if (names.Count == 1) { return(p); } for (int i = 1; i < names.Count; i++) { p = new RdpNameClassChoice(p, ((RelaxngNameClass)names [i]).Compile(g)); } 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 (); } }
// compile into div internal RelaxngDiv Compile(RelaxngGrammar grammar) { grammar.CheckIncludeRecursion(Href); grammar.IncludedUris.Add(Href); if (grammar.Resolver == null) { throw new RelaxngException(this, "To compile 'include' element, XmlResolver is required."); } Uri baseUri = null; try { if (BaseUri != null && BaseUri != String.Empty) { baseUri = new Uri(BaseUri); } #if PORTABLE } catch { throw; } #else } catch (UriFormatException) {
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; }
internal RdpPattern Compile(RelaxngGrammar grammar) { return(makeSingle(grammar)); }
internal override RdpPattern Compile(RelaxngGrammar grammar) { return(RdpNotAllowed.Instance); }
internal override RdpPattern Compile (RelaxngGrammar grammar) { IsCompiled = true; return new RdpChoice ( makeSingle (grammar), RdpEmpty.Instance); }
private RelaxngGrammar ReadGrammarPattern () { RelaxngGrammar grammar = new RelaxngGrammar (); FillLocation (grammar); grammar.DefaultNamespace = Reader.GetAttribute ("ns"); Read (); this.readGrammarIncludeContent (grammar.Starts, grammar.Defines, grammar.Divs, grammar.Includes); expectEnd ("grammar"); return grammar; }
// Compile from this simplified syntax to derivatives. internal override RdpPattern Compile(RelaxngGrammar grammar) { ResetCompileState(); parentGrammar = grammar; // First, process includes and divs. RELAX NG 4.1 - 4.15. ArrayList compiledDivs = new ArrayList(); foreach (RelaxngInclude inc in includes) { compiledDivs.Add(inc.Compile(this)); } compiledDivs.AddRange(divs); foreach (RelaxngDiv div in compiledDivs) { div.Compile(this); } // Check constraints. RELAX NG 4.16 foreach (RelaxngStart start in starts) { start.Pattern.CheckConstraints(); } foreach (RelaxngDefine define in defs) { foreach (RelaxngPattern p in define.Patterns) { p.CheckConstraints(); } } // Assemble combine into the same name defines/start. // see RELAX NG 4.17. AssembleCombine(); // 4.18 : <grammar> must have at least one <start>. if (assembledStart == null) { throw new RelaxngException("A grammar elements must contain at least one start element."); } compiledStart = assembledStart.Compile(this); // Assemble all define components into top grammar and // return start patterns for descendant grammars. // see RELAX NG 4.18. CollectGrammars(); if (parentGrammar != null) { return(compiledStart); } assembledStart = null; // no use anymore // 4.19 (a) remove non-reachable defines /* * compiledStart.MarkReachableDefs (); * ArrayList tmp = new ArrayList (); * foreach (DictionaryEntry entry in this.assembledDefs) * if (!reachableDefines.ContainsKey (entry.Key)) * tmp.Add (entry.Key); * foreach (string key in tmp) * assembledDefs.Remove (key); */ // 4.19 (b) check illegal recursion CheckRecursion(compiledStart, 0); // here we collected element-replaced definitions foreach (DictionaryEntry entry in elementReplacedDefs) { assembledDefs.Add(entry.Key, entry.Value); } startPattern = compiledStart; // 4.20,21 reduce notAllowed and empty. bool b; do { b = false; startPattern = startPattern.ReduceEmptyAndNotAllowed(ref b, new Hashtable()); }while (b); Hashtable ht = new Hashtable(); startPattern.setInternTable(ht); // Check Constraints: RELAX NG spec 7 // 7.1.1-4, 7.3, 7.4 startPattern.CheckConstraints(false, false, false, false, false, false); // 7.1.5 CheckStartPatternContent(startPattern); // 4.19 (c) expandRef - actual replacement startPattern = compiledStart.ExpandRef(assembledDefs); // 7.2 RdpContentType ct = startPattern.ContentType; // return its start pattern. IsCompiled = true; return(startPattern); }
internal RdpPattern Compile (RelaxngGrammar grammar) { return makeSingle (grammar); }
internal abstract RdpNameClass Compile (RelaxngGrammar g);
internal override RdpPattern Compile (RelaxngGrammar grammar) { return RdpNotAllowed.Instance; }
internal override RdpPattern Compile (RelaxngGrammar grammar) { return RdpText.Instance; }
internal abstract RdpPattern Compile (RelaxngGrammar grammar);
public void Compile () { RelaxngGrammar g = null; if (this is RelaxngGrammar) g = (RelaxngGrammar) this; else { g = new RelaxngGrammar (); g.XmlResolver = this.Resolver; g.BaseUri = this.BaseUri; g.LineNumber = this.LineNumber; g.LinePosition = this.LinePosition; RelaxngStart st = new RelaxngStart (); st.BaseUri = this.BaseUri; st.LineNumber = this.LineNumber; st.LinePosition = this.LinePosition; st.Pattern = this; g.Starts.Add (st); g.Provider = provider; } startRelaxngPattern = g.Compile (null); this.IsCompiled = true; }
internal override RdpNameClass Compile (RelaxngGrammar g) { if (except != null) { RdpNameClass exc = except.Compile (g); if (FindInvalidType (exc, false)) throw new RelaxngException (except, "nsName except cannot have anyName nor nsName children."); return new RdpNsNameExcept (ns, exc); } else { return new RdpNsName (ns); } }
internal override RdpPattern Compile (RelaxngGrammar grammar) { // RdpParamList rdpl = new RdpParamList (); // foreach (RelaxngParam prm in this.paramList) // rdpl.Add (prm.Compile (grammar)); RdpPattern p = null; if (this.except != null) { if (except.Patterns.Count == 0) throw new RelaxngException (this, "data except pattern have no children."); p = except.Patterns [0].Compile (grammar); for (int i=1; i<except.Patterns.Count; i++) p = new RdpChoice (p, except.Patterns [i].Compile (grammar)); } IsCompiled = true; if (this.except != null) return new RdpDataExcept (new RdpDatatype (DatatypeLibrary, Type, ParamList, grammar.Provider), p); else return new RdpData (new RdpDatatype (DatatypeLibrary, Type, ParamList, grammar.Provider)); }
internal override RdpNameClass Compile (RelaxngGrammar g) { // Flatten names into RdpChoice. See 4.12. if (names.Count == 0) return null; RdpNameClass p = ((RelaxngNameClass) names [0]).Compile (g); if (names.Count == 1) return p; for (int i=1; i<names.Count; i++) p = new RdpNameClassChoice (p, ((RelaxngNameClass) names [i]).Compile (g)); return p; }
internal override RdpPattern Compile (RelaxngGrammar grammar) { IsCompiled = true; return new RdpValue (new RdpDatatype (DatatypeLibrary, Type, null, grammar.Provider), value); }
// compile into div internal RelaxngDiv Compile (RelaxngGrammar grammar) { grammar.CheckIncludeRecursion (Href); grammar.IncludedUris.Add (Href, Href); if (grammar.Resolver == null) throw new RelaxngException (this, "To compile 'include' element, XmlResolver is required."); Uri baseUri = null; try { if (BaseUri != null && BaseUri != String.Empty) baseUri = new Uri (BaseUri); } catch (UriFormatException) { if (File.Exists (BaseUri)) baseUri = new Uri (Path.GetFullPath (BaseUri)); } Uri uri = grammar.Resolver.ResolveUri (baseUri, Href); RelaxngGrammar g = ReadExternalResource (grammar, uri, (ns != null && ns.Length != 0) || !grammar.IsSourceCompactSyntax ? ns : grammar.DefaultNamespace) as RelaxngGrammar; if (g == null) throw new RelaxngException (this, "Included syntax must start with \"grammar\" element."); g.DataProvider = grammar.Provider; g.IsSourceCompactSyntax = grammar.IsSourceCompactSyntax; // process recursive inclusions. foreach (RelaxngInclude inc in g.Includes) g.Divs.Add (inc.Compile (grammar)); // process this own div children. // each div subelements are also compiled. foreach (RelaxngDiv cdiv in divs) cdiv.Compile (g); foreach (RelaxngDiv cdiv in g.Divs) cdiv.Compile (g); // replace redifinitions into div. // starts. if (this.Starts.Count > 0 && g.Starts.Count == 0) throw new RelaxngException (this, "When the included grammar does not contain start components, this include component must not contain start components."); RelaxngGrammarContentList appliedStarts = (this.starts.Count > 0) ? this.starts : g.Starts; RelaxngDiv div = new RelaxngDiv (); div.BaseUri = this.BaseUri; div.LinePosition = this.LinePosition; div.LineNumber = this.LineNumber; foreach (RelaxngStart start in appliedStarts) div.Starts.Add (start); // defines. Hashtable overrides = new Hashtable (); Hashtable originalDefs = new Hashtable (); foreach (RelaxngDefine def in defines) { overrides.Add (def.Name, def.Name); div.Defines.Add (def); } foreach (RelaxngDefine def in g.Defines) { originalDefs [def.Name] = def.Name; if (!overrides.ContainsKey (def.Name)) { div.Defines.Add (def); } // else discard. } foreach (string name in overrides.Values) if (!originalDefs.ContainsKey (name)) throw new RelaxngException (this, "The include component must not contain define components whose name does not appear in the included grammar component."); grammar.IncludedUris.Remove (Href); return div; }
internal override RdpPattern Compile (RelaxngGrammar grammar) { IsCompiled = true; return new RdpList (makeSingle (grammar)); }
// 4.19 (b) private void CheckRecursion(RdpPattern p, int depth) { RdpAbstractBinary binary = p as RdpAbstractBinary; if (binary != null) { // choice, interleave, group CheckRecursion(binary.LValue, depth); CheckRecursion(binary.RValue, depth); return; } RdpAbstractSingleContent single = p as RdpAbstractSingleContent; if (single != null) { CheckRecursion(single.Child, depth); return; } switch (p.PatternType) { case RelaxngPatternType.Ref: // get checkRecursionDepth from table. int checkRecursionDepth = -1; object checkedDepth = checkedDefs [p]; if (checkedDepth != null) { checkRecursionDepth = (int)checkedDepth; } // get refPattern RdpUnresolvedRef pref = p as RdpUnresolvedRef; RelaxngGrammar target = pref.TargetGrammar; RdpPattern refPattern = pref.RefPattern; if (refPattern == null) { // FIXME: fill line info throw new RelaxngException("No matching define found for " + pref.Name); } if (checkRecursionDepth == -1) { checkedDefs [p] = depth; /*test*/ if (refPattern.PatternType != RelaxngPatternType.Element) { CheckRecursion(refPattern, depth); } checkedDefs [p] = -2; } else if (depth == checkRecursionDepth) { // FIXME: fill line info throw new RelaxngException(String.Format("Detected illegal recursion. Ref name is {0}.", pref.Name)); } break; case RelaxngPatternType.Attribute: CheckRecursion(((RdpAttribute)p).Children, depth); break; case RelaxngPatternType.DataExcept: CheckRecursion(((RdpDataExcept)p).Except, depth); break; case RelaxngPatternType.Element: RdpElement el = p as RdpElement; CheckRecursion(el.Children, depth + 1); // +1 break; case RelaxngPatternType.List: CheckRecursion(((RdpList)p).Child, depth); break; } }
internal override RdpPattern Compile (RelaxngGrammar grammar) { return new RdpElement ( nc.Compile (grammar), this.makeSingle (grammar)); }
// remove ref and parentRef. // add new defines for each elements. private void CheckReferences(RdpPattern p) { RdpAbstractBinary binary = p as RdpAbstractBinary; if (binary != null) { // choice, interleave, group CheckReferences(binary.LValue); CheckReferences(binary.RValue); return; } RdpAbstractSingleContent single = p as RdpAbstractSingleContent; if (single != null) { CheckReferences(single.Child); return; } switch (p.PatternType) { case RelaxngPatternType.Ref: // FIXME: This should not re-expand ref RdpUnresolvedRef pref = p as RdpUnresolvedRef; if (pref.RefPattern != null) { break; } RelaxngGrammar target = pref.TargetGrammar; if (target == null) { // FIXME: fill line info throw new RelaxngException("Referenced definition was not found."); } RdpPattern defP = target.assembledDefs [pref.Name] as RdpPattern; if (defP == null) { target.unresolvedPatterns.Add(p); } else { ArrayList al = target.refPatterns [defP] as ArrayList; if (al == null) { al = new ArrayList(); target.refPatterns [defP] = al; } al.Add(p); pref.RefPattern = defP; } break; case RelaxngPatternType.Attribute: CheckReferences(((RdpAttribute)p).Children); break; case RelaxngPatternType.DataExcept: CheckReferences(((RdpDataExcept)p).Except); break; case RelaxngPatternType.Element: RdpElement el = p as RdpElement; CheckReferences(el.Children); string name = ElementDefMap [el] as string; if (name == null) { // add new define int idx = 0; string newName = "element0"; if (el.NameClass is RdpName) { newName = ((RdpName)el.NameClass).LocalName; } while (true) { if (assembledDefs [newName] == null) { elementReplacedDefs [newName] = el.Children; break; } newName = "element" + ++idx; } ElementDefMap [el] = newName; } // Even though the element is replaced with ref, // derivative of ref is RdpElement in fact... break; case RelaxngPatternType.List: CheckReferences(((RdpList)p).Child); break; case RelaxngPatternType.Empty: case RelaxngPatternType.NotAllowed: case RelaxngPatternType.Text: case RelaxngPatternType.Value: break; //case RelaxngPatternType.ExternalRef: //case RelaxngPatternType.Include: // Mixed, Optional, ZeroOrMore are already removed. // Choice, Group, Interleave, OneOrMore are already proceeded. } }
internal RdpPattern Compile (RelaxngGrammar grammar) { return p.Compile (grammar); }
internal override RdpPattern Compile(RelaxngGrammar grammar) { IsCompiled = true; return(new RdpValue(new RdpDatatype(DatatypeLibrary, Type, null, grammar.Provider), value)); }
internal RdpParam Compile (RelaxngGrammar grammar) { IsCompiled = true; return new RdpParam (name, value); }
internal RdpPattern Compile(RelaxngGrammar grammar) { return(p.Compile(grammar)); }
internal override RdpNameClass Compile(RelaxngGrammar g) { return(new RdpName(ncname, ns)); }
internal override RdpPattern Compile(RelaxngGrammar grammar) { return(RdpText.Instance); }
internal override RdpPattern Compile (RelaxngGrammar grammar) { IsCompiled = true; return makeBinary (grammar); }
internal override RdpNameClass Compile (RelaxngGrammar g) { if (except != null) { RdpNameClass exc = except.Compile (g); if (FindInvalidType (exc, true)) throw new RelaxngException (except, "anyName except cannot have anyName children."); return new RdpAnyNameExcept (exc); } else return RdpAnyName.Instance; }
internal override RdpPattern Compile (RelaxngGrammar grammar) { IsCompiled = true; return new RdpInterleave (makeSingle (grammar), RdpText.Instance); }
internal override RdpNameClass Compile (RelaxngGrammar g) { return new RdpName (ncname, ns); }
internal abstract RdpNameClass Compile(RelaxngGrammar g);
internal RdpNameClass Compile (RelaxngGrammar g) { // Flatten names into RdpGroup. See 4.12. if (names.Count == 0) return null; RdpNameClass p = ((RelaxngNameClass) names [0]).Compile (g); for (int i=1; i<names.Count; i++) { p = new RdpNameClassChoice ( ((RelaxngNameClass) names [i]).Compile (g), p); } return p; }
RelaxngGrammar DtdXsd2Rng (XmlSchema xsd, string ns) { g = new RelaxngGrammar (); g.DefaultNamespace = ns; RelaxngStart start = new RelaxngStart (); g.Starts.Add (start); RelaxngChoice choice = new RelaxngChoice (); start.Pattern = choice; // There are only elements. foreach (XmlSchemaElement el in xsd.Items) { RelaxngDefine def = DefineElement (el); g.Defines.Add (def); RelaxngRef dref = new RelaxngRef (); dref.Name = def.Name; choice.Patterns.Add (dref); } return g; }
public RelaxngValidatingReader(XmlReader reader, XmlReader grammarXml, RelaxngDatatypeProvider provider) : this(reader, RelaxngGrammar.Read(grammarXml, provider)) { }