Пример #1
0
 internal void AddRange(XMLList list)
 {
     foreach (XML xml in list.m_Nodes)
     {
         Add(xml);
     }
 }
Пример #2
0
        private object Copy()
        {
            XMLList list = new XMLList(lib);

            foreach (XML xml in m_Nodes)
            {
                list.Add((XML)xml.Copy());
            }
            return(list);
        }
Пример #3
0
        internal XMLList GetPropertyList(XMLName xmlName)
        {
            XMLList list = new XMLList(lib);

            foreach (XML xml in m_Nodes)
            {
                list.AddRange(xml.GetPropertyList(xmlName));
            }
            return(list);
        }
Пример #4
0
        private XMLList Child(long index)
        {
            XMLList list = new XMLList(lib);

            foreach (XML xml in this)
            {
                list.AddRange(xml.Child(index));
            }
            return(list);
        }
Пример #5
0
        /// <summary>
        /// XMLList.prototype.processingInstructions ( [ name ] )
        ///
        /// The processingInstructions method calls the processingInstructions
        /// method of each XML object in this XMLList object passing the optional
        /// parameter name (or "*" if it is omitted) and returns an XMList
        /// containing the results in order.
        ///
        /// See ECMA
        /// </summary>
        private XMLList ProcessingInstructions(XMLName name)
        {
            XMLList list = new XMLList(lib);

            foreach (XML xml in this)
            {
                list.AddRange(xml.ProcessingInstructions(name));
            }
            return(list);
        }
Пример #6
0
        private XMLList Descendants(XMLName xmlName)
        {
            XMLList list = new XMLList(lib);

            foreach (XML xml in this)
            {
                list.AddRange(xml.Descendants(xmlName));
            }
            return(list);
        }
Пример #7
0
        /// <summary>
        /// XMLList.prototype.child ( propertyName )
        ///
        /// The child method calls the child() method of each XML object in
        /// this XMLList object and returns an XMLList containing the results
        /// in order.
        ///
        /// See ECMA 13.5.4.4
        /// </summary>
        private XMLList Child(XMLName xmlName)
        {
            XMLList list = new XMLList(lib);

            foreach (XML xml in this)
            {
                list.AddRange(xml.Child(xmlName));
            }
            return(list);
        }
Пример #8
0
        private XMLList Attributes()
        {
            XMLList list = new XMLList(lib);

            foreach (XML xml in this)
            {
                list.AddRange(xml.Attributes());
            }
            return(list);
        }
Пример #9
0
        private XMLList Children()
        {
            XMLList list = new XMLList(lib);

            foreach (XML xml in m_Nodes)
            {
                list.AddRange(xml.Children());
            }
            return(list);
        }
Пример #10
0
        protected internal override object GetXMLProperty(XMLName name)
        {
            if (isPrototype)
            {
                return(base.Get(name.localName, this));
            }

            XMLList list = new XMLList(lib);

            foreach (XML xml in m_Nodes)
            {
                list.AddRange((XMLList)xml.GetXMLProperty(name));
            }
            return(list);
        }
Пример #11
0
        public XMLList(XMLLib lib, object inputObject)
            : this(lib)
        {
            string frag;
            if (inputObject == null || inputObject is Undefined)
            {
                frag = "";
            }
            else if (inputObject is XML)
            {
                XML xml = (XML)inputObject;
                Add(xml);
            }
            else if (inputObject is XMLList)
            {
                XMLList xmll = (XMLList)inputObject;
                AddRange(xmll);
            }
            else
            {
                frag = ScriptConvert.ToString(inputObject).Trim();
                if (!frag.StartsWith("<>"))
                {
                    frag = "<>" + frag + "</>";
                }
                frag = "<fragment>" + frag.Substring(2);
                if (!frag.EndsWith("</>"))
                {
                    throw ScriptRuntime.TypeError("XML with anonymous tag missing end anonymous tag");
                }
                frag = frag.Substring(0, frag.Length - 3) + "</fragment>";

                XML orgXML = XML.CreateFromJS(lib, frag);

                // Now orphan the children and add them to our XMLList.
                XMLList children = (XMLList)orgXML.Children();
                AddRange(children);
            }
        }
Пример #12
0
 private XMLList Attributes ()
 {
     XMLList list = new XMLList (lib);
     foreach (XML xml in this)
         list.AddRange (xml.Attributes ());
     return list;
 }
