// Use this for initialization
    void Start()
    {
        string last_element = "";
        int counter = 1;

        textAsset = (TextAsset) Resources.Load("XMLs/tea_dialog");
        reader = XmlReader.Create(new StringReader(textAsset.text));

        //pull in the animation names from the xml file
        while (reader.Read ()) {

            if(reader.NodeType == XmlNodeType.Element){

                while(reader.MoveToNextAttribute())
                {
                    if(reader.Name == "id")
                    {
                        //print (counter + " : " + reader.Value);
                        animIndices.Add (counter, reader.Value);
                        counter += 1;
                    }
                }

            }
        }

        //print out hash table, for testing purposes
        //printHashTable ();
    }
Example #2
0
	public void DumpReader (XmlReader xr, bool attValue)
	{
		Console.WriteLine ("NodeType: " + xr.NodeType);
		Console.WriteLine ("Prefix: " + xr.Prefix);
		Console.WriteLine ("Name: " + xr.Name);
		Console.WriteLine ("LocalName: " + xr.LocalName);
		Console.WriteLine ("NamespaceURI: " + xr.NamespaceURI);
		Console.WriteLine ("Value: " + xr.Value);
		Console.WriteLine ("Depth: " + xr.Depth);
		Console.WriteLine ("IsEmptyElement: " + xr.IsEmptyElement);

		if (xr.NodeType == XmlNodeType.Attribute) {
			Console.WriteLine ("Attribute Values::::");
			while (xr.ReadAttributeValue ())
				DumpReader (xr, true);
			Console.WriteLine (":::Attribute Values End");
		} else if (!attValue) {
			Console.WriteLine ("Attributes::::");
			Console.Write (xr.AttributeCount);
			if (xr.MoveToFirstAttribute ()) {
				do {
					DumpReader (xr, false);
				} while (xr.MoveToNextAttribute ());
				xr.MoveToElement ();
			}
			Console.WriteLine (":::Attributes End");
		}
	}
Example #3
0
    /// <summary>
    /// Reads a specific data tag from the xml document.
    /// </summary>
    /// <param name='reader'>
    /// Reader.
    /// </param>
    private void ReadData(XmlReader reader)
    {
        //If these values are not being set,
        //something is wrong.
        string key = "ERROR";

        string value = "ERROR";

        if (reader.HasAttributes)
        {
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "name")
                {
                    key = reader.Value;
                }
            }
        }

        //Move back to the element
        reader.MoveToElement();

        //Read the child nodes
        if (reader.ReadToDescendant("value"))
        {
            do
            {
                value = reader.ReadString();
            }
            while (reader.ReadToNextSibling("value"));
        }

        //Add the raw values to the dictionary
        textDataBase.Add(key, value);

        //Add the localized parsed values to the localizedObjectDataBase
        LocalizedObject newLocalizedObject = new LocalizedObject();
        newLocalizedObject.ObjectType = LocalizedObject.GetLocalizedObjectType(key);
        newLocalizedObject.TextValue = value;
        localizedObjectDataBase.Add(LocalizedObject.GetCleanKey(key,newLocalizedObject.ObjectType), newLocalizedObject);
    }
Example #4
0
    // Read and extract into InterfaceRight class each attribut of node name "group"
    InterfaceElement check_attribute_group(XmlReader xml_reader)
    {
        InterfaceElement s_InterfaceElement = new InterfaceElement();
        s_InterfaceElement.mse_type = 0;
        s_InterfaceElement.b_toggle_type = false;
        s_InterfaceElement.s_content = "undefined";
        s_InterfaceElement.s_text_area = "Choose a title";

        if (xml_reader.HasAttributes)
        {
            while (xml_reader.MoveToNextAttribute() != false)
            {
                bool valide_type = true;
                string save_type = "";
                string save_readstring = "";
                string save_content = "";

                // if type exist, else, a button will be created
                if ((save_type = xml_reader.GetAttribute("type")) != null)
                {
                    if (Enum.IsDefined(typeof(me_button_type),save_type) == true)
                        s_InterfaceElement.mse_type = (me_button_type)Enum.Parse(typeof(me_button_type), save_type);
                    else
                        valide_type = false;
                }

                // if content as attribute or string exist, else, "undefined" has been saved
                if ((save_content = xml_reader.GetAttribute("content")) != null || (save_readstring = xml_reader.ReadString()) != null)
                {
                    s_InterfaceElement.s_content = save_content != null ? save_content : save_readstring;
                    if (valide_type == false)
                        s_InterfaceElement.s_content += " (Coming Soon)";
                }
            }
        }
        return s_InterfaceElement;
    }
