Exemple #1
0
        void ResolveEntity()
        {
            if (entity != null)
            {
                entity.ResolveEntity();
            }
            else
            {
                if (source.NodeType != XmlNodeType.EntityReference)
                {
                    throw new InvalidOperationException("The current node is not an Entity Reference");
                }
                XmlTextReaderImpl entReader = null;

#if NOT_PFX
                if (ParserContext.Dtd != null)
                {
                    entReader = ParserContext.Dtd.GenerateEntityContentReader(source.Name, ParserContext);
                }
#endif
                if (entReader == null)
                {
                    throw new XmlException(this as IXmlLineInfo, this.BaseURI, String.Format("Reference to undeclared entity '{0}'.", source.Name));
                }
                if (entityNameStack == null)
                {
                    entityNameStack = new Stack <string> ();
                }
                else if (entityNameStack.Contains(Name))
                {
                    throw new XmlException(String.Format("General entity '{0}' has an invalid recursive reference to itself.", Name));
                }
                entityNameStack.Push(Name);
                entity = new XmlTextReader(
                    entReader, insideAttribute);
                entity.entityNameStack = entityNameStack;
                entity.CopyProperties(this);
            }
        }
		void ResolveEntity ()
		{
			if (entity != null)
				entity.ResolveEntity ();
			else {
				if (source.NodeType != XmlNodeType.EntityReference)
					throw new InvalidOperationException ("The current node is not an Entity Reference");
				XmlTextReaderImpl entReader = null;
				if (ParserContext.Dtd != null)
					entReader = ParserContext.Dtd.GenerateEntityContentReader (source.Name, ParserContext);
				if (entReader == null)
					throw new XmlException (this as IXmlLineInfo, this.BaseURI, String.Format ("Reference to undeclared entity '{0}'.", source.Name));
				if (entityNameStack == null)
					entityNameStack = new Stack<string> ();
				else if (entityNameStack.Contains (Name))
					throw new XmlException (String.Format ("General entity '{0}' has an invalid recursive reference to itself.", Name));
				entityNameStack.Push (Name);
				entity = new XmlTextReader (
					entReader, insideAttribute);
				entity.entityNameStack = entityNameStack;
				entity.CopyProperties (this);
			}
		}