public NvdlValidatingReader(XmlReader reader, NvdlRules rules, XmlResolver resolver, NvdlConfig config) : base(reader) { dispatcher = new NvdlDispatcher(new SimpleRules( new NvdlCompileContext( rules, config, resolver)), this); }
public NvdlValidatingReader (XmlReader reader, NvdlRules rules, XmlResolver resolver, NvdlConfig config) : base (reader) { dispatcher = new NvdlDispatcher (new SimpleRules ( new NvdlCompileContext ( rules, config, resolver)), this); }
private NvdlRules ReadRules() { NvdlRules el = new NvdlRules(); FillLocation(el); el.SchemaType = reader.GetAttribute("schemaType"); el.StartMode = reader.GetAttribute("startMode"); FillForeignAttribute(el); if (reader.IsEmptyElement) { reader.Skip(); return(el); } reader.Read(); do { reader.MoveToContent(); if (reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.NamespaceURI != Nvdl.Namespace) { el.Foreign.Add(XDocument.ReadFrom(reader)); continue; } switch (reader.LocalName) { case "mode": el.Modes.Add(ReadMode()); break; case "namespace": el.Rules.Add(ReadNamespace()); break; case "anyNamespace": el.Rules.Add(ReadAnyNamespace()); break; case "trigger": el.Triggers.Add(ReadTrigger()); break; } } while (!reader.EOF); if (!reader.EOF) { reader.Read(); } return(el); }
private NvdlRules ReadRules () { NvdlRules el = new NvdlRules (); FillLocation (el); el.SchemaType = reader.GetAttribute ("schemaType"); el.StartMode = reader.GetAttribute ("startMode"); FillForeignAttribute (el); if (reader.IsEmptyElement) { reader.Skip (); return el; } reader.Read (); do { reader.MoveToContent (); if (reader.NodeType == XmlNodeType.EndElement) break; if (reader.NamespaceURI != Nvdl.Namespace) { el.Foreign.Add (doc.ReadNode (reader)); continue; } switch (reader.LocalName) { case "mode": el.Modes.Add (ReadMode ()); break; case "namespace": el.Rules.Add (ReadNamespace ()); break; case "anyNamespace": el.Rules.Add (ReadAnyNamespace ()); break; case "trigger": el.Triggers.Add (ReadTrigger ()); break; } } while (!reader.EOF); if (!reader.EOF) reader.Read (); return el; }
public NvdlValidatingReader (XmlReader reader, NvdlRules rules, XmlResolver resolver) : this (reader, rules, resolver, Nvdl.DefaultConfig) { }
public NvdlValidatingReader (XmlReader reader, NvdlRules rules) : this (reader, rules, new XmlUrlResolver ()) { }
public NvdlCompileContext(NvdlRules rules, NvdlConfig config, XmlResolver resolver) { this.rules = rules; this.config = config; this.resolver = resolver; }
private void SimplifyPhase1(NvdlCompileContext ctx) { NvdlRules rules = ctx.Rules; // 6.4.1 : just ignore "Foreign" property. // 6.4.2 : already ignored on reading nvdl. // 6.4.3 : done in SOM // 6.4.4 : FIXME: must be done. // 6.4.5 : FIXME: considered in compiler. // 6.4.6 : FIXME: considered in compiler. // 6.4.7 : FIXME: considered in compiler. // 6.4.8 : here NvdlModeList list = rules.Modes; NvdlMode startMode = null; if (rules.Modes.Count > 0) { if (rules.Rules.Count > 0) { throw new NvdlCompileException("Modes and rules cannot coexist in 'rules' element.", rules); } else if (rules.StartMode == null) { throw new NvdlCompileException("startMode is missing in 'rules' element when modes are specified.", rules); } foreach (NvdlMode m in rules.Modes) { if (m.Name == rules.StartMode) { startMode = m; break; } } if (startMode == null) { throw new NvdlCompileException("Matching 'mode' element specified by 'startMode' does not exist.", rules); } } else { if (rules.Rules.Count == 0) { throw new NvdlCompileException("Neither modes nor rules exists in 'rules' element.", rules); } list = new NvdlModeList(); startMode = new NvdlMode(); startMode.SourceUri = rules.SourceUri; startMode.LineNumber = rules.LineNumber; startMode.LinePosition = rules.LinePosition; startMode.Name = "(startMode)"; list.Add(startMode); foreach (NvdlRule rule in rules.Rules) { startMode.Rules.Add(rule); } } // 6.4.9 : done in SimpleMode.ctor() and // SimpleRule.ctor(), using ctx.CompiledModes. foreach (NvdlMode m in list) { SimpleMode sm = new SimpleMode(m, ctx); ctx.AddCompiledMode(sm.Name, sm); if (m == startMode) { this.startMode = sm; } } // 6.4.10 : done in SimpleRule.Simplify ArrayList tl = new ArrayList(); for (int i = 0; i < rules.Triggers.Count; i++) { tl.Add(new SimpleTrigger(rules.Triggers [i])); } triggers = (SimpleTrigger [])tl.ToArray( typeof(SimpleTrigger)); modes = (SimpleMode []) new ArrayList(ctx.GetCompiledModes()) .ToArray(typeof(SimpleMode)); }
public NvdlCompileContext (NvdlRules rules, NvdlConfig config, XmlResolver resolver) { this.rules = rules; this.config = config; this.resolver = resolver; }
public NvdlValidatingReader(XmlReader reader, NvdlRules rules, XmlResolver resolver) : this(reader, rules, resolver, Nvdl.DefaultConfig) { }
public NvdlValidatingReader(XmlReader reader, NvdlRules rules) : this(reader, rules, new XmlUrlResolver()) { }