Add() public abstract method

public abstract Add ( String array ) : String
array String
return String
Ejemplo n.º 1
0
 public QNameValue(string prefix, string localName, string ns, XmlNameTable nameTable)
 {
     if (prefix == null)
         throw new NullReferenceException("prefix");
     if (localName == null)
         throw new NullReferenceException("localName");                
     if (ns == null)
         throw new NullReferenceException("ns");
     if (nameTable == null)
         throw new NullReferenceException("nameTable");
     if (prefix != "" && ns == "")
         throw new XQueryException(Properties.Resources.FOCA0002,
             String.Format("{0}:{1}", prefix, localName));
     try
     {
         localName = XmlConvert.VerifyNCName(localName);
     }
     catch(XmlException)
     {
         throw new XQueryException(Properties.Resources.FORG0001, localName, "xs:QName");
     }
     Prefix = nameTable.Add(prefix);
     LocalName = nameTable.Add(localName);
     NamespaceUri = nameTable.Add(ns);
 }
	// Constructor.
	public XmlNamespaceManager(XmlNameTable nameTable)
			{
				// Validate the parameters.
				if(nameTable == null)
				{
					throw new ArgumentNullException("nameTable");
				}

				// Record the name table for later.
				this.nameTable = nameTable;

				// Add special namespaces for "xml" and "xmlns".
				xmlCompareQuick = nameTable.Add("xml");
				xmlNsCompareQuick = nameTable.Add("xmlns");
				namespaces = new NamespaceInfo
					(xmlCompareQuick,
					 nameTable.Add(XmlDocument.xmlnsXml),
					 null);
				namespaces = new NamespaceInfo
					(xmlNsCompareQuick,
					 nameTable.Add(XmlDocument.xmlns),
					 namespaces);

				// Mark the position of the outermost scope level.
				namespaces = new NamespaceInfo(null, String.Empty, namespaces);
			}
 private bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHashtable columns)
 {
     string array = XmlConvert.EncodeLocalName(col.ColumnName);
     string localName = nameTable.Get(array);
     if (localName == null)
     {
         localName = nameTable.Add(array);
     }
     col.encodedColumnName = localName;
     string namespaceURI = nameTable.Get(col.Namespace);
     if (namespaceURI == null)
     {
         namespaceURI = nameTable.Add(col.Namespace);
     }
     else if (col._columnUri != null)
     {
         col._columnUri = namespaceURI;
     }
     XmlNodeIdentety identety = new XmlNodeIdentety(localName, namespaceURI);
     columns[identety] = col;
     if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase))
     {
         this.HandleSpecialColumn(col, nameTable, columns);
     }
     return true;
 }
Ejemplo n.º 4
0
 public XIncludeKeywords(XmlNameTable nt) 
 {
     nameTable = nt; 
     //Preload some keywords
     _XIncludeNamespace = nameTable.Add(s_XIncludeNamespace);
     _OldXIncludeNamespace = nameTable.Add(s_OldXIncludeNamespace);
     _Include = nameTable.Add(s_Include);
     _Href = nameTable.Add(s_Href);
     _Parse = nameTable.Add(s_Parse);                        
 }
Ejemplo n.º 5
0
        public XmlNamespaceManager(XmlNameTable nameTable)
        {
            this.nameTable = nameTable;

            nameTable.Add(PrefixXmlns);
            nameTable.Add(PrefixXml);
            nameTable.Add(String.Empty);
            nameTable.Add(XmlnsXmlns);
            nameTable.Add(XmlnsXml);

            InitData();
        }
Ejemplo n.º 6
0
        /// <include file='doc\XmlNamespaceManager.uex' path='docs/doc[@for="XmlNamespaceManager.XmlNamespaceManager"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlNamespaceManager(XmlNameTable nameTable) {
            this.nameTable = nameTable;
            namespaceXml = nameTable.Add(XmlReservedNs.NsXml);
            namespaceXmlNs = nameTable.Add(XmlReservedNs.NsXmlNs);       
            xml = nameTable.Add("xml");
            xmlNs = nameTable.Add("xmlns");       

            decls = new HWStack(60);
            scopes = new HWStack(60);
            defaultNs = null;
            count = 0;
        }