Пример #13
0
        public override object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args)
        {
            if (!f.HasTag(XMLOBJECT_TAG))
            {
                return(base.ExecIdCall(f, cx, scope, thisObj, args));
            }

            int id = f.MethodId;

            if (id == Id_constructor)
            {
                return(JsConstructor(cx, thisObj == null, args));
            }

            // All XML.prototype methods require thisObj to be XML
            if (!(thisObj is XMLList))
            {
                throw IncompatibleCallError(f);
            }
            XMLList realThis = (XMLList)thisObj;

            XMLName xmlName;

            switch (id)
            {
            case Id_attribute:
                xmlName = XMLName.Parse(lib, cx, GetArgSafe(args, 0));
                return(realThis.Attribute(xmlName));

            case Id_attributes:
                return(realThis.Attributes());

            case Id_child:
                xmlName = XMLName.Parse(lib, cx, GetArgSafe(args, 0));
                if (xmlName == null)
                {
                    long index = ScriptRuntime.lastUint32Result(cx);
                    return(realThis.Child(index));
                }
                else
                {
                    return(realThis.Child(xmlName));
                }

            case Id_children:
                return(realThis.Children());

            case Id_contains:
                return(realThis.Contains(GetArgSafe(args, 0)));

            case Id_copy:
                return(realThis.Copy());

            case Id_descendants: {
                xmlName = (args.Length == 0)
                            ? XMLName.FormStar() : XMLName.Parse(lib, cx, GetArgSafe(args, 0));
                return(realThis.Descendants(xmlName));
            }

            case Id_hasOwnProperty:
                xmlName = XMLName.Parse(lib, cx, GetArgSafe(args, 0));
                return(realThis.HasOwnProperty(xmlName));


            case Id_hasComplexContent:
                return(realThis.HasComplexContent());

            case Id_hasSimpleContent:
                return(realThis.HasSimpleContent());

            case Id_length:
                return(realThis.Length());

            case Id_normalize:
                realThis.Normalize();
                return(Undefined.Value);

            case Id_parent:
                return(realThis.Parent());

            case Id_processingInstructions:
                xmlName = (args.Length > 0) ? XMLName.Parse(lib, cx, args [0]) : XMLName.FormStar();
                return(realThis.ProcessingInstructions(xmlName));

            case Id_propertyIsEnumerable: {
                return(realThis.PropertyIsEnumerable(GetArgSafe(args, 0)));
            }

            case Id_text:
                return(realThis.Text());

            case Id_toString:
                return(realThis.ToString());

            case Id_toXMLString:
                return(realThis.ToXMLString());

            case Id_valueOf:
                return(realThis);

            case Id_addNamespace:
                return(realThis.DelegateTo("addNamespace").AddNamespace(GetArgSafe(args, 0)));

            case Id_appendChild:
                return(realThis.DelegateTo("appendChild").AppendChild(GetArgSafe(args, 0)));

            case Id_childIndex:
                return(realThis.DelegateTo("childIndex").ChildIndex());

            case Id_inScopeNamespaces:
                return(realThis.DelegateTo("inScopeNamespaces").InScopeNamespaces());

            case Id_insertChildAfter:
                return(realThis.DelegateTo("insertChildAfter").InsertChildAfter(GetArgSafe(args, 0), GetArgSafe(args, 1)));

            case Id_insertChildBefore:
                return(realThis.DelegateTo("insertChildBefore").InsertChildBefore(GetArgSafe(args, 0), GetArgSafe(args, 1)));

            case Id_localName:
                return(realThis.DelegateTo("localName").LocalName());

            case Id_name:
                return(realThis.DelegateTo("name").Name());

            case Id_namespace:
                return(realThis.DelegateTo("namespace").Namespace(GetArgSafe(args, 0)));

            case Id_namespaceDeclarations:
                return(realThis.DelegateTo("namespaceDeclarations").NamespaceDeclarations());

            case Id_nodeKind:
                return(realThis.DelegateTo("nodeKind").NodeKind());

            case Id_prependChild:
                return(realThis.DelegateTo("prependChild").PrependChild(GetArgSafe(args, 0)));

            case Id_removeNamespace:
                return(realThis.DelegateTo("removeNamespace").RemoveNamespace(GetArgSafe(args, 0)));

            case Id_replace:
                return(realThis.DelegateTo("replace").Replace(GetArgSafe(args, 0), GetArgSafe(args, 1)));

            case Id_setChildren:
                return(realThis.DelegateTo("setChildren").SetChildren(GetArgSafe(args, 0)));

            case Id_setLocalName:
                realThis.DelegateTo("setLocalName").SetLocalName(GetArgSafe(args, 0));
                return(Undefined.Value);

            case Id_setName:
                realThis.DelegateTo("setName").SetName(GetArgSafe(args, 0));
                return(Undefined.Value);

            case Id_setNamespace:
                realThis.DelegateTo("setNamespace").SetNamespace(GetArgSafe(args, 0));
                return(Undefined.Value);
            }

            throw new System.ArgumentException(System.Convert.ToString(id));
        }
