Example #1
1
 /// <include file='doc\XmlParserContext.uex' path='docs/doc[@for="XmlParserContext.XmlParserContext3"]/*' />
 public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String docTypeName,
                   String pubId, String sysId, String internalSubset, String baseURI,
                   String xmlLang, XmlSpace xmlSpace, Encoding enc)
 {
     
     if (nsMgr != null) {
         if (nt == null) {
             _nt = nsMgr.NameTable;
         }
         else {
             if ( (object)nt != (object)  nsMgr.NameTable ) {
                 throw new XmlException(Res.Xml_NotSameNametable);
             }
             _nt = nt;
         }
     }
     else {
         _nt = nt;
     }
     
     _nsMgr              = nsMgr;
     _docTypeName        = (null == docTypeName ? String.Empty : docTypeName);
     _pubId              = (null == pubId ? String.Empty : pubId);
     _sysId              = (null == sysId ? String.Empty : sysId);
     _internalSubset     = (null == internalSubset ? String.Empty : internalSubset);
     _baseURI            = (null == baseURI ? String.Empty : baseURI);
     _xmlLang            = (null == xmlLang ? String.Empty : xmlLang);
     _xmlSpace           = xmlSpace;
     _encoding           = enc;
     
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigableNavigator"/> class with a content source,
 /// and an optional root content.
 /// </summary>
 /// <param name="source">The content source.</param>
 /// <param name="content">The root content.</param>
 /// <remarks>When no root content is supplied then the root of the source is used.</remarks>
 public NavigableNavigator(INavigableSource source, INavigableContent content = null)
     : this(source)
 {
     _nameTable = new NameTable();
     _lastAttributeIndex = source.LastAttributeIndex;
     _state = new State(content ?? source.Root, null, null, 0, StatePosition.Root);
 }
 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;
 }
 public XmlSchemaValidator(XmlNameTable nameTable, XmlSchemaSet schemas, IXmlNamespaceResolver namespaceResolver, XmlSchemaValidationFlags validationFlags)
 {
     if (nameTable == null)
     {
         throw new ArgumentNullException("nameTable");
     }
     if (schemas == null)
     {
         throw new ArgumentNullException("schemas");
     }
     if (namespaceResolver == null)
     {
         throw new ArgumentNullException("namespaceResolver");
     }
     this.nameTable = nameTable;
     this.nsResolver = namespaceResolver;
     this.validationFlags = validationFlags;
     if (((validationFlags & XmlSchemaValidationFlags.ProcessInlineSchema) != XmlSchemaValidationFlags.None) || ((validationFlags & XmlSchemaValidationFlags.ProcessSchemaLocation) != XmlSchemaValidationFlags.None))
     {
         this.schemaSet = new XmlSchemaSet(nameTable);
         this.schemaSet.ValidationEventHandler += schemas.GetEventHandler();
         this.schemaSet.CompilationSettings = schemas.CompilationSettings;
         this.schemaSet.XmlResolver = schemas.GetResolver();
         this.schemaSet.Add(schemas);
         this.validatedNamespaces = new Hashtable();
     }
     else
     {
         this.schemaSet = schemas;
     }
     this.Init();
 }
Example #5
0
 /// <include file='doc\XmlParserContext.uex' path='docs/doc[@for="XmlParserContext.XmlParserContext1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String docTypeName,
           String pubId, String sysId, String internalSubset, String baseURI,
           String xmlLang, XmlSpace xmlSpace) 
 : this(nt, nsMgr, docTypeName, pubId, sysId, internalSubset, baseURI, xmlLang, xmlSpace, null)
 {
     // Intentionally Empty
 }
 internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
 {
     typedValue = null;
     Exception exception = DatatypeImplementation.binaryFacetsChecker.CheckLexicalFacets(ref s, this);
     if (exception == null)
     {
         byte[] buffer = null;
         try
         {
             buffer = XmlConvert.FromBinHexString(s, false);
         }
         catch (ArgumentException exception2)
         {
             return exception2;
         }
         catch (XmlException exception3)
         {
             return exception3;
         }
         exception = DatatypeImplementation.binaryFacetsChecker.CheckValueFacets(buffer, this);
         if (exception == null)
         {
             typedValue = buffer;
             return null;
         }
     }
     return exception;
 }