Example #5
0
    // Read and extract into Element class each attribut of node name "element"
    Element check_attribute_element(XmlReader xml_reader, Element element)
    {
        if (xml_reader.HasAttributes)
        {
            while (xml_reader.MoveToNextAttribute() != false)
            {
                string prefab_name = "";

                if ((prefab_name = xml_reader.GetAttribute("prefab")) != null)
                {
                    if (Resources.Load(prefab_name) != null)
                        element.prefab = Resources.Load(prefab_name) as GameObject;
                }
            }
        }
        return element;
    }
Example #6
0
 internal void ReadContentFrom(XmlReader r, LoadOptions o)
 {
     if ((o & (LoadOptions.SetBaseUri | LoadOptions.SetLineInfo)) == 0)
     {
         ReadContentFrom(r);
         return;
     }
     if (r.ReadState != ReadState.Interactive) throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
     XContainer c = this;
     XNode n = null;
     NamespaceCache eCache = new NamespaceCache();
     NamespaceCache aCache = new NamespaceCache();
     string baseUri = (o & LoadOptions.SetBaseUri) != 0 ? r.BaseURI : null;
     IXmlLineInfo li = (o & LoadOptions.SetLineInfo) != 0 ? r as IXmlLineInfo : null;
     do
     {
         string uri = r.BaseURI;
         switch (r.NodeType)
         {
             case XmlNodeType.Element:
                 {
                     XElement e = new XElement(eCache.Get(r.NamespaceURI).GetName(r.LocalName));
                     if (baseUri != null && baseUri != uri)
                     {
                         e.SetBaseUri(uri);
                     }
                     if (li != null && li.HasLineInfo())
                     {
                         e.SetLineInfo(li.LineNumber, li.LinePosition);
                     }
                     if (r.MoveToFirstAttribute())
                     {
                         do
                         {
                             XAttribute a = new XAttribute(aCache.Get(r.Prefix.Length == 0 ? string.Empty : r.NamespaceURI).GetName(r.LocalName), r.Value);
                             if (li != null && li.HasLineInfo())
                             {
                                 a.SetLineInfo(li.LineNumber, li.LinePosition);
                             }
                             e.AppendAttributeSkipNotify(a);
                         } while (r.MoveToNextAttribute());
                         r.MoveToElement();
                     }
                     c.AddNodeSkipNotify(e);
                     if (!r.IsEmptyElement)
                     {
                         c = e;
                         if (baseUri != null)
                         {
                             baseUri = uri;
                         }
                     }
                     break;
                 }
             case XmlNodeType.EndElement:
                 {
                     if (c.content == null)
                     {
                         c.content = string.Empty;
                     }
                     // Store the line info of the end element tag.
                     // Note that since we've got EndElement the current container must be an XElement
                     XElement e = c as XElement;
                     Debug.Assert(e != null, "EndElement received but the current container is not an element.");
                     if (e != null && li != null && li.HasLineInfo())
                     {
                         e.SetEndElementLineInfo(li.LineNumber, li.LinePosition);
                     }
                     if (c == this) return;
                     if (baseUri != null && c.HasBaseUri)
                     {
                         baseUri = c.parent.BaseUri;
                     }
                     c = c.parent;
                     break;
                 }
             case XmlNodeType.Text:
             case XmlNodeType.SignificantWhitespace:
             case XmlNodeType.Whitespace:
                 if ((baseUri != null && baseUri != uri) ||
                     (li != null && li.HasLineInfo()))
                 {
                     n = new XText(r.Value);
                 }
                 else
                 {
                     c.AddStringSkipNotify(r.Value);
                 }
                 break;
             case XmlNodeType.CDATA:
                 n = new XCData(r.Value);
                 break;
             case XmlNodeType.Comment:
                 n = new XComment(r.Value);
                 break;
             case XmlNodeType.ProcessingInstruction:
                 n = new XProcessingInstruction(r.Name, r.Value);
                 break;
             case XmlNodeType.DocumentType:
                 n = new XDocumentType(r.LocalName, r.GetAttribute("PUBLIC"), r.GetAttribute("SYSTEM"), r.Value);
                 break;
             case XmlNodeType.EntityReference:
                 if (!r.CanResolveEntity) throw new InvalidOperationException(SR.InvalidOperation_UnresolvedEntityReference);
                 r.ResolveEntity();
                 break;
             case XmlNodeType.EndEntity:
                 break;
             default:
                 throw new InvalidOperationException(SR.Format(SR.InvalidOperation_UnexpectedNodeType, r.NodeType));
         }
         if (n != null)
         {
             if (baseUri != null && baseUri != uri)
             {
                 n.SetBaseUri(uri);
             }
             if (li != null && li.HasLineInfo())
             {
                 n.SetLineInfo(li.LineNumber, li.LinePosition);
             }
             c.AddNodeSkipNotify(n);
             n = null;
         }
     } while (r.Read());
 }
