Beispiel #1
0
 public AttributeBinding(XmlElement element, XmlName name, string val, bool specified)
 {
     this.element=element;
     this.name=name;
     this.val=val;
     this.specified=specified;
 }
 public static XmlName Create(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next, IXmlSchemaInfo schemaInfo) {
     if (schemaInfo == null) {
         return new XmlName(prefix, localName, ns, hashCode, ownerDoc, next);
     }
     else {
         return new XmlNameEx(prefix, localName, ns, hashCode, ownerDoc, next, schemaInfo);
     }
 }
Beispiel #3
0
 internal bool BindIDAttributeWithElementType(XmlName eleName, XmlName attrName)
 {
     if ( htElementIDAttrDecl[eleName] == null ) {
         htElementIDAttrDecl.Add(eleName, attrName);
         return true;
     }
     return false;
 }
 internal XmlName(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next) {
     this.prefix = prefix;
     this.localName = localName;
     this.ns = ns;
     this.name = null;
     this.hashCode = hashCode;
     this.ownerDoc = ownerDoc;
     this.next = next;
 }
 internal XmlNameEx(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next, IXmlSchemaInfo schemaInfo) : base(prefix, localName, ns, hashCode, ownerDoc, next)
 {
     this.SetValidity(schemaInfo.Validity);
     this.SetIsDefault(schemaInfo.IsDefault);
     this.SetIsNil(schemaInfo.IsNil);
     this.memberType = schemaInfo.MemberType;
     this.schemaType = schemaInfo.SchemaType;
     this.decl = (schemaInfo.SchemaElement != null) ? ((object) schemaInfo.SchemaElement) : ((object) schemaInfo.SchemaAttribute);
 }
Beispiel #6
0
 internal XmlAttribute( XmlName name, XmlDocument doc ): base( doc ) {
     Debug.Assert(name!=null);
     Debug.Assert(doc!=null);
     if ( !doc.IsLoading ) {
         XmlDocument.CheckName( name.Prefix );
         XmlDocument.CheckName( name.LocalName );
     }
     if (name.LocalName=="")
         throw new ArgumentException(Res.GetString(Res.Xdom_Attr_Name));
     this.name = name;
 }
Beispiel #7
0
 internal XmlAttribute(XmlName name, XmlDocument doc) : base(doc)
 {
     Debug.Assert(name != null);
     Debug.Assert(doc != null);
     this.parentNode = null;
     if (!doc.IsLoading)
     {
         XmlDocument.CheckName(name.Prefix);
         XmlDocument.CheckName(name.LocalName);
     }
     if (name.LocalName.Length == 0)
         throw new ArgumentException(SR.Xdom_Attr_Name);
     _name = name;
 }
        XmlLinkedNode lastChild; // == this for empty elements otherwise it is the last child

        internal XmlElement( XmlName name, bool empty, XmlDocument doc ): base( doc ) {
            Debug.Assert(name!=null);
            this.parentNode = null;
            if ( !doc.IsLoading ) {
                XmlDocument.CheckName( name.Prefix );
                XmlDocument.CheckName( name.LocalName );
            }
            if (name.LocalName.Length == 0) 
                throw new ArgumentException(Res.GetString(Res.Xdom_Empty_LocalName));
            this.name = name;
            if (empty) {
                this.lastChild = this; 
            }
        }