Example #7
0
		public XmlPathProcessor(IList<XmlMatch> matchList, Action<XmlReader> action,
			XmlNameTable readerNameTable)
		{
			Guard.ArgumentNotNull(readerNameTable, "readerNameTable");

			Initialize(matchList, action, new XmlNamespaceManager(readerNameTable));
		}
	protected XmlTextReader(XmlNameTable nt)
			{
				if(nt == null)
				{
					throw new ArgumentNullException("nt");
				}

				namespaces = true;
				normalize = false;
				depth = 0;
				readState = ReadState.Initial;
				whitespace = WhitespaceHandling.All;

				xmlBaseName = nt.Add("xml:base");
				xmlLangName = nt.Add("xml:lang");
				xmlSpaceName = nt.Add("xml:space");
				xmlNSPrefix = nt.Add("xmlns");
				xmlCompareQuick = nt.Add("xml");

				contextSupport = false;
				hasRoot = true;
				incDepth = false;
				xmlPopScope = false;
				xmlnsPopScope = false;
				sawPreserve = -1;
				state = State.XmlDeclaration;
				elementNames = new Stack();
				nodes = new NodeManager(nt, new ErrorHandler(Error));
				input = new XmlParserInput
					(null, nt, new EOFHandler(HandleEOF), new ErrorHandler(Error));
				context = new XmlParserContext
					(nt, new XmlNamespaceManager(nt), String.Empty, XmlSpace.None);
				resolver = new XmlUrlResolver();
				dtdReader = new XmlDTDReader(context);
			}
Example #9
0
 internal RecordBuilder(RecordOutput output, XmlNameTable nameTable) {
     Debug.Assert(output != null);
     this.output    = output;
     this.nameTable = nameTable != null ? nameTable : new NameTable();
     this.atoms     = new OutKeywords(this.nameTable);
     this.scopeManager   = new OutputScopeManager(this.nameTable, this.atoms);
 }
 internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
 {
     typedValue = null;
     if ((s == null) || (s.Length == 0))
     {
         return new XmlSchemaException("Sch_EmptyAttributeValue", string.Empty);
     }
     Exception exception = DatatypeImplementation.qnameFacetsChecker.CheckLexicalFacets(ref s, this);
     if (exception == null)
     {
         XmlQualifiedName name = null;
         try
         {
             string str;
             name = XmlQualifiedName.Parse(s, nsmgr, out str);
         }
         catch (ArgumentException exception2)
         {
             return exception2;
         }
         catch (XmlException exception3)
         {
             return exception3;
         }
         exception = DatatypeImplementation.qnameFacetsChecker.CheckValueFacets(name, this);
         if (exception == null)
         {
             typedValue = name;
             return null;
         }
     }
     return exception;
 }
        const int InitialSize = 64; // must be a power of two

        public DomNameTable( XmlDocument document ) {
            ownerDocument = document;
            nameTable = document.NameTable;
            entries = new XmlName[InitialSize];
            mask = InitialSize - 1;
            Debug.Assert( ( entries.Length & mask ) == 0 );  // entries.Length must be a power of two
        }
Example #12
0
 /// <summary>
 ///     Initialises a new instance of the <see cref="SgmlDtd" /> class.
 /// </summary>
 /// <param name="name">The name of the DTD.</param>
 /// <param name="nt">
 ///     The <see cref="XmlNameTable" /> is NOT used.
 /// </param>
 public SgmlDtd(string name, XmlNameTable nt) {
     this.m_name = name;
     this.m_elements = new Dictionary<string, ElementDecl>();
     this.m_pentities = new Dictionary<string, Entity>();
     this.m_entities = new Dictionary<string, Entity>();
     this.m_sb = new StringBuilder();
 }
		private XmlLightNavigator(XmlNameTable names, XmlLightElement current, List<string> attrNames, int attribute)
		{
			_names = names;
			_current = current;
			_attrNames = attrNames;
			_attribute = attribute;
		}
 public override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr)
 {
     object obj2;
     if ((s == null) || (s.Length == 0))
     {
         throw new XmlSchemaException("Sch_EmptyAttributeValue", string.Empty);
     }
     if (nsmgr == null)
     {
         throw new ArgumentNullException("nsmgr");
     }
     try
     {
         string str;
         obj2 = XmlQualifiedName.Parse(s.Trim(), nsmgr, out str);
     }
     catch (XmlSchemaException exception)
     {
         throw exception;
     }
     catch (Exception exception2)
     {
         throw new XmlSchemaException(Res.GetString("Sch_InvalidValue", new object[] { s }), exception2);
     }
     return obj2;
 }