Ejemplo n.º 7
0
 internal string GetAtomizedValue(XmlNameTable nameTable)
 {
     if (this.value == null)
     {
         Debug.Assert(valueStartPos != -1);
         Debug.Assert(chars != null);
         return(nameTable.Add(chars, valueStartPos, valueLength));
     }
     else
     {
         return(nameTable.Add(this.value));
     }
 }
        /// <include file='doc\XmlNamespaceManager.uex' path='docs/doc[@for="XmlNamespaceManager.XmlNamespaceManager"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlNamespaceManager(XmlNameTable nameTable)
        {
            this.nameTable = nameTable;
            namespaceXml   = nameTable.Add(XmlReservedNs.NsXml);
            namespaceXmlNs = nameTable.Add(XmlReservedNs.NsXmlNs);
            xml            = nameTable.Add("xml");
            xmlNs          = nameTable.Add("xmlns");

            decls     = new HWStack(60);
            scopes    = new HWStack(60);
            defaultNs = null;
            count     = 0;
        }
        public XmlNamespaceManager( XmlNameTable nameTable ) {
            this.nameTable = nameTable;
            xml = nameTable.Add("xml");
            xmlNs = nameTable.Add("xmlns");

            nsdecls = new NamespaceDeclaration[8];
            string emptyStr = nameTable.Add( string.Empty );
            nsdecls[0].Set( emptyStr, emptyStr, -1, -1 );
            nsdecls[1].Set( xmlNs, nameTable.Add( XmlReservedNs.NsXmlNs ), -1, -1 );
            nsdecls[2].Set( xml, nameTable.Add( XmlReservedNs.NsXml ), 0, -1 );
            lastDecl = 2;
            scopeId = 1;
        }
 public XmlNamespaceManager(XmlNameTable nameTable)
 {
     this.nameTable = nameTable;
     this.xml = nameTable.Add("xml");
     this.xmlNs = nameTable.Add("xmlns");
     this.nsdecls = new NamespaceDeclaration[8];
     string prefix = nameTable.Add(string.Empty);
     this.nsdecls[0].Set(prefix, prefix, -1, -1);
     this.nsdecls[1].Set(this.xmlNs, nameTable.Add("http://www.w3.org/2000/xmlns/"), -1, -1);
     this.nsdecls[2].Set(this.xml, nameTable.Add("http://www.w3.org/XML/1998/namespace"), 0, -1);
     this.lastDecl = 2;
     this.scopeId = 1;
 }
Ejemplo n.º 11
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Xml.XmlNamespaceManager" /> class with the specified <see cref="T:System.Xml.XmlNameTable" />.</summary>
 /// <param name="nameTable">The <see cref="T:System.Xml.XmlNameTable" /> to use. </param>
 /// <exception cref="T:System.NullReferenceException">null is passed to the constructor </exception>
 public XmlNamespaceManager(XmlNameTable nameTable)
 {
     if (nameTable == null)
     {
         throw new ArgumentNullException("nameTable");
     }
     this.nameTable = nameTable;
     nameTable.Add("xmlns");
     nameTable.Add("xml");
     nameTable.Add(string.Empty);
     nameTable.Add("http://www.w3.org/2000/xmlns/");
     nameTable.Add("http://www.w3.org/XML/1998/namespace");
     this.InitData();
 }
Ejemplo n.º 12
0
        public XmlNamespaceManager(XmlNameTable nameTable)
        {
            this.nameTable = nameTable;
            this.xml       = nameTable.Add("xml");
            this.xmlNs     = nameTable.Add("xmlns");
            this.nsdecls   = new NamespaceDeclaration[8];
            string prefix = nameTable.Add(string.Empty);

            this.nsdecls[0].Set(prefix, prefix, -1, -1);
            this.nsdecls[1].Set(this.xmlNs, nameTable.Add("http://www.w3.org/2000/xmlns/"), -1, -1);
            this.nsdecls[2].Set(this.xml, nameTable.Add("http://www.w3.org/XML/1998/namespace"), 0, -1);
            this.lastDecl = 2;
            this.scopeId  = 1;
        }
Ejemplo n.º 13
0
        public string GetString(XmlNameTable nameTable)
        {
            switch (this.type)
            {
            case StringHandleType.UTF8:
                return(this.bufferReader.GetString(this.offset, this.length, nameTable));

            case StringHandleType.Dictionary:
                return(nameTable.Add(this.bufferReader.GetDictionaryString(this.key).Value));

            case StringHandleType.ConstString:
                return(nameTable.Add(constStrings[this.key]));
            }
            return(this.bufferReader.GetEscapedString(this.offset, this.length, nameTable));
        }
Ejemplo n.º 14
0
        public XmlNamespaceManager(XmlNameTable nameTable)
        {
            _nameTable = nameTable;
            _xml       = nameTable.Add("xml");
            _xmlNs     = nameTable.Add("xmlns");

            _nsdecls = new NamespaceDeclaration[8];
            string emptyStr = nameTable.Add(string.Empty);

            _nsdecls[0].Set(emptyStr, emptyStr, -1, -1);
            _nsdecls[1].Set(_xmlNs, nameTable.Add(XmlReservedNs.NsXmlNs), -1, -1);
            _nsdecls[2].Set(_xml, nameTable.Add(XmlReservedNs.NsXml), 0, -1);
            _lastDecl = 2;
            _scopeId  = 1;
        }
Ejemplo n.º 15
0
        internal virtual void AddNamespace(string prefix, string uri, bool atomizedNames)
        {
            if (prefix == null)
            {
                throw new ArgumentNullException("prefix", "Value cannot be null.");
            }

            if (uri == null)
            {
                throw new ArgumentNullException("uri", "Value cannot be null.");
            }
            if (!atomizedNames)
            {
                prefix = nameTable.Add(prefix);
                uri    = nameTable.Add(uri);
            }

            if (prefix == PrefixXml && uri == XmlnsXml)
            {
                return;
            }

            IsValidDeclaration(prefix, uri, true);

            if (prefix.Length == 0)
            {
                defaultNamespace = uri;
            }

            for (int i = declPos; i > declPos - count; i--)
            {
                if (object.ReferenceEquals(decls [i].Prefix, prefix))
                {
                    decls [i].Uri = uri;
                    return;
                }
            }

            declPos++;
            count++;

            if (declPos == decls.Length)
            {
                GrowDecls();
            }
            decls [declPos].Prefix = prefix;
            decls [declPos].Uri    = uri;
        }
