Ejemplo n.º 1
0
        private RelaxngDefine ReadDefine()
        {
            RelaxngDefine def = new RelaxngDefine();

            FillLocation(def);
            expect("define");
            def.Name    = GetNameAttribute();
            def.Combine = GetSpaceStrippedAttribute("combine", String.Empty);

            Read();
            while (NodeType == XmlNodeType.Element)
            {
                def.Patterns.Add(ReadPattern());
            }
            expectEnd("define");
            return(def);
        }
Ejemplo n.º 2
0
		private RelaxngDefine ReadDefine ()
		{
			RelaxngDefine def = new RelaxngDefine ();
			FillLocation (def);
			expect ("define");
			def.Name = GetNameAttribute ();
			def.Combine = GetSpaceStrippedAttribute ("combine", String.Empty);

			Read ();
			while (NodeType == XmlNodeType.Element)
				def.Patterns.Add (ReadPattern ());
			expectEnd ("define");
			return def;
		}
Ejemplo n.º 3
0
		RelaxngDefine DefineElement (XmlSchemaElement el)
		{
			RelaxngDefine def = new RelaxngDefine ();
			def.Patterns.Add (CreateElement (el));
			def.Name = el.Name;

			return def;
		}
Ejemplo n.º 4
0
		// Note that it might not be used directly when a grammar
		// contains more than one "define" for an identical name
		// (compact syntax does not support "combine" attribute).
		public void WriteDefine (RelaxngDefine define)
		{
			if (IsKeyword (define.Name))
				w.Write ('\\');
			w.Write (define.Name);
			if (define.Combine == null)
				w.Write (" = ");
			else
				w.Write (define.Combine.Trim () == "interleave" ?
					" &= " : " |= ");
			if (define.Patterns.Count == 0)
				w.Write ("empty");
			else {
				define.Patterns [0].WriteRnc (this);
				for (int i = 1; i < define.Patterns.Count; i++) {
					w.Write (",");
					define.Patterns [i].WriteRnc (this);
				}
			}
			w.WriteLine ();
			w.WriteLine ();
		}
Ejemplo n.º 5
0
		private RelaxngDefine CreateGlobalAttribute (QName name)
		{
			RelaxngDefine def = new RelaxngDefine ();
			def.Name = CreateUniqueName (name.Name + "-attr");
			RelaxngAttribute attr = new RelaxngAttribute ();
			attr.NameClass = new RelaxngName (
				name.Name, name.Namespace);
			def.Patterns.Add (attr);
			attributes.Add (name, def);
			grammar.Defines.Add (def);
			return def;
		}
Ejemplo n.º 6
0
		// Already relaxed.
		private RelaxngDefine CreateGlobalElement (QName name)
		{
			RelaxngDefine def = new RelaxngDefine ();
			def.Name = CreateUniqueName (name.Name);
			RelaxngElement el = new RelaxngElement ();
			el.NameClass = new RelaxngName (name.Name,
				name.Namespace);
			def.Patterns.Add (el);
			elements.Add (name, def);
			grammar.Defines.Add (def);
			return def;
		}
Ejemplo n.º 7
0
		private void InferElement (RelaxngDefine el, bool isNew)
		{
			RelaxngElement ct = (RelaxngElement) el.Patterns [0];

			// Attributes
			if (source.MoveToFirstAttribute ()) {
				InferAttributes (ct, isNew);
				source.MoveToElement ();
			}

			// Content
			if (source.IsEmptyElement) {
				InferAsEmptyElement (ct, isNew);
				source.Read ();
				source.MoveToContent ();
			}
			else {
				InferContent (ct, isNew);
				source.ReadEndElement ();
			}
			if (GetElementContent (ct) == null)
				el.Patterns.Add (new RelaxngEmpty ());
		}