Example #7
0
 internal void ReadContentFrom(XmlReader r)
 {
     if (r.ReadState != ReadState.Interactive) throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
     XContainer c = this;
     NamespaceCache eCache = new NamespaceCache();
     NamespaceCache aCache = new NamespaceCache();
     do
     {
         switch (r.NodeType)
         {
             case XmlNodeType.Element:
                 XElement e = new XElement(eCache.Get(r.NamespaceURI).GetName(r.LocalName));
                 if (r.MoveToFirstAttribute())
                 {
                     do
                     {
                         e.AppendAttributeSkipNotify(new XAttribute(aCache.Get(r.Prefix.Length == 0 ? string.Empty : r.NamespaceURI).GetName(r.LocalName), r.Value));
                     } while (r.MoveToNextAttribute());
                     r.MoveToElement();
                 }
                 c.AddNodeSkipNotify(e);
                 if (!r.IsEmptyElement)
                 {
                     c = e;
                 }
                 break;
             case XmlNodeType.EndElement:
                 if (c.content == null)
                 {
                     c.content = string.Empty;
                 }
                 if (c == this) return;
                 c = c.parent;
                 break;
             case XmlNodeType.Text:
             case XmlNodeType.SignificantWhitespace:
             case XmlNodeType.Whitespace:
                 c.AddStringSkipNotify(r.Value);
                 break;
             case XmlNodeType.CDATA:
                 c.AddNodeSkipNotify(new XCData(r.Value));
                 break;
             case XmlNodeType.Comment:
                 c.AddNodeSkipNotify(new XComment(r.Value));
                 break;
             case XmlNodeType.ProcessingInstruction:
                 c.AddNodeSkipNotify(new XProcessingInstruction(r.Name, r.Value));
                 break;
             case XmlNodeType.DocumentType:
                 c.AddNodeSkipNotify(new XDocumentType(r.LocalName, r.GetAttribute("PUBLIC"), r.GetAttribute("SYSTEM"), r.Value));
                 break;
             case XmlNodeType.EntityReference:
                 if (!r.CanResolveEntity) throw new InvalidOperationException(SR.InvalidOperation_UnresolvedEntityReference);
                 r.ResolveEntity();
                 break;
             case XmlNodeType.EndEntity:
                 break;
             default:
                 throw new InvalidOperationException(SR.Format(SR.InvalidOperation_UnexpectedNodeType, r.NodeType));
         }
     } while (r.Read());
 }
	/// <summary>
	/// Find all links.
	/// </summary>
	private IEnumerable<string> findAllLinks(
		XmlReader xml,
		string baseUrl )
	{
		var links = new List<string>();

		while ( xml.Read() )
		{
			switch ( xml.NodeType )
			{
				// Added 2006-03-27: Inside comments, too.
				case XmlNodeType.Comment:
					XmlReader childXml = getDocReader( xml.Value, baseUrl );

					IEnumerable<string> childLinks = findAllLinks( childXml, baseUrl );
					links.AddRange( childLinks );
					break;

				// A node element.
				case XmlNodeType.Element:
					string[] linkAttributeNames;
					// If this is a link element, store the URLs to modify.
					if ( isLinkElement( xml.Name, out linkAttributeNames ) )
					{
						while ( xml.MoveToNextAttribute() )
						{
							checkAddStyleAttributeLinks(
								xml.Name,
								xml.Value,
								links );

// ReSharper disable LoopCanBeConvertedToQuery
							foreach ( string a in linkAttributeNames )
// ReSharper restore LoopCanBeConvertedToQuery
							{
								if ( a.ToLower() == xml.Name.ToLower() )
								{
									string linkUrl = xml.Value;

									if ( !isAbsoluteUrl( linkUrl ) )
									{
										links.Add( linkUrl );
									}
								}
							}
						}
					}
					else
					{
						// Also, look for style attributes.
						while ( xml.MoveToNextAttribute() )
						{
							checkAddStyleAttributeLinks(
								xml.Name,
								xml.Value,
								links );
						}
					}
					break;
			}
		}

		return links.ToArray();
	}
  } //ReadTransformWrite()

  /// <summary>
  /// Output the tranformed XML in annotated form to the console.
  /// Calls the Output method.
  /// </summary>
  /// <param name="reader"></param>
  private static void OutputXml (XmlReader reader)
  {
    while (reader.Read())
    {
      switch (reader.NodeType)
      {
        case XmlNodeType.ProcessingInstruction:
          Output(reader, "ProcessingInstruction");
          break;

        case XmlNodeType.DocumentType:
          Output(reader, "DocumentType");
          break;

        case XmlNodeType.Document:
          Output(reader, "Document");
          break;

        case XmlNodeType.Comment:
          Output(reader, "Comment");
          break;

        case XmlNodeType.Element:
          Output(reader, "Element");
          while(reader.MoveToNextAttribute())
          {
            Output(reader, "Attribute");
          } //while
          break;

        case XmlNodeType.Text:
          Boolean flag = false;
          // Do not display whitespace text nodes
          for (int i=0; i < reader.Value.Length; i++)
          {
            if (!System.Char.IsWhiteSpace(reader.Value[i]))
              flag = true;
          } //for
          if(flag)
            Output (reader, "Text");
          break;
      } //switch
    } //while
    Console.WriteLine();
  } //OutputXML()
 /* Method to extract the client specific parts of the config file */
 private bool ExtractClientConfig(XmlReader reader)
 {
     try {
         while (reader.Read()) {
             if (reader.IsStartElement()) {
                 if (reader.Name == "client") {
                     client_config.Add(new ClientConfig());
                     while (reader.MoveToNextAttribute()) {
                         if (reader.Name == "name")
                             client_config.Last().name.Add("short_name", reader.Value);
                         else if (reader.Name == "lname")
                             client_config.Last().name.Add("full_name", reader.Value);
                         else
                             Console.WriteLine("Unknown report configuration attribute: " + reader.Name);
                     }
                 }
                 else if (reader.Name == "project")
                     client_config.Last().projects.Add(reader.ReadString());
                 else if (reader.Name == "priority")
                     client_config.Last().priority.Add(reader.ReadString());
                 else if (reader.Name == "email")
                     client_config.Last().email.Add(reader.ReadString());
             }
         }
         return true;
     }
     catch (Exception ex) {
         Console.WriteLine("Exception when extracting client data from config XML: " + ex.Message);
         return false;
     }
 }
        /// PRIVATE METHODS ///
        /// 
        /* Method which extracts the attributes from an XML node.
         * All attributes in the XML file are declared here. Each
         * should have a unique name. It would be possible to allow
         * node scoped attributes by adding extra parameters. Might
         * do this in the future if need this method to do it. */
        private bool ExtractAttributes(XmlReader reader)
        {
            if (reader.HasAttributes) {
                while (reader.MoveToNextAttribute()) {
                    // Console.WriteLine(reader.Name);
                    switch (reader.Name) {
                        /* Jira Config variables */
                        case "host":
                            jira_config.data.Add("host", reader.Value);
                            break;
                        case "user":
                            jira_config.data.Add("user", reader.Value);
                            break;
                        case "pass":
                            jira_config.data.Add("pass", reader.Value);
                            break;

                        /* File Config variables */
                        case "outputDir":
                            file_config.output.Add("output_dir", reader.Value);
                            break;
                        case "outputName":
                            file_config.output.Add("output_name", reader.Value);
                            break;
                        case "outputExt":
                            file_config.output.Add("output_ext", reader.Value);
                            break;

                        /* Email Config variables */
                        case "serverName":
                            email_config.email.Add("server_name", reader.Value);
                            break;
                        case "serverPort":
                            email_config.email.Add("server_port", reader.Value);
                            break;
                        case "senderEmail":
                            email_config.email.Add("sender_email", reader.Value);
                            break;
                        case "emailSubject":
                            email_config.email.Add("email_subject", reader.Value);
                            break;
                        case "emailBody":
                            email_config.email.Add("email_body", reader.Value);
                            break;
                        case "emailTemplate":
                            email_config.email.Add("email_template", reader.Value);
                            break;
                        case "emailType":
                            email_config.email.Add("email_type", reader.Value);
                            break;

                        /* Template config */
                        case "placeHolder":
                            string ph = reader.Value;
                            if (reader.MoveToNextAttribute()) {
                                if (reader.Name == "content") {
                                    // Console.WriteLine("Template Markup defined: " + ph + " ; " + reader.Value);
                                    template_config.markup_delim.Add(ph, reader.Value);
                                }
                                else
                                    Console.WriteLine("Unknown template configuration attribute: " + reader.Name);
                            }
                            else
                                Console.WriteLine("Unable to process Template Attribute: " + ph);
                            break;

                        default:
                            Console.WriteLine("Unknown report configuration attribute: " + reader.Name);
                            return false;
                    }
                }
            }

            return true;
        }