Ejemplo n.º 16
0
        public XmlNamespaceManager(XmlNameTable nameTable)
        {
            if (nameTable == null)
            {
                throw new ArgumentNullException("nameTable");
            }
            this.nameTable = nameTable;

            nameTable.Add(PrefixXmlns);
            nameTable.Add(PrefixXml);
            nameTable.Add(String.Empty);
            nameTable.Add(XmlnsXmlns);
            nameTable.Add(XmlnsXml);

            InitData();
        }
Ejemplo n.º 17
0
        public string GetString(int offset, int length, XmlNameTable nameTable)
        {
            char[] chars     = GetCharBuffer(length);
            int    charCount = GetChars(offset, length, chars);

            return(nameTable.Add(chars, 0, charCount));
        }
Ejemplo n.º 18
0
        public string GetString(XmlNameTable nameTable)
        {
            StringHandleType type = _type;

            if (type == StringHandleType.UTF8)
            {
                return(_bufferReader.GetString(_offset, _length, nameTable));
            }
            if (type == StringHandleType.Dictionary)
            {
                return(nameTable.Add(_bufferReader.GetDictionaryString(_key).Value));
            }
            DiagnosticUtility.DebugAssert(type == StringHandleType.ConstString, "Should be ConstString");
            //If not Utf8 then the StringHandleType is ConstString
            return(nameTable.Add(s_constStrings[_key]));
        }
        public string GetString(int offset, int length, XmlNameTable nameTable)
        {
            char[] charBuffer = this.GetCharBuffer(length);
            int    num        = this.GetChars(offset, length, charBuffer);

            return(nameTable.Add(charBuffer, 0, num));
        }
 public BaseProcessor(XmlNameTable nameTable, System.Xml.Schema.SchemaNames schemaNames, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings)
 {
     this.nameTable = nameTable;
     this.schemaNames = schemaNames;
     this.eventHandler = eventHandler;
     this.compilationSettings = compilationSettings;
     this.NsXml = nameTable.Add("http://www.w3.org/XML/1998/namespace");
 }
Ejemplo n.º 21
0
        internal override void SetSpecialAttribute(String name, String value)
        {
            XmlNameTable nt = FindOwnerQuick().NameTable;

            if (name == "PUBLIC")
            {
                publicId = ((value != null) ? nt.Add(value) : String.Empty);
            }
            else if (name == "SYSTEM")
            {
                systemId = ((value != null) ? nt.Add(value) : String.Empty);
            }
            else
            {
                throw new ArgumentException
                          (S._("Xml_InvalidSpecialAttribute"), "name");
            }
        }
Ejemplo n.º 22
0
	// Constructor.
	public NodeManager(XmlNameTable nt, ErrorHandler eh)
			{
				current = (int)Type.None;
				attributes = null;
				error = eh;
				nodes = new NodeInfo[11];
				nodes[current] = new DefaultNodeInfo();
				xml = nt.Add("xml");
			}
Ejemplo n.º 23
0
        public XmlName AddName(string?prefix, string localName, string?ns, IXmlSchemaInfo?schemaInfo)
        {
            if (prefix == null)
            {
                prefix = string.Empty;
            }
            if (ns == null)
            {
                ns = string.Empty;
            }

            int hashCode = XmlName.GetHashCode(localName);

            for (XmlName e = _entries[hashCode & _mask]; e != null; e = e.next)
            {
                if (e.HashCode == hashCode &&
                    ((object)e.LocalName == (object)localName ||
                     e.LocalName.Equals(localName)) &&
                    ((object)e.Prefix == (object)prefix ||
                     e.Prefix.Equals(prefix)) &&
                    ((object)e.NamespaceURI == (object)ns ||
                     e.NamespaceURI.Equals(ns)) &&
                    e.Equals(schemaInfo))
                {
                    return(e);
                }
            }

            prefix    = _nameTable.Add(prefix);
            localName = _nameTable.Add(localName);
            ns        = _nameTable.Add(ns);
            int     index = hashCode & _mask;
            XmlName name  = XmlName.Create(prefix, localName, ns, hashCode, _ownerDocument, _entries[index], schemaInfo);

            _entries[index] = name;

            if (_count++ == _mask)
            {
                Grow();
            }

            return(name);
        }
        public string GetString(XmlNameTable nameTable)
        {
            StringHandleType type = this.type;

            if (type == StringHandleType.UTF8)
            {
                return(bufferReader.GetString(offset, length, nameTable));
            }
            if (type == StringHandleType.Dictionary)
            {
                return(nameTable.Add(bufferReader.GetDictionaryString(key).Value));
            }
            if (type == StringHandleType.ConstString)
            {
                return(nameTable.Add(constStrings[key]));
            }
            Fx.Assert(type == StringHandleType.EscapedUTF8, "");
            return(bufferReader.GetEscapedString(offset, length, nameTable));
        }
        /// <include file='doc\XmlNamespaceManager.uex' path='docs/doc[@for="XmlNamespaceManager.AddNamespace"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public virtual void AddNamespace(string prefix, string uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }
            if (prefix == null)
            {
                throw new ArgumentNullException("prefix");
            }
            prefix = nameTable.Add(prefix);
            uri    = nameTable.Add(uri);

            if (Ref.Equal(xml, prefix) || Ref.Equal(xmlNs, prefix))
            {
                throw new ArgumentException(Res.GetString(Res.Xml_InvalidPrefix));
            }

            for (int declIndex = decls.Length - 1; declIndex >= decls.Length - count; declIndex--)
            {
                NsDecl decl = (NsDecl)decls[declIndex];
                if (Ref.Equal(decl.Prefix, prefix))
                {
                    decl.Uri = uri;
                    return; // redefine
                }
            } /* else */
            {
                NsDecl decl = (NsDecl)decls.Push();
                if (decl == null)
                {
                    decl = new NsDecl();
                    decls.AddToTop(decl);
                }
                decl.Prefix = prefix;
                decl.Uri    = uri;
                count++;
                if (prefix == string.Empty)
                {
                    defaultNs = decl;
                }
            }
        }
