Exemplo n.º 1
0
        private void SelectSingleNode()
        {
            if (xmlSource.Value == null)
            {
                Debug.LogWarning("XMl source is empty, or likely invalid");

                Fsm.Event(errorEvent);
                return;
            }

            string xPathQueryString = xPath.ParseXpathQuery(this.Fsm);

            XmlNode node = null;

            try{
                node = xmlSource.Value.SelectSingleNode(xPathQueryString, DataMakerXmlUtils.CreateNamespaceManager(xmlSource.Value.OwnerDocument));
            }catch (XPathException e)
            {
                Debug.LogWarning(e.Message);
                Fsm.Event(errorEvent);
                return;
            }

            if (node != null)
            {
                if (!xmlResult.IsNone)
                {
                    xmlResult.Value = DataMakerXmlUtils.XmlNodeToString(node);
                }

                if (storeNodeProperties.Length > 0)
                {
                    FsmXmlProperty.StoreNodeProperties(this.Fsm, node, storeNodeProperties);
                }
                else
                {
                    storeProperties.StoreNodeProperties(this.Fsm, node);
                }


                found.Value = true;
                Fsm.Event(foundEvent);
            }
            else
            {
                found.Value = false;
                Fsm.Event(notFoundEvent);
            }

            if (!string.IsNullOrEmpty(storeReference.Value))
            {
                DataMakerXmlUtils.XmlStoreNode(node, storeReference.Value);
            }


            Finish();
        }
Exemplo n.º 2
0
        public static string GetNodeProperty(XmlNode node, string property)
        {
            if (property.StartsWith("@"))
            {
                property = property.Remove(0, 1);

                XmlAttribute att = node.Attributes[property];
                if (att != null)
                {
                    return(att.InnerText);
                }
                else
                {
                    //Debug.LogWarning (property + " attribute not found");
                }
            }
            else if (property.StartsWith("/") || property.StartsWith("."))
            {
                if (property.StartsWith("/"))
                {
                    property = "." + property;
                }

                XmlNode subNode = node.SelectSingleNode(property,
                                                        DataMakerXmlUtils.CreateNamespaceManager(node.OwnerDocument));
                if (subNode != null)
                {
                    return(subNode.InnerText);
                }
                else
                {
                    Debug.LogWarning(property + " not found");
                }
            }
            else
            {
                if (property == "Name()")
                {
                    return(node.Name);
                }
                else
                {
                    XmlNode innerNode = node[property];
                    if (innerNode != null)
                    {
                        return(innerNode.InnerText);
                    }
                    else
                    {
                        return(node.InnerText);
                        //Debug.LogWarning (property + " not found");
                    }
                }
            }

            return("");
        }
Exemplo n.º 3
0
        private void SelectNodeList()
        {
            nodeCount.Value = 0;

            if (xmlSource.Value == null)
            {
                Debug.LogWarning("XMl source is empty, or likely invalid");
                Fsm.Event(errorEvent);
                return;
            }

            string xPathQueryString = xPath.ParseXpathQuery(this.Fsm);

            XmlNodeList nodeList = null;

            try{
                nodeList = xmlSource.Value.SelectNodes(xPathQueryString, DataMakerXmlUtils.CreateNamespaceManager(xmlSource.Value.OwnerDocument));
            }catch (XPathException e)
            {
                Debug.LogWarning(e.Message);
                Fsm.Event(errorEvent);
                return;
            }

            if (nodeList != null)
            {
                nodeCount.Value = nodeList.Count;

                if (nodeList.Count == 0)
                {
                    found.Value = false;
                    Fsm.Event(notFoundEvent);
                    return;
                }

                if (!xmlResult.IsNone)
                {
                    xmlResult.Value = DataMakerXmlUtils.XmlNodeListToString(nodeList);
                    //	Debug.Log(xmlResult.Value);
                }
                found.Value = true;
                Fsm.Event(foundEvent);
            }
            else
            {
                found.Value = false;
                Fsm.Event(notFoundEvent);
            }

            if (!string.IsNullOrEmpty(storeReference.Value))
            {
                DataMakerXmlUtils.XmlStoreNodeList(nodeList, storeReference.Value);
            }
        }
Exemplo n.º 4
0
        public static void SetNodeProperty(XmlNode node, string property, string propertyValue)
        {
            if (property.StartsWith("@"))
            {
                property = property.Remove(0, 1);

                XmlAttribute att = node.Attributes[property];
                if (att == null)
                {
                    att = node.OwnerDocument.CreateAttribute(property);
                    node.Attributes.Append(att);
                }
                att.InnerText = propertyValue;
            }
            else if (property.StartsWith("/") || property.StartsWith("."))
            {
                if (property.StartsWith("/"))
                {
                    property = "." + property;
                }

                XmlNode subNode = node.SelectSingleNode(property, DataMakerXmlUtils.CreateNamespaceManager(node.OwnerDocument));
                if (subNode != null)
                {
                    subNode.InnerText = propertyValue;
                }
                else
                {
                    Debug.LogWarning(property + " not found");
                }
            }
            else
            {
                XmlNode innerNode = node[property];
                if (innerNode != null)
                {
                    innerNode.InnerText = propertyValue;
                }
                else
                {
                    //Debug.LogWarning (property + " not found");
                }
            }
        }