Пример #14
0
 private XMLList Descendants (XMLName xmlName)
 {
     XMLList list = new XMLList (lib);
     foreach (XML xml in this)
         list.AddRange (xml.Descendants (xmlName));
     return list;
 }
Пример #15
0
 /// <summary>
 /// XML.prototype.child ( propertyName )
 /// 
 /// The child method returns the list of children in this 
 /// XML object matching the given propertyName. If propertyName is a numeric
 /// index, the child method returns a list containing the child at the
 /// ordinal position identified by propertyName.
 /// 
 /// See ECMA 13.4.4.6 
 /// </summary>
 /// <param name="index"></param>
 /// <returns></returns>
 internal XMLList Child(long index)
 {
     XMLList list = new XMLList (lib);
     if (index > 0 || index < UnderlyingNode.ChildNodes.Count)
         list.Add (new XML (lib, UnderlyingNode.ChildNodes [(int)index]));
     return list;
 }
Пример #16
0
 private XMLList Child (long index)
 {
     XMLList list = new XMLList (lib);
     foreach (XML xml in this)
         list.AddRange (xml.Child (index));
     return list;
 }
Пример #17
0
 /// <summary>
 /// XML.prototype.processingInstructions ( [ name ] )
 /// 
 /// When the processingInstructions method is called with one 
 /// parameter name, it returns an XMLList containing all the 
 /// children of this XML object that are processing-instructions 
 /// with the given name. When the processingInstructions method 
 /// is called with no parameters, it returns an XMLList containing 
 /// all the children of this XML object that are processing-instructions
 /// regardless of their name.
 /// 
 /// See ECMA 13.4.4.28
 /// </summary>
 /// <returns></returns>
 internal XMLList ProcessingInstructions(XMLName xmlName)
 {
     XMLList list = new XMLList (lib);
     foreach (XmlNode child in UnderlyingNode.ChildNodes) {
         if (child is XmlProcessingInstruction) {
             if (xmlName == null || xmlName.Matches (child))
                 list.Add (new XML (lib, child));
         }
     }
     return list;
 }
Пример #18
0
 /// <summary>
 /// XMLList.prototype.processingInstructions ( [ name ] )
 /// 
 /// The processingInstructions method calls the processingInstructions
 /// method of each XML object in this XMLList object passing the optional
 /// parameter name (or "*" if it is omitted) and returns an XMList
 /// containing the results in order.
 /// 
 /// See ECMA 
 /// </summary>
 private XMLList ProcessingInstructions (XMLName name)
 {
     XMLList list = new XMLList (lib);
     foreach (XML xml in this) {
         list.AddRange (xml.ProcessingInstructions (name));
     }
     return list;
 }
Пример #19
0
 internal XMLList GetPropertyList (XMLName xmlName)
 {
     XMLList list = new XMLList (lib);
     foreach (XML xml in m_Nodes) {
         list.AddRange (xml.GetPropertyList (xmlName));
     }
     return list;
 }
Пример #20
0
 private object Copy ()
 {
     XMLList list = new XMLList (lib);
     foreach (XML xml in m_Nodes) {
         list.Add ((XML)xml.Copy ());
     }
     return list;
 }
Пример #21
0
        /// <summary>
        /// XML.prototype.elements ( [ name ] )
        /// 
        /// When the elements method is called with one parameter name,
        /// it returns an XMLList containing all the children of this
        /// XML object that are XML elements with the given name. When
        /// the elements method is called with no parameters, it returns
        /// an XMLList containing all the children of this XML object that
        /// are XML elements regardless of their name.
        /// 
        /// See ECMA 13.4.4.13
        /// </summary>
        private XMLList Elements(XMLName xmlName)
        {
            if (xmlName == null)
                return Children ();

            XMLList list = new XMLList (lib);
            MatchChildren (list, xmlName, UnderlyingNode, false);
            return list;
        }
Пример #22
0
        internal void MatchAttributes(XMLList list, XMLName xmlName, XmlNode parent, bool recursive)
        {
            if (parent is XmlDocument)
                parent = ((XmlDocument)parent).DocumentElement;

            if (!(parent is XmlElement))
                return;

            foreach (XmlAttribute attr in parent.Attributes) {
                if (xmlName == null || xmlName.Matches (attr))
                    list.Add (new XML (lib, attr));
            }

            if (recursive) {
                foreach (XmlNode node in parent.ChildNodes)
                    MatchAttributes (list, xmlName, node, recursive);
            }
        }
