Esempio n. 1
0
		private void acceptState (CssParserStates s)
		{
			Console.WriteLine("Accepted State: {0}", s.ToString ());
			CssParserStates popState;
			SimpleElement child;
			SimpleElement parent;
			
			// Dont pop root element
			if (elements.Count == 1)
				parent = (SimpleElement) elements.Peek ();
			else
				parent = (SimpleElement) elements.Pop ();
			
			Console.WriteLine("Adding child to: {0}", parent.TagName );
			CssToken t;
			while ((popState = (CssParserStates) state.Pop ()) != s) {
				child = new SimpleElement (popState.ToString ());
				t = (CssToken) tokens.Pop ();
				child.Text = t.GetValue ();
				parent.ChildElements.Add (child);
			}
			
			rootElement.ChildElements.Add (parent);
		}
 public void Add(SimpleElement se) {
    this.List.Add(se);
 }
Esempio n. 3
0
		public void CssDocumentStart ()
		{
			state.Push (CssParserStates.STYLESHEET);
			rootElement = new SimpleElement("StyleSheet");
			elements.Push (rootElement);
			currentElement = rootElement;
		}
Esempio n. 4
0
		private void addParentNode (CssParserStates s)
		{
			SimpleElement element = new SimpleElement (s.ToString ());
			elements.Push (element);
		}
Esempio n. 5
0
		private static void printTree(SimpleElement se, StringBuilder sb, int depth) 
		{

		   sb.Append(new string('\t',depth) +  
		      "<" + se.TagName);
		   foreach (string attName in se.Attributes.Keys) {
		      sb.Append(" " + attName + "=" + "\"" + 
		      se.Attribute(attName) + "\"");
		   }
		   sb.Append(">" + se.Text.Trim());
		   if (se.ChildElements.Count > 0) {
		      sb.Append(System.Environment.NewLine);
		      depth +=1;
		      foreach(SimpleElement ch in se.ChildElements) 
		      {
		         //sb.Append(System.Environment.NewLine);
		         printTree (ch, sb, depth);            
		      }
		      depth -= 1;
		      sb.Append(new string('\t',depth) + 
		         "</" + se.TagName + 
		         ">" + System.Environment.NewLine);
		   }    
		   else {
		      sb.Append("</" + se.TagName + ">" + 
		         System.Environment.NewLine);
		   }
		}