Ejemplo n.º 26
0
        public XmlName AddName(string prefix, string localName, string ns)
        {
            if (prefix == null)
            {
                prefix = string.Empty;
            }
            if (ns == null)
            {
                ns = string.Empty;
            }

            int hashCode = XmlNameHelper.GetHashCode(localName);

            for (XmlName e = entries[hashCode & mask]; e != null; e = e.next)
            {
                if (e.HashCode == hashCode &&
                    ((object)e.LocalName == (object)localName ||
                     e.LocalName.Equals(localName)) &&
                    ((object)e.Prefix == (object)prefix ||
                     e.Prefix.Equals(prefix)) &&
                    ((object)e.NamespaceURI == (object)ns ||
                     e.NamespaceURI.Equals(ns)))
                {
                    return(e);
                }
            }

            prefix    = nameTable.Add(prefix);
            localName = nameTable.Add(localName);
            ns        = nameTable.Add(ns);
            int     index = hashCode & mask;
            XmlName name  = XmlName.Create(prefix, localName, ns, hashCode, ownerDocument, entries[index]);

            entries[index] = name;

            if (count++ == mask)
            {
                Grow();
            }

            return(name);
        }
Ejemplo n.º 27
0
 public string GetAtomizedNameWPrefix(XmlNameTable nameTable) {
     if (nameWPrefix == null) {
         if (prefix.Length == 0 ) {
             nameWPrefix = localName;
         }
         else {
             nameWPrefix = nameTable.Add ( string.Concat (prefix,":", localName));
         }
     }
     return nameWPrefix;
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AndroidStudioStrings"/> class.
        /// </summary>
        /// <param name="nameTable">The name table from which strings are generated.</param>
        public AndroidStudioStrings(XmlNameTable nameTable)
        {
            this.Problems = nameTable.Add("problems");
            this.Problem = nameTable.Add("problem");
            this.File = nameTable.Add("file");
            this.Line = nameTable.Add("line");
            this.Module = nameTable.Add("module");
            this.Package = nameTable.Add("package");
            this.EntryPoint = nameTable.Add("entry_point");
            this.ProblemClass = nameTable.Add("problem_class");
            this.Hints = nameTable.Add("hints");
            this.Hint = nameTable.Add("hint");
            this.Description = nameTable.Add("description");

            this.Type = nameTable.Add("TYPE");
            this.FQName = nameTable.Add("FQNAME");
            this.Severity = nameTable.Add("severity");
            this.AttributeKey = nameTable.Add("attribute_key");
            this.Value = nameTable.Add("value");
        }
Ejemplo n.º 29
0
        public DocumentSchemaValidator(XmlDocument ownerDocument, XmlSchemaSet schemas, ValidationEventHandler eventHandler) {
            this.schemas = schemas;
            this.eventHandler = eventHandler;
            document = ownerDocument;
            this.internalEventHandler = new ValidationEventHandler(InternalValidationCallBack);
            
            this.nameTable = document.NameTable;
            nsManager = new XmlNamespaceManager(nameTable);
            
            Debug.Assert(schemas != null && schemas.Count > 0);

            nodeValueGetter = new XmlValueGetter(GetNodeValue);
            psviAugmentation = true;

            //Add common strings to be compared to NameTable
            NsXmlNs = nameTable.Add(XmlReservedNs.NsXmlNs);
            NsXsi = nameTable.Add(XmlReservedNs.NsXsi);
            XsiType = nameTable.Add("type");
            XsiNil = nameTable.Add("nil");
        }
Ejemplo n.º 30
0
        public string GetString(XmlNameTable nameTable)
        {
            StringHandleType type = _type;

            if (type == StringHandleType.UTF8)
            {
                return(_bufferReader.GetString(_offset, _length, nameTable));
            }
            if (type == StringHandleType.Dictionary)
            {
                return(nameTable.Add(_bufferReader.GetDictionaryString(_key).Value));
            }
            if (type == StringHandleType.ConstString)
            {
                return(nameTable.Add(s_constStrings[_key]));
            }
            // If none of the above, must be StringHandleType.EscapedUTF8
            DiagnosticUtility.DebugAssert(type == StringHandleType.EscapedUTF8, "Should be EscapedUTF8");
            return(_bufferReader.GetEscapedString(_offset, _length, nameTable));
        }
Ejemplo n.º 31
0
 internal void ConcurrencyCheck(XmlNodeChangedEventArgs args)
 {
     if (atomized == false)
     {
         XmlNameTable nameTable = this.rootNode.Document.NameTable;
         this.localName    = nameTable.Add(this.localName);
         this.namespaceURI = nameTable.Add(this.namespaceURI);
         this.atomized     = true;
     }
     if (IsMatch(args.Node))
     {
         this.changeCount++;
         this.curInd  = -1;
         this.curElem = rootNode;
         if (args.Action == XmlNodeChangedAction.Insert)
         {
             this.empty = false;
         }
     }
     this.matchCount = -1;
 }
Ejemplo n.º 32
0
        public static string NormalizeString(XmlNameTable nameTable, string s)
        {
            if (s == null)
                return s;

            string result = nameTable.Get(s);
            if (result == null)
                result = nameTable.Add(s);

            return result;

        }
Ejemplo n.º 33
0
        public DocumentSchemaValidator(XmlDocument ownerDocument, XmlSchemaSet schemas, ValidationEventHandler eventHandler)
        {
            _schemas              = schemas;
            _eventHandler         = eventHandler;
            _document             = ownerDocument;
            _internalEventHandler = new ValidationEventHandler(InternalValidationCallBack);

            _nameTable = _document.NameTable;
            _nsManager = new XmlNamespaceManager(_nameTable);

            Debug.Assert(schemas != null && schemas.Count > 0);

            _nodeValueGetter  = new XmlValueGetter(GetNodeValue);
            _psviAugmentation = true;

            //Add common strings to be compared to NameTable
            _nsXmlNs = _nameTable.Add(XmlReservedNs.NsXmlNs);
            _nsXsi   = _nameTable.Add(XmlReservedNs.NsXsi);
            _xsiType = _nameTable.Add("type");
            _xsiNil  = _nameTable.Add("nil");
        }
Ejemplo n.º 34
0
 internal void ConcurrencyCheck(XmlNodeChangedEventArgs args)
 {
     if (_atomized == false)
     {
         XmlNameTable nameTable = _rootNode.Document.NameTable;
         _localName    = nameTable.Add(_localName);
         _namespaceURI = nameTable.Add(_namespaceURI);
         _atomized     = true;
     }
     if (IsMatch(args.Node))
     {
         _changeCount++;
         _curInd  = -1;
         _curElem = _rootNode;
         if (args.Action == XmlNodeChangedAction.Insert)
         {
             _empty = false;
         }
     }
     _matchCount = -1;
 }
Ejemplo n.º 35
0
        /// <summary>
        /// Reads until an element with the specified qualified name is found.
        /// </summary>
        /// <param name="name">The qualified name of the element.</param>
        /// <returns>true if a matching element is found; otherwise false and the
        /// XmlReader is in an end of file state.</returns>
        public virtual bool ReadToFollowing(string name)
        {
            if (name == null || name.Length == 0)
            {
                throw new ArgumentException();
            }

            // atomize name
            name = _nameTable.Add(name);

            // Move back to element, so we don't have to deal with _nodeType != NodeType
            if (_currentAttribute >= 0)
            {
                _currentAttribute = -1;
            }

            // find following element with that name
            while (Read())
            {
                if (_nodeType == XmlNodeType.Element &&
                    Object.ReferenceEquals(((XmlReader_XmlNode)_xmlNodes.Peek()).Name, name))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 36
0
 internal string CreateNameWPrefix(XmlNameTable nt)
 {
     Debug.Assert(nameWPrefix == null);
     if (prefix.Length == 0)
     {
         nameWPrefix = localName;
     }
     else
     {
         nameWPrefix = nt.Add($"{prefix}:{localName}");
     }
     return(nameWPrefix);
 }
        public string GetAtomizedPrefixedName(string prefix, string local)
        {
            if (prefix == null || prefix.Length == 0)
            {
                return(local);
            }

            if (cacheBuffer == null)
            {
                cacheBuffer = new char [20];
            }
            if (cacheBuffer.Length < prefix.Length + local.Length + 1)
            {
                cacheBuffer = new char [Math.Max(
                                            prefix.Length + local.Length + 1,
                                            cacheBuffer.Length << 1)];
            }
            prefix.CopyTo(0, cacheBuffer, 0, prefix.Length);
            cacheBuffer [prefix.Length] = ':';
            local.CopyTo(0, cacheBuffer, prefix.Length + 1, local.Length);
            return(nameTable.Add(cacheBuffer, 0, prefix.Length + local.Length + 1));
        }
 internal string CreateNameWPrefix(XmlNameTable nt)
 {
     Debug.Assert(nameWPrefix == null);
     if (prefix.Length == 0)
     {
         nameWPrefix = localName;
     }
     else
     {
         nameWPrefix = nt.Add(string.Concat(prefix, ":", localName));
     }
     return(nameWPrefix);
 }
Ejemplo n.º 39
0
        private string GetDefaultPrefix(string attributeNS)
        {
            IDictionary <string, string> namespaceDecls = NamespaceResolver.GetNamespacesInScope(XmlNamespaceScope.All);
            string defaultPrefix = null;
            string defaultNS;

            attributeNS = _nameTable.Add(attributeNS); //atomize ns

            foreach (KeyValuePair <string, string> pair in namespaceDecls)
            {
                defaultNS = _nameTable.Add(pair.Value);
                if (object.ReferenceEquals(defaultNS, attributeNS))
                {
                    defaultPrefix = pair.Key;
                    if (defaultPrefix.Length != 0)
                    { //Locate first non-empty prefix
                        return(defaultPrefix);
                    }
                }
            }
            return(defaultPrefix);
        }
 public string GetAtomizedNameWPrefix(XmlNameTable nameTable)
 {
     if (_nameWPrefix == null)
     {
         if (_prefix.Length == 0)
         {
             _nameWPrefix = _localName;
         }
         else
         {
             _nameWPrefix = nameTable.Add(string.Concat(_prefix, ":", _localName));
         }
     }
     return(_nameWPrefix);
 }
 public string GetAtomizedNameWPrefix(XmlNameTable nameTable)
 {
     if (this.nameWPrefix == null)
     {
         if (this.prefix.Length == 0)
         {
             this.nameWPrefix = this.localName;
         }
         else
         {
             this.nameWPrefix = nameTable.Add(this.prefix + ":" + this.localName);
         }
     }
     return this.nameWPrefix;
 }
 internal XmlElementList(XmlNode parent, string localName, string namespaceURI) : this(parent)
 {
     XmlNameTable nameTable = parent.Document.NameTable;
     this.asterisk     = nameTable.Add("*");
     this.localName    = nameTable.Get(localName);
     this.namespaceURI = nameTable.Get(namespaceURI);
     if ((this.localName == null) || (this.namespaceURI == null))
     {
         this.empty        = true;
         this.atomized     = false;
         this.localName    = localName;
         this.namespaceURI = namespaceURI;
     }
     this.name = null;
 }
Ejemplo n.º 43
0
 public string GetAtomizedNameWPrefix(XmlNameTable nameTable)
 {
     if (this.nameWPrefix == null)
     {
         if (this.prefix.Length == 0)
         {
             this.nameWPrefix = this.localName;
         }
         else
         {
             this.nameWPrefix = nameTable.Add(this.prefix + ":" + this.localName);
         }
     }
     return(this.nameWPrefix);
 }
Ejemplo n.º 44
0
        /// <summary>
        /// Reads until an element with the specified local name and namespace URI
        /// is found.
        /// </summary>
        /// <param name="localname">The local name of the element.</param>
        /// <param name="namespaceURI">The namespace URI of the element.</param>
        /// <returns>true if a matching element is found; otherwise false and the
        /// XmlReader is in an end of file state.</returns>
        public virtual bool ReadToFollowing(string localName, string namespaceURI)
        {
            if (localName == null || localName.Length == 0 || namespaceURI == null)
            {
                throw new ArgumentException();
            }

            // atomize local name and namespace
            localName    = NameTable.Add(localName);
            namespaceURI = NameTable.Add(namespaceURI);

            // Move back to element, so we don't have to deal with _nodeType != NodeType
            if (_currentAttribute >= 0)
            {
                _currentAttribute = -1;
            }

            XmlReader_XmlNode node;

            // find following element with that name
            while (Read())
            {
                if (_nodeType == XmlNodeType.Element)
                {
                    node = (XmlReader_XmlNode)_xmlNodes.Peek();

                    if (Object.ReferenceEquals(node.LocalName, localName) &&
                        Object.ReferenceEquals(node.NamespaceURI, namespaceURI))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
 internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
 {
     typedValue = null;
     Exception exception = DatatypeImplementation.stringFacetsChecker.CheckLexicalFacets(ref s, this);
     if (exception == null)
     {
         exception = DatatypeImplementation.stringFacetsChecker.CheckValueFacets(s, this);
         if (exception == null)
         {
             nameTable.Add(s);
             typedValue = s;
             return null;
         }
     }
     return exception;
 }
Ejemplo n.º 46
0
        public MFTestResults AddGetTest1()
        {
            try
            {
                XmlNameTable nt = new XmlNameTable();
                String[] strings = new String[100];
                String[] atomizedStrings = new String[100];
                String str;
                String atomized;


                for(int i =0 ; i <100; i++)
                {
                    str = ToNumString(i);
                    strings[i] = str;

                    atomizedStrings[i] = nt.Add(str);

                    Assert.AreEqual(str, atomizedStrings[i]);
                }

                for (int i = 99; i >=0; i--)
                {
                    str = ToNumString(i);
                    atomized = nt.Get(str);
                    if (Object.ReferenceEquals(str, atomized))
                    {
                        Log.Comment("The new string and atomized string are of the same reference");
                    }

                    Assert.AreEqual(str, atomized);
                    Assert.IsTrue(Object.ReferenceEquals(atomizedStrings[i], atomized), "String not atomized");
                }

            }
            catch (Exception e)
            {
                Log.Exception("Unexpected exception", e);
                return MFTestResults.Fail;
            }

            return MFTestResults.Pass;
        }
Ejemplo n.º 47
0
        public MFTestResults AddGetTest2()
        {
            try
            {
                XmlNameTable nt = new XmlNameTable();

                String atomized = nt.Add("http://www.microsoft.com/netmf");

                Assert.AreEqual(null, nt.Get("http://www.microsoft.com/netmf/v4"));
                Assert.AreEqual(null, nt.Get("http://www.microsoft.com/"));
                Assert.AreEqual(null, nt.Get("http://www.microsoft.com/netMF"));
            }
            catch (Exception e)
            {
                Log.Exception("Unexpected exception", e);
                return MFTestResults.Fail;
            }

            return MFTestResults.Pass;
        }
Ejemplo n.º 48
0
        internal OutKeywords(XmlNameTable nameTable) {
            Debug.Assert(nameTable != null);
#if DEBUG
            _NameTable = nameTable;
#endif

            _AtomEmpty               = nameTable.Add(string.Empty);
            _AtomLang                = nameTable.Add(Keywords.s_Lang);
            _AtomSpace               = nameTable.Add(Keywords.s_Space);
            _AtomXmlns               = nameTable.Add(Keywords.s_Xmlns);
            _AtomXml                 = nameTable.Add(Keywords.s_Xml);
            _AtomXmlNamespace        = nameTable.Add(Keywords.s_XmlNamespace);
            _AtomXmlnsNamespace      = nameTable.Add(Keywords.s_XmlnsNamespace);

            CheckKeyword(_AtomEmpty);
            CheckKeyword(_AtomLang);
            CheckKeyword(_AtomSpace);
            CheckKeyword(_AtomXmlns);
            CheckKeyword(_AtomXml);
            CheckKeyword(_AtomXmlNamespace);
            CheckKeyword(_AtomXmlnsNamespace);
        }
Ejemplo n.º 49
0
        internal OutKeywords(XmlNameTable nameTable) {
            Debug.Assert(nameTable != null);
#if DEBUG
            _NameTable = nameTable;
#endif

            _AtomEmpty               = nameTable.Add(string.Empty);
            _AtomLang                = nameTable.Add("lang");
            _AtomSpace               = nameTable.Add("space");
            _AtomXmlns               = nameTable.Add("xmlns");
            _AtomXml                 = nameTable.Add("xml");
            _AtomXmlNamespace        = nameTable.Add(XmlReservedNs.NsXml);
            _AtomXmlnsNamespace      = nameTable.Add(XmlReservedNs.NsXmlNs);

            CheckKeyword(_AtomEmpty);
            CheckKeyword(_AtomLang);
            CheckKeyword(_AtomSpace);
            CheckKeyword(_AtomXmlns);
            CheckKeyword(_AtomXml);
            CheckKeyword(_AtomXmlNamespace);
            CheckKeyword(_AtomXmlnsNamespace);
        }
Ejemplo n.º 50
0
	// Update the search and namespace information.
	public void UpdateInfo(XmlNameTable nt, XmlNamespaceManager nm)
			{
				this.nt = nt;
				this.nm = nm;
				names.Clear();

				for(int i = 0; i < count; ++i)
				{
					// get the attribute name information
					AttributeInfo info = (AttributeInfo)attributes[i];
					String name = info.Name;

					// set the defaults
					String localName = name;
					String prefix = String.Empty;
					String namespaceURI = String.Empty;

					// find the namespace separator
					int index = name.LastIndexOf(':');

					// give an error if there's no name before the separator
					if(index == 0)
					{
						Error(/* TODO */);
					}

					// set the namespace information
					if(index > 0)
					{
						// add the prefix and local name to the name table
						prefix = nt.Add(name.Substring(0, index));
						localName = nt.Add(name.Substring(index + 1));

						// check for a valid prefix
						if(prefix.IndexOf(':') != -1)
						{
							Error(/* TODO */);
						}

						// set the namespace uri based on the prefix
						namespaceURI = nm.LookupNamespace(prefix);
					}
					else if(localName == "xmlns")
					{
						namespaceURI = nt.Add(XmlDocument.xmlns);
					}

					// create the key
					Key key = new Key(localName, namespaceURI);

					// check for duplicate
					if(names.ContainsKey(key))
					{
						Error(/* TODO */);
					}

					// add the key and index to the hash table
					names.Add(key, i);

					// update the current attribute's namespace information
					info.UpdateNamespaceInfo(localName, namespaceURI, prefix);
				}
			}
Ejemplo n.º 51
0
 internal void Atomize(XmlNameTable nameTable)
 {
     Debug.Assert(_name != null);
     _name = nameTable.Add(_name);
     _ns = nameTable.Add(_ns);
 }
        internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) {
            Exception exception;

            typedValue = null;

            exception = stringFacetsChecker.CheckLexicalFacets(ref s, this);
            if (exception != null) goto Error;

            exception = stringFacetsChecker.CheckValueFacets(s, this);
            if (exception != null) goto Error;

            nameTable.Add(s);

            typedValue = s;
            return null;

        Error:
            return exception;
        }
Ejemplo n.º 53
0
 public MyXmlNamespaceResolver(System.Xml.XmlNameTable nameTable)
 {
     this.nameTable = nameTable;
     this.emptyAtom = nameTable.Add(string.Empty);
 }
Ejemplo n.º 54
0
        public MFTestResults AddEmptyStringTest()
        {
            try
            {
                XmlNameTable nt = new XmlNameTable();

                String atomized = nt.Add("");

                Assert.IsTrue(Object.ReferenceEquals(atomized, String.Empty), "Atomized Empty String is not String.Empty");
            }
            catch (Exception e)
            {
                Log.Exception("Unexpected exception", e);
                return MFTestResults.Fail;
            }

            return MFTestResults.Pass;
        }
Ejemplo n.º 55
0
        internal static string XdrCanonizeUri(string uri, XmlNameTable nameTable, SchemaNames schemaNames)
        {
            string canonicalUri;
            int offset = 5;
            bool convert = false;

            if (uri.Length > 5 && uri.StartsWith("uuid:", StringComparison.Ordinal))
            {
                convert = true;
            }
            else if (uri.Length > 9 && uri.StartsWith("urn:uuid:", StringComparison.Ordinal))
            {
                convert = true;
                offset = 9;
            }

            if (convert)
            {
                canonicalUri = nameTable.Add(uri.Substring(0, offset) + CultureInfo.InvariantCulture.TextInfo.ToUpper(uri.Substring(offset, uri.Length - offset)));
            }
            else
            {
                canonicalUri = uri;
            }

            if (
                Ref.Equal(schemaNames.NsDataTypeAlias, canonicalUri) ||
                Ref.Equal(schemaNames.NsDataTypeOld, canonicalUri)
            )
            {
                canonicalUri = schemaNames.NsDataType;
            }
            else if (Ref.Equal(schemaNames.NsXdrAlias, canonicalUri))
            {
                canonicalUri = schemaNames.NsXdr;
            }

            return canonicalUri;
        }
Ejemplo n.º 56
0
        // Initializes a new instance of the XmlTextReaderImpl class with the specified XmlNameTable.
        // This constructor is used when creating XmlTextReaderImpl for V1 XmlTextReader
        internal XmlTextReaderImpl(XmlNameTable nt)
        {
            Debug.Assert(nt != null);

            _v1Compat = true;
            _outerReader = this;

            _nameTable = nt;
            nt.Add(string.Empty);

            if (!System.Xml.XmlReaderSettings.EnableLegacyXmlSettings())
            {
                _xmlResolver = null;
            }
            else
            {
                _xmlResolver = new XmlUrlResolver();
            }

            _xml = nt.Add("xml");
            _xmlNs = nt.Add("xmlns");

            Debug.Assert(_index == 0);
            _nodes = new NodeData[NodesInitialSize];
            _nodes[0] = new NodeData();
            _curNode = _nodes[0];

            _stringBuilder = new StringBuilder();
            _xmlContext = new XmlContext();

            _parsingFunction = ParsingFunction.SwitchToInteractiveXmlDecl;
            _nextParsingFunction = ParsingFunction.DocumentContent;

            _entityHandling = EntityHandling.ExpandCharEntities;
            _whitespaceHandling = WhitespaceHandling.All;
            _closeInput = true;

            _maxCharactersInDocument = 0;
            // Breaking change: entity expansion is enabled, but limit it to 10,000,000 chars (like XLinq)
            _maxCharactersFromEntities = (long)1e7;
            _charactersInDocument = 0;
            _charactersFromEntities = 0;

            _ps.lineNo = 1;
            _ps.lineStartPos = -1;
        }
Ejemplo n.º 57
0
        // Initializes a new instance of the XmlTextReaderImpl class with the specified XmlNameTable.
        // This constructor is used when creating XmlTextReaderImpl for V1 XmlTextReader
        internal XmlTextReaderImpl( XmlNameTable nt ) {
            Debug.Assert( nt != null );

            v1Compat = true;
            outerReader = this;

            nameTable = nt;
            nt.Add( string.Empty );

            xmlResolver = new XmlUrlResolver();

            Xml = nt.Add( "xml" );
            XmlNs = nt.Add( "xmlns" );

            Debug.Assert( index == 0 );
            nodes = new NodeData[ NodesInitialSize ];
            nodes[0] = new NodeData();
            curNode = nodes[0];

            stringBuilder = new BufferBuilder();
            xmlContext = new XmlContext();

            parsingFunction = ParsingFunction.SwitchToInteractiveXmlDecl;
            nextParsingFunction = ParsingFunction.DocumentContent;

            entityHandling = EntityHandling.ExpandCharEntities;
            whitespaceHandling = WhitespaceHandling.All;
            closeInput = true;

            maxCharactersInDocument = 0;
            // Breaking change: entity expansion is enabled, but limit it to 10,000,000 chars (like XLinq)
            maxCharactersFromEntities = (long)1e7;
            charactersInDocument = 0;
            charactersFromEntities = 0;

            ps.lineNo = 1;
            ps.lineStartPos = -1;
        }
		public XmlNamespaceManager (XmlNameTable nameTable)
		{
			if (nameTable == null)
				throw new ArgumentNullException ("nameTable");
			this.nameTable = nameTable;

			nameTable.Add (PrefixXmlns);
			nameTable.Add (PrefixXml);
			nameTable.Add (String.Empty);
			nameTable.Add (XmlnsXmlns);
			nameTable.Add (XmlnsXml);
			
			InitData ();
		}
Ejemplo n.º 59
0
 public string GetEscapedString(int iOffset, int length, XmlNameTable nameTable)
 {
     char[] charBuffer = this.GetCharBuffer(length);
     int escapedChars = this.GetEscapedChars(iOffset, length, charBuffer);
     return nameTable.Add(charBuffer, 0, escapedChars);
 }
Ejemplo n.º 60
0
 public string GetString(int iOffset, int iLength, XmlNameTable nameTable)
 {
     char[] charBuffer = this.GetCharBuffer(iLength);
     int charsLength = this.GetChars(iOffset, iLength, charBuffer);
     return nameTable.Add(charBuffer, 0, charsLength);
 }