Пример #23
0
 /// <summary>
 /// XML.prototype.attribute ( attributeName )
 /// 
 /// The attribute method returns an XMLList
 /// containing zero or one XML attributes associated with 
 /// this XML object that have the given attributeName.
 /// 
 /// See ECMA 13.4.4.4
 /// </summary>
 /// <param name="xmlName"></param>
 /// <returns></returns>
 internal XMLList Attribute(XMLName xmlName)
 {
     XMLList list = new XMLList (lib);
     MatchAttributes (list, xmlName, UnderlyingNode, false);
     return list;
 }
Пример #24
0
 /// <summary>
 /// XML.prototype.comments ( )
 /// 
 /// The comments method returns an XMLList containing the properties of this
 /// XML object that represent XML comments.
 /// 
 /// See ECMA 13.4.4.9
 /// </summary>
 private XMLList Comments()
 {
     XMLList list = new XMLList (lib);
     foreach (XmlNode child in UnderlyingNode.ChildNodes) {
         if (child is XmlComment)
             list.Add (new XML (lib, child));
     }
     return list;
 }
Пример #25
0
 /// <summary>
 /// XMLList.prototype.child ( propertyName )
 /// 
 /// The child method calls the child() method of each XML object in
 /// this XMLList object and returns an XMLList containing the results
 /// in order.
 /// 
 /// See ECMA 13.5.4.4
 /// </summary>
 private XMLList Child (XMLName xmlName)
 {
     XMLList list = new XMLList (lib);
     foreach (XML xml in this)
         list.AddRange (xml.Child (xmlName));
     return list;
 }
Пример #26
0
 public void MatchChildren(XMLList list, XMLName xmlName, XmlNode parent, bool recursive)
 {
     foreach (XmlNode child in parent.ChildNodes) {
         if (xmlName.Matches (child))
             list.Add (new XML (lib, child));
         if (recursive)
             MatchChildren (list, xmlName, child, recursive);
     }
 }
Пример #27
0
 /// <summary>
 /// XML.prototype.children ( )
 /// 
 /// The children method returns an XMLList containing all the
 /// properties of this XML object in order.
 /// 
 /// See ECMA 13.4.4.8
 /// </summary>
 internal XMLList Children()
 {
     XMLList list = new XMLList (lib);
     foreach (XmlNode node in UnderlyingNode.ChildNodes)
         list.Add (new XML (lib, node));
     return list;
 }
Пример #28
0
 /// <summary>
 /// XML.prototype.attributes ( )
 /// 
 /// The attributes method returns an XMLList containing the XML attributes of this object.
 /// 
 /// See ECMA 13.4.4.5
 /// </summary>
 /// <returns></returns>
 internal XMLList Attributes()
 {
     XMLList list = new XMLList (lib);
     MatchAttributes (list, null, UnderlyingNode, false);
     return list;
 }
Пример #29
0
 private XMLList Children ()
 {
     XMLList list = new XMLList (lib);
     foreach (XML xml in m_Nodes) {
         list.AddRange (xml.Children ());
     }
     return list;
 }
Пример #30
0
 /// <summary>
 /// XML.prototype.child ( propertyName )
 /// 
 /// The child method returns the list of children in this 
 /// XML object matching the given propertyName. If propertyName is a numeric
 /// index, the child method returns a list containing the child at the
 /// ordinal position identified by propertyName.
 /// 
 /// See ECMA 13.4.4.6 
 /// </summary>
 /// <param name="index"></param>
 /// <returns></returns>
 internal XMLList Child(XMLName xmlName)
 {
     XMLList list = new XMLList (lib);
     MatchChildren (list, xmlName, UnderlyingNode, false);
     return list;
 }
Пример #31
0
        protected internal override object GetXMLProperty (XMLName name)
        {
            if (isPrototype) {
                return base.Get (name.localName, this);
            }

            XMLList list = new XMLList (lib);
            foreach (XML xml in m_Nodes) {
                list.AddRange ((XMLList)xml.GetXMLProperty (name));
            }
            return list;
        }
Пример #32
0
 /// <summary>
 /// XML.prototype.descendants ( [ name ] )
 /// 
 /// The descendants method returns all the XML valued descendants 
 /// (children, grandchildren, great-grandchildren, etc.) of this XML
 /// object with the given name. If the name parameter is omitted,
 /// it returns all descendants of this XML object.
 /// 
 /// See ECMA 13.4.4.12
 /// </summary>
 /// <param name="xmlName"></param>
 /// <returns></returns>
 internal XMLList Descendants(XMLName xmlName)
 {
     XMLList list = new XMLList (lib);
     if (xmlName.IsAttributeName) {
         MatchAttributes (list, xmlName, UnderlyingNode, true);
     }
     else {
         MatchChildren (list, xmlName, UnderlyingNode, true);
     }
     return list;
 }
Пример #33
0
 internal void AddRange (XMLList list)
 {
     foreach (XML xml in list.m_Nodes)
         Add (xml);
 }