Example #15
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);
 }
Example #16
0
        public XdmNodeNavigator(XdmNode node)
        {
            if (node == null) throw new ArgumentNullException("node");

             this.currentNode = node;
             this.nameTable = CreateNameTable();
        }
 internal XNodeReader(XNode node, XmlNameTable nameTable, ReaderOptions options)
 {
     this.source = node;
     this.root = node;
     this.nameTable = (nameTable != null) ? nameTable : CreateNameTable();
     this.omitDuplicateNamespaces = (options & ReaderOptions.OmitDuplicateNamespaces) != ReaderOptions.None;
 }
 public AndroidXmlReader(Stream source)
 {
     _parser = new ResXMLParser(source);
     _namespaces = new Dictionary<string, List<string>>();
     _nameTable = new NameTable();
     _readIterator = ReadIterator().GetEnumerator();
 }
	// 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);
			}
 public DomNameTable(XmlDocument document)
 {
     this.ownerDocument = document;
     this.nameTable = document.NameTable;
     this.entries = new XmlName[0x40];
     this.mask = 0x3f;
 }
 public XmlNodeReaderNavigator(XmlNode node)
 {
     this.curNode = node;
     this.logNode = node;
     XmlNodeType nodeType = this.curNode.NodeType;
     if (nodeType == XmlNodeType.Attribute)
     {
         this.elemNode = null;
         this.attrIndex = -1;
         this.bCreatedOnAttribute = true;
     }
     else
     {
         this.elemNode = node;
         this.attrIndex = -1;
         this.bCreatedOnAttribute = false;
     }
     if (nodeType == XmlNodeType.Document)
     {
         this.doc = (XmlDocument) this.curNode;
     }
     else
     {
         this.doc = node.OwnerDocument;
     }
     this.nameTable = this.doc.NameTable;
     this.nAttrInd = -1;
     this.nDeclarationAttrCount = -1;
     this.nDocTypeAttrCount = -1;
     this.bOnAttrVal = false;
     this.bLogOnAttrVal = false;
 }
Example #22
0
        public XdmNodeNavigator(XdmNodeNavigator other)
        {
            if (other == null) throw new ArgumentNullException("other");

             this.currentNode = other.currentNode;
             this.nameTable = other.nameTable;
        }
 internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
 {
     typedValue = null;
     if ((s == null) || (s.Length == 0))
     {
         return new XmlSchemaException("Sch_EmptyAttributeValue", string.Empty);
     }
     Exception exception = DatatypeImplementation.durationFacetsChecker.CheckLexicalFacets(ref s, this);
     if (exception == null)
     {
         XsdDuration duration;
         exception = XsdDuration.TryParse(s, XsdDuration.DurationType.YearMonthDuration, out duration);
         if (exception == null)
         {
             TimeSpan span;
             exception = duration.TryToTimeSpan(XsdDuration.DurationType.YearMonthDuration, out span);
             if (exception == null)
             {
                 exception = DatatypeImplementation.durationFacetsChecker.CheckValueFacets(span, this);
                 if (exception == null)
                 {
                     typedValue = span;
                     return null;
                 }
             }
         }
     }
     return exception;
 }
 /// <summary>
 /// Construct an XmlCsvReader.
 /// </summary>
 /// <param name="input">The .csv input stream</param>
 /// <param name="baseUri">The base URI of the .csv.</param>
 /// <param name="nametable">The nametable to use for atomizing element names</param>
 public XmlCsvReader(Stream input, Encoding encoding, Uri baseUri, XmlNameTable nametable)
 {
     _baseUri = baseUri;
     _encoding = encoding;
     _csvReader = new CsvReader(input, encoding, 4096);
     _nt = nametable;
 }
