MoveToAttribute() public method

public MoveToAttribute ( string localName, string namespaceURI ) : bool
localName string
namespaceURI string
return bool
        public override string GetAttribute(string localName, string namespaceURI)
        {
            if (null == localName)
            {
                throw new ArgumentNullException("localName");
            }
            // reader allows calling GetAttribute, even when positioned inside attributes
            XPathNavigator nav = _nav;

            switch (nav.NodeType)
            {
            case XPathNodeType.Element:
                break;

            case XPathNodeType.Attribute:
                nav = nav.Clone();
                if (!nav.MoveToParent())
                {
                    return(null);
                }
                break;

            default:
                return(null);
            }
            // are they really looking for a namespace-decl?
            if (namespaceURI == XmlConst.ReservedNsXmlNs)
            {
                if (localName == "xmlns")
                {
                    localName = string.Empty;
                }
                return(nav.GetNamespace(localName));
            }
            if (null == namespaceURI)
            {
                namespaceURI = string.Empty;
            }
            // We need to clone the navigator and move the clone to the attribute to see whether the attribute exists,
            // because XPathNavigator.GetAttribute return string.Empty for both when the the attribute is not there or when
            // it has an empty value. XmlReader.GetAttribute must return null if the attribute does not exist.
            if ((object)nav == (object)_nav)
            {
                nav = nav.Clone();
            }
            if (nav.MoveToAttribute(localName, namespaceURI))
            {
                return(nav.Value);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
 public static void SetOrCreateXmlAttribute(XPathNavigator node, string localName, string namespaceURI, string value)
 {
     if (node.MoveToAttribute(localName, namespaceURI))
     {
         node.SetValue(value);
         node.MoveToParent();
     }
     else
     {
         node.CreateAttribute("", localName, namespaceURI, value);
     }
 }
        public override bool MoveToAttribute(string localName, string namespaceName)
        {
            if (localName == null)
            {
                throw new ArgumentNullException("localName");
            }
            int            depth   = this.depth;
            XPathNavigator elemNav = this.GetElemNav(out depth);

            if (elemNav != null)
            {
                if (namespaceName == "http://www.w3.org/2000/xmlns/")
                {
                    if (localName == "xmlns")
                    {
                        localName = string.Empty;
                    }
                    if (elemNav.MoveToFirstNamespace(XPathNamespaceScope.Local))
                    {
                        do
                        {
                            if (elemNav.LocalName == localName)
                            {
                                goto Label_007A;
                            }
                        }while (elemNav.MoveToNextNamespace(XPathNamespaceScope.Local));
                    }
                }
                else
                {
                    if (namespaceName == null)
                    {
                        namespaceName = string.Empty;
                    }
                    if (elemNav.MoveToAttribute(localName, namespaceName))
                    {
                        goto Label_007A;
                    }
                }
            }
            return(false);

Label_007A:
            if (this.state == State.InReadBinary)
            {
                this.readBinaryHelper.Finish();
                this.state = this.savedState;
            }
            this.MoveToAttr(elemNav, depth + 1);
            return(true);
        }
        public override bool MoveToAttribute(string localName, string namespaceName)
        {
            if (null == localName)
            {
                throw new ArgumentNullException("localName");
            }
            int            depth = _depth;
            XPathNavigator nav   = GetElemNav(out depth);

            if (null != nav)
            {
                if (namespaceName == XmlConst.ReservedNsXmlNs)
                {
                    if (localName == "xmlns")
                    {
                        localName = string.Empty;
                    }
                    if (nav.MoveToFirstNamespace(XPathNamespaceScope.Local))
                    {
                        do
                        {
                            if (nav.LocalName == localName)
                            {
                                goto FoundMatch;
                            }
                        } while (nav.MoveToNextNamespace(XPathNamespaceScope.Local));
                    }
                }
                else
                {
                    if (null == namespaceName)
                    {
                        namespaceName = string.Empty;
                    }
                    if (nav.MoveToAttribute(localName, namespaceName))
                    {
                        goto FoundMatch;
                    }
                }
            }
            return(false);

FoundMatch:
            if (_state == State.InReadBinary)
            {
                _readBinaryHelper.Finish();
                _state = _savedState;
            }
            MoveToAttr(nav, depth + 1);
            return(true);
        }
        public override string GetAttribute(string name)
        {
            // reader allows calling GetAttribute, even when positioned inside attributes
            XPathNavigator nav = _nav;

            switch (nav.NodeType)
            {
            case XPathNodeType.Element:
                break;

            case XPathNodeType.Attribute:
                nav = nav.Clone();
                if (!nav.MoveToParent())
                {
                    return(null);
                }
                break;

            default:
                return(null);
            }
            string prefix, localname;

            ValidateNames.SplitQName(name, out prefix, out localname);
            if (0 == prefix.Length)
            {
                if (localname == "xmlns")
                {
                    return(nav.GetNamespace(string.Empty));
                }
                if ((object)nav == (object)_nav)
                {
                    nav = nav.Clone();
                }
                if (nav.MoveToAttribute(localname, string.Empty))
                {
                    return(nav.Value);
                }
            }
            else
            {
                if (prefix == "xmlns")
                {
                    return(nav.GetNamespace(localname));
                }
                if ((object)nav == (object)_nav)
                {
                    nav = nav.Clone();
                }
                if (nav.MoveToFirstAttribute())
                {
                    do
                    {
                        if (nav.LocalName == localname && nav.Prefix == prefix)
                        {
                            return(nav.Value);
                        }
                    } while (nav.MoveToNextAttribute());
                }
            }
            return(null);
        }
Example #6
0
		public XPathNavigator CreateAttribute(string name, string namespaceUri, XPathNavigator source)
		{
			source.CreateAttribute(null, name, namespaceUri, "");
			source.MoveToAttribute(name, namespaceUri ?? "");
			return source;
		}
		private void XmlElementWithAttributes (XPathNavigator nav)
		{
			nav.MoveToFirstChild ();
			AssertNavigator ("#1", nav, XPathNodeType.Element, "", "img", "", "img", "", true, false, true);
			Assert.IsTrue (!nav.MoveToNext ());
			Assert.IsTrue (!nav.MoveToPrevious ());

			Assert.IsTrue (nav.MoveToFirstAttribute ());
			AssertNavigator ("#2", nav, XPathNodeType.Attribute, "", "src", "", "src", "foo.png", false, false, false);
			Assert.IsTrue (!nav.MoveToFirstAttribute ());	// On attributes, it fails.

			Assert.IsTrue (nav.MoveToNextAttribute ());
			AssertNavigator ("#3", nav, XPathNodeType.Attribute, "", "alt", "", "alt", "image Fooooooo!", false, false, false);
			Assert.IsTrue (!nav.MoveToNextAttribute ());

			Assert.IsTrue (nav.MoveToParent ());
			AssertNavigator ("#4", nav, XPathNodeType.Element, "", "img", "", "img", "", true, false, true);

			Assert.IsTrue (nav.MoveToAttribute ("alt", ""));
			AssertNavigator ("#5", nav, XPathNodeType.Attribute, "", "alt", "", "alt", "image Fooooooo!", false, false, false);
			Assert.IsTrue (!nav.MoveToAttribute ("src", ""));	// On attributes, it fails.
			Assert.IsTrue (nav.MoveToParent ());
			Assert.IsTrue (nav.MoveToAttribute ("src", ""));
			AssertNavigator ("#6", nav, XPathNodeType.Attribute, "", "src", "", "src", "foo.png", false, false, false);

			nav.MoveToRoot ();
			AssertNavigator ("#7", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
		}
Example #8
0
        /// <summary>
        /// Function analyzes children of the node recursively
        /// </summary>
        /// <param name="nodeNavigator">current node whose children schould be analyzed</param>
        /// <param name="groupName">currently created sequence of group names to this node</param>
        /// <param name="parameterName">name of the compared parameter</param>
        /// <param name="dictionaryEntry">entry for currently analyzed xml doc</param>
        /// <param name="temp">temporary entry for the parameter to be filled</param>
        public void AnalyzeNodeChildren(XPathNavigator nodeNavigator, string groupName, string parameterName, KeyValuePair<string, XPathDocument> dictionaryEntry, Dictionary<ParameterID, Dictionary<String, object>> temp)
        {
            nodeNavigator.MoveToFirstChild();

            do
            {
                //----comparing param's attributes-----------------

                if (nodeNavigator.HasChildren)
                {
                    // This is a group
                    StringBuilder groupNameNewSB = new StringBuilder();
                    nodeNavigator.MoveToAttribute("NAME", "");

                    groupNameNewSB.Append(groupName);
                    if (groupName != "")
                    {
                        groupNameNewSB.Append(".");
                    }

                    groupNameNewSB.Append(nodeNavigator.Value);

                    nodeNavigator.MoveToParent();
                    AnalyzeNodeChildren(nodeNavigator, groupNameNewSB.ToString(), parameterName, dictionaryEntry, temp);
                }
                else
                {
                    nodeNavigator.MoveToFirstAttribute();

                    do
                    {
                        switch (nodeNavigator.Name)
                        {
                            case "NAME":
                                break;
                            case "HINT":
                                break;
                            case "TYPE":
                                break;
                            case "VALUE": // this can be done better....... but anyways , let's continue :)
                                //paramValue = Convert.ToDouble(thisNavigator.ValueAsDouble);
                                object paramValue = null;
                                double doubleValue;
                                bool paramIsString = false;
                                if (!Double.TryParse(nodeNavigator.Value, NumberStyles.Number, CultureInfo.InvariantCulture/*CultureInfo.CreateSpecificCulture("en-GB")*/, out doubleValue))
                                {
                                    paramValue = nodeNavigator.Value;
                                    paramIsString = true;
                                }

                                //------- move to attribute doesn't work backwards (no idea why)
                                // update: because it cannot go from attribute to attribute with the use of
                                //MoveToAttribute method (in this case only MoveToNextAttribute can be used)
                                nodeNavigator.MoveToParent();
                                nodeNavigator.MoveToFirstChild();
                                nodeNavigator.MoveToAttribute("NAME", "");

                                //if no match with desired name 'break;' and go to the next one
                                if (!nodeNavigator.Value.Contains(parameterName))
                                {
                                    nodeNavigator.MoveToParent();
                                    nodeNavigator.MoveToFirstChild();
                                    nodeNavigator.MoveToAttribute("VALUE", "");
                                    break;
                                }

                                #region Adding parameter to temp
                                //....add( (fileName, Concatenated String <groupName + , +  parameterName>), parameterValue)
                                if (paramIsString)
                                {
                                    // For this I could have written a function :)
                                    Dictionary<string, object> tempDictionary = new Dictionary<string, object>();

                                    ///if this parameter entry already exists, then only add it's difference entry in its dictionary
                                    if (temp.TryGetValue(new ParameterID(nodeNavigator.Value, groupName, true), out tempDictionary))
                                    //if (temp.ContainsKey(new parameterID(thisNavigator.Value, groupName)))
                                    {
                                        tempDictionary.Add(dictionaryEntry.Key, paramValue);
                                    }
                                    else
                                    {
                                        tempDictionary = new Dictionary<string, object>();
                                        tempDictionary.Add(dictionaryEntry.Key, paramValue);
                                        temp.Add(new ParameterID(nodeNavigator.Value, groupName, true), tempDictionary);
                                        //(DictionaryEntry.Key, groupName + ", " + thisNavigator.Value), paramValue);
                                    }
                                }
                                else
                                {
                                    Dictionary<string, object> tempDictionary = new Dictionary<string, object>();

                                    ///if this parameter entry already exists, then only add it's difference entry in its dictionary
                                    if (temp.TryGetValue(new ParameterID(nodeNavigator.Value, groupName, false), out tempDictionary))
                                    //if (temp.ContainsKey(new parameterID(thisNavigator.Value, groupName)))
                                    {
                                        tempDictionary.Add(dictionaryEntry.Key, doubleValue);
                                    }
                                    else
                                    {
                                        tempDictionary = new Dictionary<string, object>();
                                        tempDictionary.Add(dictionaryEntry.Key, doubleValue);
                                        temp.Add(new ParameterID(nodeNavigator.Value, groupName, false), tempDictionary);
                                        //(DictionaryEntry.Key, groupName + ", " + thisNavigator.Value), paramValue);
                                    }
                                }
                                #endregion

                                //again - doesn't work backwards
                                nodeNavigator.MoveToParent();
                                nodeNavigator.MoveToFirstChild();
                                nodeNavigator.MoveToAttribute("VALUE", "");

                                break;
                            case "LEVEL":
                                break;
                            default:
                                break;
                        }

                    } while (nodeNavigator.MoveToNextAttribute());
                    nodeNavigator.MoveToParent();
                }
            } while (nodeNavigator.MoveToNext());//iteration on params

            nodeNavigator.MoveToParent();
        }
Example #9
0
		public XPathNavigator CreateAttribute(string name, string namespaceUri, XPathNavigator source)
		{
			name = XmlConvert.EncodeLocalName(name);
			source.CreateAttribute(null, name, namespaceUri, "");
			source.MoveToAttribute(name, namespaceUri ?? "");
			return source;
		}
        public override string GetAttribute(string name)
        {
            string         str;
            string         str2;
            XPathNavigator nav = this.nav;

            switch (nav.NodeType)
            {
            case XPathNodeType.Element:
                break;

            case XPathNodeType.Attribute:
                nav = nav.Clone();
                if (nav.MoveToParent())
                {
                    break;
                }
                return(null);

            default:
                return(null);
            }
            ValidateNames.SplitQName(name, out str, out str2);
            if (str.Length == 0)
            {
                if (str2 == "xmlns")
                {
                    return(nav.GetNamespace(string.Empty));
                }
                if (nav == this.nav)
                {
                    nav = nav.Clone();
                }
                if (nav.MoveToAttribute(str2, string.Empty))
                {
                    return(nav.Value);
                }
            }
            else
            {
                if (str == "xmlns")
                {
                    return(nav.GetNamespace(str2));
                }
                if (nav == this.nav)
                {
                    nav = nav.Clone();
                }
                if (nav.MoveToFirstAttribute())
                {
                    do
                    {
                        if ((nav.LocalName == str2) && (nav.Prefix == str))
                        {
                            return(nav.Value);
                        }
                    }while (nav.MoveToNextAttribute());
                }
            }
            return(null);
        }
Example #11
0
 public void DeleteNil(XPathNavigator node)
 {
     if (node.MoveToAttribute(
        "nil", NamespaceManager.LookupNamespace("xsi")))
         node.DeleteSelf();
 }
Example #12
0
		private string GetAttributeValue(XPathNavigator navigator, string name)
		{
			string val = "";
			if (navigator.MoveToAttribute(name, ""))
			{
				val = navigator.Value;
				navigator.MoveToParent();
			}
			return val;
		}	
        /// <summary>
        /// Checks if first navigator is equal to or subset of second.
        /// </summary>
        /// <param name="first">First navigator.</param>
        /// <param name="second">Second navigator.</param>
        /// <param name="checkSubset"><b>true</b> if we want to check that first 
        /// navigator and second has equal contents. <b>false</b> if contents of
        /// first iterator should be subset of second iterator's contents.</param>
        private static void AreEqual( XPathNavigator first, XPathNavigator second, bool checkSubset )
        {
            do
            {
                Assert.AreEqual( first.NodeType, second.NodeType, string.Format( "Types of nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                if( first.NodeType != XPathNodeType.Root
                    && first.NodeType != XPathNodeType.Whitespace
                    && first.NodeType != XPathNodeType.Text
                    && first.NodeType != XPathNodeType.Comment
                    )
                {
                    Assert.AreEqual( first.LocalName, second.LocalName, string.Format( "Names of nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                    Assert.AreEqual( first.NamespaceURI, second.NamespaceURI, string.Format( "Namespaces of nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                }
                if( first.NodeType != XPathNodeType.Root &&
                    first.NodeType != XPathNodeType.Element &&
                    first.NodeType != XPathNodeType.Whitespace
                    )
                    Assert.AreEqual( first.Value, second.Value, string.Format( "Values of nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );

                if( MoveToFirstAttribute( first ) )
                {
                    if( ( !checkSubset && !MoveToFirstAttribute( second ) )
                        || ( checkSubset && !second.MoveToAttribute( first.LocalName, first.NamespaceURI ) ) )
                        throw new AssertionException( string.Format( "Missing node '{0}' in second navigator.", MakePath( first ) ) );

                    do
                    {
                        Assert.AreEqual( first.NodeType, second.NodeType );
                        Assert.AreEqual( first.LocalName, second.LocalName );
                        Assert.AreEqual( first.NamespaceURI, second.NamespaceURI );
                        Assert.AreEqual( first.Value, second.Value, string.Format( "Values of attributes {0}:{1} must match.", first.Prefix, first.LocalName ) );

                        if( !MoveToNextAttribute( first ) )
                        {
                            if( !checkSubset && MoveToNextAttribute( second ) )
                                throw new AssertionException( string.Format( "Extra node '{0}' in second navigator.", MakePath( second ) ) );
                            break;
                        }
                        if( !checkSubset )
                        {
                            if( !MoveToNextAttribute( second ) )
                                throw new AssertionException( string.Format( "Missing node '{0}' in second navigator.", MakePath( first ) ) );
                        }
                        else
                        {
                            second.MoveToParent();
                            if( !second.MoveToAttribute( first.LocalName, first.NamespaceURI ) )
                                throw new AssertionException( string.Format( "Missing node '{0}' in second navigator.", MakePath( first ) ) );
                        }
                    }
                    while( true );

                    first.MoveToParent();
                    second.MoveToParent();
                }
                else if( !checkSubset && MoveToFirstAttribute( second ) )
                {
                    throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                }

                /*
                * We don't care how namespaces are defined.
                *
                if( first.MoveToFirstNamespace( XPathNamespaceScope.Local ) )
                {
                    if( !second.MoveToFirstNamespace( XPathNamespaceScope.Local ) )
                        throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                    do
                    {
                        Assert.AreEqual( first.NodeType, second.NodeType );
                        Assert.AreEqual( first.LocalName, second.LocalName );
                        Assert.AreEqual( first.NamespaceURI, second.NamespaceURI );
                        Assert.AreEqual( first.Value, second.Value );

                        if( !first.MoveToNextNamespace( XPathNamespaceScope.Local ) )
                        {
                            if( second.MoveToNextNamespace( XPathNamespaceScope.Local ) )
                                throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                            break;
                        }
                        if( !second.MoveToNextNamespace( XPathNamespaceScope.Local ) )
                            throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                    }
                    while( true );

                    first.MoveToParent();
                    second.MoveToParent();
                }
                */

                if( first.MoveToFirstChild() )
                {
                    if( !second.MoveToFirstChild() )
                        throw new AssertionException( string.Format( "Missing node '{0}' in second navigator.", MakePath( first ) ) );
                    if( checkSubset
                        && !CompareNodes( first, second )
                        && !FindNextElement( second, first ) )
                        throw new AssertionException( string.Format( "Missing node '{0}' in second navigator.", MakePath( first ) ) );
                    continue;
                }
                else if( !checkSubset && second.MoveToFirstChild() )
                    throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );

                // Move to next
                if( first.MoveToNext() )
                {
                    if( !checkSubset )
                    {
                        if( !second.MoveToNext() )
                            throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                    }
                    else
                    {
                        // Find next subelement with corresponding name
                        if( !FindNextElement( second, first ) )
                            throw new AssertionException( string.Format( "Missing node '{0}' in second navigator.", MakePath( first ) ) );
                    }
                    continue;
                }
                else if( !checkSubset && second.MoveToNext() )
                    throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );

                // Move up
                do
                {
                    if( first.MoveToParent() )
                    {
                        if( !second.MoveToParent() )
                            throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                    }
                    else
                        goto Finish;

                    if( first.MoveToNext() )
                    {
                        if( !second.MoveToNext() )
                            throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                        break;
                    }
                    else if( !checkSubset && second.MoveToNext() )
                        throw new AssertionException( string.Format( "Nodes '{0}' and '{1}' must match.", MakePath( first ), MakePath( second ) ) );
                }
                while( true );
            }
            while( true );

            Finish:
            return;
        }
Example #14
0
		public XPathNavigator CreateAttribute(string name, string namespaceUri, XPathNavigator source)
		{
			string prefix;
			name = XmlConvert.EncodeLocalName(name);
			if (IsRootNamespace(namespaceUri, out prefix))
				prefix = CreateNamespace(prefix, namespaceUri, source);
			source.CreateAttribute(prefix, name, namespaceUri, "");
			source.MoveToAttribute(name, namespaceUri ?? "");
			return source;
		}
Example #15
0
 public void DeleteNil(XPathNavigator node)
 {
     if (node.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
         node.DeleteSelf();
 }
        public override bool MoveToAttribute(string name)
        {
            int            num;
            string         str;
            string         str2;
            XPathNavigator elemNav = this.GetElemNav(out num);

            if (elemNav == null)
            {
                return(false);
            }
            ValidateNames.SplitQName(name, out str, out str2);
            bool flag = false;

            if ((flag = (str.Length == 0) && (str2 == "xmlns")) || (str == "xmlns"))
            {
                if (flag)
                {
                    str2 = string.Empty;
                }
                if (elemNav.MoveToFirstNamespace(XPathNamespaceScope.Local))
                {
                    do
                    {
                        if (elemNav.LocalName == str2)
                        {
                            goto Label_00B5;
                        }
                    }while (elemNav.MoveToNextNamespace(XPathNamespaceScope.Local));
                }
            }
            else
            {
                if (str.Length == 0)
                {
                    if (!elemNav.MoveToAttribute(str2, string.Empty))
                    {
                        goto Label_00B3;
                    }
                    goto Label_00B5;
                }
                if (elemNav.MoveToFirstAttribute())
                {
                    do
                    {
                        if ((elemNav.LocalName == str2) && (elemNav.Prefix == str))
                        {
                            goto Label_00B5;
                        }
                    }while (elemNav.MoveToNextAttribute());
                }
            }
Label_00B3:
            return(false);

Label_00B5:
            if (this.state == State.InReadBinary)
            {
                this.readBinaryHelper.Finish();
                this.state = this.savedState;
            }
            this.MoveToAttr(elemNav, num + 1);
            return(true);
        }
        public override bool MoveToAttribute(string name)
        {
            int            depth;
            XPathNavigator nav = GetElemNav(out depth);

            if (null == nav)
            {
                return(false);
            }

            string prefix, localname;

            ValidateNames.SplitQName(name, out prefix, out localname);

            // watch for a namespace name
            bool IsXmlnsNoPrefix = false;

            if ((IsXmlnsNoPrefix = (0 == prefix.Length && localname == "xmlns")) ||
                (prefix == "xmlns"))
            {
                if (IsXmlnsNoPrefix)
                {
                    localname = string.Empty;
                }
                if (nav.MoveToFirstNamespace(XPathNamespaceScope.Local))
                {
                    do
                    {
                        if (nav.LocalName == localname)
                        {
                            goto FoundMatch;
                        }
                    } while (nav.MoveToNextNamespace(XPathNamespaceScope.Local));
                }
            }
            else if (0 == prefix.Length)
            {
                // the empty prefix always means empty namespaceUri for attributes
                if (nav.MoveToAttribute(localname, string.Empty))
                {
                    goto FoundMatch;
                }
            }
            else
            {
                if (nav.MoveToFirstAttribute())
                {
                    do
                    {
                        if (nav.LocalName == localname && nav.Prefix == prefix)
                        {
                            goto FoundMatch;
                        }
                    } while (nav.MoveToNextAttribute());
                }
            }
            return(false);

FoundMatch:
            if (_state == State.InReadBinary)
            {
                _readBinaryHelper.Finish();
                _state = _savedState;
            }
            MoveToAttr(nav, depth + 1);
            return(true);
        }
Example #18
0
        private void createSubplatform(XPathNavigator navLocal, XmlDocument document, XPathNavigator navGlobal)
        {
            //itSubplatforms.Current.CreateAttribute(String.Empty, "name", String.Empty, cName + "Subplatform" + subplatNum++ + AME.Tools.ImportTool.Delimitter + "Subplatform");
            String eventName = navLocal.SelectSingleNode("parent::node()").GetAttribute("name", navLocal.NamespaceURI);

            // Set up component values
            String cType = "Subplatform";
            String cName;
            String cDescription = String.Empty;

            // Create links
            #region links
            
            // SubplatformKind
            String kind = (navLocal.SelectSingleNode("Kind") == null) ? String.Empty : navLocal.SelectSingleNode("Kind").Value;
            kind = kind.Trim();
            if (navGlobal.SelectSingleNode(String.Format("/Scenario/Species[Name='{0}']", kind)) != null)
            {
                // Create component _ Want Kind in the component name.
                cName = navLocal.GetAttribute("name", navLocal.NamespaceURI) + AME.Tools.ImportTool.Delimitter + kind + "_" + cType;
                navLocal.MoveToAttribute("name", navLocal.NamespaceURI);
                navLocal.SetValue(cName);
                navLocal.MoveToParent();
                
                createComponent(VSGConfiguration, document, cType, cName, cDescription);

                createLink(VSGConfiguration, document, cName, cName, kind, "SubplatformKind", String.Empty);
            }
            else
            {
                cName = navLocal.GetAttribute("name", navLocal.NamespaceURI);

                // Create component
                createComponent(VSGConfiguration, document, cType, cName, cDescription);
            }

            // Scenario Link
            createLink(VSGConfiguration, document, navGlobal.SelectSingleNode("/Scenario").GetAttribute("name", navGlobal.NamespaceURI), eventName, cName, "Scenario", String.Empty);


            #endregion

            // Create parameters
            #region parameters

            if (navLocal.SelectSingleNode("Docked") != null)
                createParameter(VSGConfiguration, document, cName, "Component", "Subplatform.DockedCount", (navLocal.SelectSingleNode("Docked/Count") == null) ? String.Empty : navLocal.SelectSingleNode("Docked/Count").Value, String.Empty);

            #endregion

            // Armaments
            Int32 armamentNum = 0;
            XPathNodeIterator itArmaments = navLocal.Select("Armament");
            while (itArmaments.MoveNext())
            {
                itArmaments.Current.CreateAttribute(String.Empty, "name", String.Empty, cName + "Armament" + armamentNum++ + AME.Tools.ImportTool.Delimitter + "Armament");
                createArmament(itArmaments.Current, document, navGlobal);
            }
        }