Exemplo n.º 1
0
 public AttributeBinding(XmlElement element, XmlName name, string val, bool specified)
 {
     this.element=element;
     this.name=name;
     this.val=val;
     this.specified=specified;
 }
Exemplo n.º 2
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);
     }
 }
Exemplo n.º 3
0
 internal bool BindIDAttributeWithElementType(XmlName eleName, XmlName attrName)
 {
     if ( htElementIDAttrDecl[eleName] == null ) {
         htElementIDAttrDecl.Add(eleName, attrName);
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 8
0
        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; 
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 10
0
        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;
 }
Exemplo n.º 12
0
		private IXsltContextVariable ResolveVariableCore(string prefix, string name)
		{
			IXsltContextVariable variable;
			var key = new XmlName(name, prefix ?? string.Empty);
			variables.TryGetValue(key, out variable);
			return variable;
		}
Exemplo n.º 13
0
		public void AddFunction(XmlName name, IXsltContextFunction function)
		{
			EnsureFunctions()[name] = function;
		}
Exemplo n.º 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;
 }
Exemplo n.º 15
0
 public ElementListItem(XmlName name)
     : this(name, false, false)
 {
 }
Exemplo n.º 16
0
 public ElementListItem(XmlName name, bool required, bool choice)
 {
     this.Name=name;
     this.IsRequired=required;
     this.IsChoice=choice;
 }
Exemplo n.º 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;
		}
Exemplo n.º 18
0
 internal XmlName GetIDAttributeByElement(XmlName eleName)
 {
     return (XmlName)(htElementIDAttrDecl[eleName]);
 }
Exemplo n.º 19
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);
 }
Exemplo n.º 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));
 }
Exemplo n.º 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;
 }
Exemplo n.º 22
0
		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;
		}
Exemplo n.º 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;
		}
Exemplo n.º 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;
 }
Exemplo n.º 25
0
 protected virtual void PerformAction(XmlName name)
 {
 }
Exemplo n.º 26
0
 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;
 }
Exemplo n.º 27
0
 public ElementListItem(XmlName name, bool required)
     : this(name, required, false)
 {
 }
Exemplo n.º 28
0
        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[];
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 32
0
		public void AddVariable(XmlName name, IXsltContextVariable variable)
		{
			EnsureVariables()[name] = variable;
		}
Exemplo n.º 33
0
 private ElementTypeRef FindInCollection(ICollection col, XmlName name)
 {
     foreach ( ElementTypeRef sr in col )
     {
         if ( sr.Name.Equals(name) )
             return sr;
     }
     return null;
 }
Exemplo n.º 34
0
		public void AddVariable(string prefix, string name, IXsltContextVariable variable)
		{
			var key = new XmlName(name, prefix ?? string.Empty);
			AddVariable(key, variable);
		}
Exemplo n.º 35
0
		public void AddFunction(string prefix, string name, IXsltContextFunction function)
		{
			var key = new XmlName(name, prefix ?? string.Empty);
			AddFunction(key, function);
		}
Exemplo n.º 36
0
 //This should be used only to create the emptyElem as above.
 private XmlElement() : base()
 {
     this.name      = null;
     this.lastChild = null;
 }