Example #25
0
 public static XmlNamespaceManager CreateManager(XmlNameTable table)
 {
     XmlNamespaceManager mgr = new XmlNamespaceManager(table);
     mgr.AddNamespace(Options_Prefix, Options);
     mgr.AddNamespace(SongBook_Prefix, SongBook);
     return mgr;
 }
Example #26
0
 /// <summary>
 /// Start construction of a new Xml tree (document or fragment).
 /// </summary>
 public override XmlRawWriter StartTree(XPathNodeType rootType, IXmlNamespaceResolver nsResolver, XmlNameTable nameTable) {
     // Build XPathDocument
     // If rootType != XPathNodeType.Root, then build an XQuery fragment
     this.doc = new XPathDocument(nameTable);
     this.writer = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames | (rootType == XPathNodeType.Root ? XPathDocument.LoadFlags.None : XPathDocument.LoadFlags.Fragment), string.Empty);
     this.writer.NamespaceResolver = nsResolver;
     return this.writer;
 }
 internal XPathDocument(XmlNameTable nameTable)
 {
     if (nameTable == null)
     {
         throw new ArgumentNullException("nameTable");
     }
     this.nameTable = nameTable;
 }
Example #28
0
        /// <summary>
        /// Initializes a new instance of CssXmlDocument
        /// </summary>
        /// <param name="nt">The name table to use</param>
        public CssXmlDocument(XmlNameTable nt)
            : base(nt)
        {
            setupNodeChangeListeners();

            //	SharpVectors.Net.ExtendedHttpWebRequest.Register();
            //	SharpVectors.Net.DataWebRequest.Register();
        }
Example #29
0
		/// <summary>
		/// Creates a copy of given context. Contexts shares the same name table,
		/// namespace manager, and factories.
		/// </summary>
		/// <param name="other">An instance of <see cref="ObjectXPathContext"/> to 
		/// copy.</param>
		private ObjectXPathContext( ObjectXPathContext other ) : 
			this( (XmlNamespaceManager)null )
		{
			_nameTable = other.NameTable;
			_namespaceManager = other.NamespaceManager;
			_nodePolicyFactory = other._nodePolicyFactory;
			_converterFactory = other._converterFactory;
		}
Example #30
0
 /// <summary>
 /// Initialises a new instance of the <see cref="SgmlDtd"/> class.
 /// </summary>
 /// <param name="name">The name of the DTD.</param>
 /// <param name="nt">The <see cref="XmlNameTable"/> is NOT used.</param>
 public SgmlDtd( string name, XmlNameTable nt )
 {
     Name = name;
       _elements = new Dictionary<string, ElementDecl>();
       _parameterEntities = new Dictionary<string, Entity>();
       _entities = new Dictionary<string, Entity>();
       _sb = new StringBuilder();
 }
 /// <include file='doc\XmlParserContext.uex' path='docs/doc[@for="XmlParserContext.XmlParserContext2"]/*' />
 public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String xmlLang, XmlSpace xmlSpace, Encoding enc)
     : this(nt, nsMgr, null, null, null, null, String.Empty, xmlLang, xmlSpace, enc)
 {
     // Intentionally Empty
 }