Beispiel #9
0
 internal XmlElement( XmlName name, bool empty, XmlDocument doc ): base( doc ) {
     Debug.Assert(name!=null);
     if ( !doc.IsLoading ) {
         XmlDocument.CheckName( name.Prefix );
         XmlDocument.CheckName( name.LocalName );
     }
     if (name.LocalName == "") 
         throw new ArgumentException(Res.GetString(Res.Xdom_Empty_LocalName));
     if ( name.Prefix.Length >= 3 && (! doc.IsLoading) && String.Compare( name.Prefix, 0, "xml", 0, 3, true, CultureInfo.InvariantCulture) == 0 )
         throw new ArgumentException(Res.GetString(Res.Xdom_Ele_Prefix));
     this.name = name;
     if (empty)
         lastChild = emptyElem;
     else
         lastChild = null;
 }
        XmlLinkedNode lastChild; // == this for empty elements otherwise it is the last child

        internal XmlElement( XmlName name, bool empty, XmlDocument doc ): base( doc ) {
            Debug.Assert(name!=null);
            this.parentNode = null;
            if ( !doc.IsLoading ) {
                XmlDocument.CheckName( name.Prefix );
                XmlDocument.CheckName( name.LocalName );
            }
            if (name.LocalName.Length == 0) 
                throw new ArgumentException(Res.GetString(Res.Xdom_Empty_LocalName));
            if ( name.Prefix.Length >= 3 && (! doc.IsLoading) && String.Compare( name.Prefix, 0, "xml", 0, 3, StringComparison.OrdinalIgnoreCase ) == 0 )
                throw new ArgumentException(Res.GetString(Res.Xdom_Ele_Prefix));
            this.name = name;
            if (empty) {
                this.lastChild = this; 
            }
        }
 private void Grow()
 {
     int num = (this.mask * 2) + 1;
     XmlName[] entries = this.entries;
     XmlName[] nameArray2 = new XmlName[num + 1];
     for (int i = 0; i < entries.Length; i++)
     {
         XmlName next;
         for (XmlName name = entries[i]; name != null; name = next)
         {
             int index = name.HashCode & num;
             next = name.next;
             name.next = nameArray2[index];
             nameArray2[index] = name;
         }
     }
     this.entries = nameArray2;
     this.mask = num;
 }
		private IXsltContextVariable ResolveVariableCore(string prefix, string name)
		{
			IXsltContextVariable variable;
			var key = new XmlName(name, prefix ?? string.Empty);
			variables.TryGetValue(key, out variable);
			return variable;
		}
		public void AddFunction(XmlName name, IXsltContextFunction function)
		{
			EnsureFunctions()[name] = function;
		}
Beispiel #14
0
 internal XmlNameEx(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next, IXmlSchemaInfo schemaInfo) : base(prefix, localName, ns, hashCode, ownerDoc, next)
 {
     SetValidity(schemaInfo.Validity);
     SetIsDefault(schemaInfo.IsDefault);
     SetIsNil(schemaInfo.IsNil);
     _memberType = schemaInfo.MemberType;
     _schemaType = schemaInfo.SchemaType;
     _decl       = schemaInfo.SchemaElement != null
            ? (object)schemaInfo.SchemaElement
            : (object)schemaInfo.SchemaAttribute;
 }
Beispiel #15
0
 public ElementListItem(XmlName name)
     : this(name, false, false)
 {
 }
Beispiel #16
0
 public ElementListItem(XmlName name, bool required, bool choice)
 {
     this.Name=name;
     this.IsRequired=required;
     this.IsChoice=choice;
 }
Beispiel #17
0
		private XmlAttribute CreateAttributeCore(XmlNode parent, XmlName name)
		{
			var document  = parent.OwnerDocument ?? (XmlDocument) parent;
			var prefix    = Namespaces.GetAttributePrefix(this, name.NamespaceUri);
			var attribute = document.CreateAttribute(prefix, name.LocalName, name.NamespaceUri);
			node = attribute;
			return attribute;
		}
Beispiel #18
0
 internal XmlName GetIDAttributeByElement(XmlName eleName)
 {
     return (XmlName)(htElementIDAttrDecl[eleName]);
 }
 // This function returns null because it is implication of removing schema.
 // If removed more methods would have to be removed as well and it would make adding schema back much harder.
 internal XmlName GetIDInfoByElement(XmlName eleName)
 {
     return(null);
 }
Beispiel #20
0
 public static XmlName Create(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next)
 {
     return(new XmlName(prefix, localName, ns, hashCode, ownerDoc, next));
 }
Beispiel #21
0
 internal XmlName(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next)
 {
     _prefix       = prefix;
     _localName    = localName;
     _ns           = ns;
     _name         = null;
     _hashCode     = hashCode;
     this.ownerDoc = ownerDoc;
     this.next     = next;
 }
		private IXsltContextFunction ResolveFunctionCore(string prefix, string name, XPathResultType[] argTypes)
		{
			IXsltContextFunction function;
			var key = new XmlName(name, prefix ?? string.Empty);
			functions.TryGetValue(key, out function);
			return function;
		}
Beispiel #23
0
		private XmlElement CreateElementCore(XmlNode parent, XmlName name)
		{
			var document = parent.OwnerDocument ?? (XmlDocument) parent;
			var prefix   = Namespaces.GetElementPrefix(this, name.NamespaceUri);
			var element  = document.CreateElement(prefix, name.LocalName, name.NamespaceUri);
			node = element;
			return element;
		}