Example #32
0
#pragma warning restore 618

        private XmlParserContext GetContext(XmlNode node)
        {
            string          lang      = null;
            XmlSpace        spaceMode = XmlSpace.None;
            XmlDocumentType docType   = _doc.DocumentType;
            string          baseURI   = _doc.BaseURI;
            //constructing xmlnamespace
            HashSet <string>    prefixes = new HashSet <string>();
            XmlNameTable        nt       = _doc.NameTable;
            XmlNamespaceManager mgr      = new XmlNamespaceManager(nt);
            bool bHasDefXmlnsAttr        = false;

            // Process all xmlns, xmlns:prefix, xml:space and xml:lang attributes
            while (node != null && node != _doc)
            {
                XmlElement element = node as XmlElement;
                if (element != null && element.HasAttributes)
                {
                    mgr.PushScope();
                    foreach (XmlAttribute attr in element.Attributes)
                    {
                        if (attr.Prefix == _doc.strXmlns && !prefixes.Contains(attr.LocalName))
                        {
                            // Make sure the next time we will not add this prefix
                            prefixes.Add(attr.LocalName);
                            mgr.AddNamespace(attr.LocalName, attr.Value);
                        }
                        else if (!bHasDefXmlnsAttr && attr.Prefix.Length == 0 && attr.LocalName == _doc.strXmlns)
                        {
                            // Save the case xmlns="..." where xmlns is the LocalName
                            mgr.AddNamespace(string.Empty, attr.Value);
                            bHasDefXmlnsAttr = true;
                        }
                        else if (spaceMode == XmlSpace.None && attr.Prefix == _doc.strXml && attr.LocalName == _doc.strSpace)
                        {
                            // Save xml:space context
                            if (attr.Value == "default")
                            {
                                spaceMode = XmlSpace.Default;
                            }
                            else if (attr.Value == "preserve")
                            {
                                spaceMode = XmlSpace.Preserve;
                            }
                        }
                        else if (lang == null && attr.Prefix == _doc.strXml && attr.LocalName == _doc.strLang)
                        {
                            // Save xml:lag context
                            lang = attr.Value;
                        }
                    }
                }
                node = node.ParentNode;
            }
            return(new XmlParserContext(
                       nt,
                       mgr,
                       (docType == null) ? null : docType.Name,
                       (docType == null) ? null : docType.PublicId,
                       (docType == null) ? null : docType.SystemId,
                       (docType == null) ? null : docType.InternalSubset,
                       baseURI,
                       lang,
                       spaceMode
                       ));
        }
Example #33
0
 public XmlTextReader(string url, TextReader input, XmlNameTable nt)
 {
     _impl             = new XmlTextReaderImpl(url, input, nt);
     _impl.OuterReader = this;
 }
Example #34
0
 public MyXmlNamespaceResolver(System.Xml.XmlNameTable nameTable)
 {
     this.nameTable = nameTable;
     this.emptyAtom = nameTable.Add(string.Empty);
 }
Example #35
0
 protected XmlTextReader(XmlNameTable nt)
 {
     _impl             = new XmlTextReaderImpl(nt);
     _impl.OuterReader = this;
 }
Example #36
0
 public XmlTextReader(TextReader input, XmlNameTable nt)
 {
     _impl             = new XmlTextReaderImpl(input, nt);
     _impl.OuterReader = this;
 }
Example #37
0
 public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, string docTypeName, string pubId, string sysId, string internalSubset, string baseURI, string xmlLang, System.Xml.XmlSpace xmlSpace) : this(nt, nsMgr, docTypeName, pubId, sysId, internalSubset, baseURI, xmlLang, xmlSpace, null)
 {
 }
Example #38
0
 public XmlTextReader(String url, XmlNameTable nt)
 {
     _impl             = new XmlTextReaderImpl(url, nt);
     _impl.OuterReader = this;
 }
Example #39
0
 // Summary:
 //     Initializes a new instance of the System.Xml.XmlNamespaceManager class with
 //     the specified System.Xml.XmlNameTable.
 //
 // Parameters:
 //   nameTable:
 //     The System.Xml.XmlNameTable to use.
 //
 // Exceptions:
 //   System.NullReferenceException:
 //     null is passed to the constructor
 public XmlNamespaceManager(XmlNameTable nameTable)
 {
     Contract.Requires(nameTable != null);
 }
Example #40
0
 public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, string xmlLang, System.Xml.XmlSpace xmlSpace, System.Text.Encoding enc) : this(nt, nsMgr, null, null, null, null, string.Empty, xmlLang, xmlSpace, enc)
 {
 }
 public XmlImplementation(XmlNameTable nt)
 {
     nameTable = nt;
 }
Example #42
0
 internal void Atomize(XmlNameTable nameTable)
 {
     Debug.Assert(_name != null);
     _name = nameTable.Add(_name);
     _ns   = nameTable.Add(_ns);
 }