Beispiel #24
0
 // This function returns null because it is implication of removing schema.
 // If removed more methods would have to be removed as well and it would make adding schema back much harder. 
 internal XmlName GetIDInfoByElement(XmlName eleName)
 {
     return null;
 }
 protected virtual void PerformAction(XmlName name)
 {
 }
 private ElementTypeRef FindInCollection(ICollection col, XmlElement e)
 {
     foreach ( ElementTypeRef sr in col )
     {
         XmlName xn=new XmlName(e);
         if ( sr.Name.Equals(xn) )
             return sr;
     }
     return null;
 }
Beispiel #27
0
 public ElementListItem(XmlName name, bool required)
     : this(name, required, false)
 {
 }
        private ElementListItem[] FindValidElements(ElementType et, XmlElement parent, XmlNode n, bool replace)
        {
            int index=-1;

            ArrayList children=new ArrayList();
            foreach ( XmlNode c in parent.ChildNodes )
            {
                if ( c.Equals(n) )
                    index=children.Count;

                if ( c.NodeType != XmlNodeType.Element )
                    continue;

                XmlName xn=new XmlName(c);
                children.Add(xn);
            }
            if ( index < 0 )
            {
                Debug.Assert(!replace, "This can't happen if in replace mode");
                children.Add(null);
                index=children.Count-1;
            }
            else
            {
                if ( !replace )
                    children.Insert(index, null);
            }

            ArrayList ret=new ArrayList();
            foreach ( ElementType t in et.ChildElements )
            {
                children[index]=t.Name;

                ElementTypeRef sr=IsValidSequence(et, children, index);
                if ( sr != null )
                    ret.Add(new ElementListItem(sr.Name, sr.IsRequired, sr.IsChoice));
            }
            return ret.ToArray(typeof(ElementListItem)) as ElementListItem[];
        }
Beispiel #29
0
        private void RemoveIdOrIdRef(XmlElement e, XmlAttribute a)
        {
            ElementType et=documentType.GetElementType(e);
            XmlName xn=new XmlName(a);
            Attribute attr=et.GetAttribute(xn);
            if ( attr == null )
                return;

            AttributeBinding ab;
            string val=a.Value;
            switch ( attr.Type )
            {
                case AttributeType.ID:
                    // record the previous id because we'll need that later (NodeChanged event)
                    ab=new AttributeBinding(e, attr.Name, val, a.Specified);
                    idTracker.RemoveId(ab);
                    ProcessRemovedId(val);
                    break;

                case AttributeType.IDREF:
                case AttributeType.IDREFS:
                    ab=new AttributeBinding(e, attr.Name, val, a.Specified);
                    idTracker.RemoveIdRefs(ab);
                    break;
            }
        }
Beispiel #30
0
 public static XmlName Create(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next, IXmlSchemaInfo schemaInfo)
 {
     if (schemaInfo == null)
     {
         return(new XmlName(prefix, localName, ns, hashCode, ownerDoc, next));
     }
     else
     {
         return(new XmlNameEx(prefix, localName, ns, hashCode, ownerDoc, next, schemaInfo));
     }
 }
Beispiel #31
0
 public static XmlName Create(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next)
 {
     return new XmlName(prefix, localName, ns, hashCode, ownerDoc, next);
 }
		public void AddVariable(XmlName name, IXsltContextVariable variable)
		{
			EnsureVariables()[name] = variable;
		}
 private ElementTypeRef FindInCollection(ICollection col, XmlName name)
 {
     foreach ( ElementTypeRef sr in col )
     {
         if ( sr.Name.Equals(name) )
             return sr;
     }
     return null;
 }
		public void AddVariable(string prefix, string name, IXsltContextVariable variable)
		{
			var key = new XmlName(name, prefix ?? string.Empty);
			AddVariable(key, variable);
		}
		public void AddFunction(string prefix, string name, IXsltContextFunction function)
		{
			var key = new XmlName(name, prefix ?? string.Empty);
			AddFunction(key, function);
		}
Beispiel #36
0
 //This should be used only to create the emptyElem as above.
 private XmlElement() : base()
 {
     this.name      = null;
     this.lastChild = null;
 }