namespace System.Xml
{
+ // FIXME: this implementation requires somewhat significant change
+ // to expand entities and merge sequential text and entity references
+ // especially to handle whitespace-only entities (such as bug #372839).
+ //
+ // To do it, we have to read ahead the next node when the input is
+ // text, whitespace or significant whitespace and check if the next
+ // node is EntityReference. If it is entref, then it have to merge
+ // the input entity if it is a text.
+ //
+ // This "read ahead" operation may result in proceeding to the next
+ // element, which badly affects IXmlNamespaceResolverimplementation.
+ // So we cannot fix this in simple way.
+
[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
public class XmlTextReader : XmlReader,
IXmlLineInfo, IXmlNamespaceResolver, IHasXmlParserContext
source = new XmlTextReaderImpl (baseURI, xmlFragment, fragType, context);
}
- internal XmlTextReader (bool dummy, string url, XmlNodeType fragType, XmlParserContext context)
+ internal XmlTextReader (bool dummy, XmlResolver resolver, string url, XmlNodeType fragType, XmlParserContext context)
{
- source = new XmlTextReaderImpl (dummy, url, fragType, context);
+ source = new XmlTextReaderImpl (dummy, resolver, url, fragType, context);
}
private XmlTextReader (XmlTextReaderImpl entityContainer, bool insideAttribute)
public void ResetState ()
{
if (entity != null)
- entity.ResetState ();
+ CloseEntity ();
source.ResetState ();
}
- public override void ResolveEntity ()
+ public override
+ 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 =
- ParserContext.Dtd.GenerateEntityContentReader (source.Name, ParserContext);
+ 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)
base.Skip ();
}
- [MonoTODO ("Check how expanded entity is handled here.")]
+ [MonoTODO] // FIXME: Check how expanded entity is handled here.
public TextReader GetRemainder ()
{
if (entity != null) {
return true;
}
- [MonoTODO ("Check how expanded entity is handled here.")]
+ [MonoTODO] // FIXME: Check how expanded entity is handled here.
public int ReadBase64 (byte [] buffer, int offset, int length)
{
if (entity != null)
return source.ReadBase64 (buffer, offset, length);
}
- [MonoTODO ("Check how expanded entity is handled here.")]
+ [MonoTODO] // FIXME: Check how expanded entity is handled here.
public int ReadBinHex (byte [] buffer, int offset, int length)
{
if (entity != null)
return source.ReadBinHex (buffer, offset, length);
}
- [MonoTODO ("Check how expanded entity is handled here.")]
+ [MonoTODO] // FIXME: Check how expanded entity is handled here.
public int ReadChars (char [] buffer, int offset, int length)
{
if (entity != null)
}
- [MonoTODO ("Check how expanded entity is handled here.")]
+ [MonoTODO] // FIXME: Check how expanded entity is handled here.
public override int ReadContentAsBase64 (byte [] buffer, int offset, int length)
{
if (entity != null)
return source.ReadContentAsBase64 (buffer, offset, length);
}
- [MonoTODO ("Check how expanded entity is handled here.")]
+ [MonoTODO] // FIXME: Check how expanded entity is handled here.
public override int ReadContentAsBinHex (byte [] buffer, int offset, int length)
{
if (entity != null)
return source.ReadContentAsBinHex (buffer, offset, length);
}
- [MonoTODO ("Check how expanded entity is handled here.")]
+ [MonoTODO] // FIXME: Check how expanded entity is handled here.
public override int ReadElementContentAsBase64 (byte [] buffer, int offset, int length)
{
if (entity != null)
return source.ReadElementContentAsBase64 (buffer, offset, length);
}
- [MonoTODO ("Check how expanded entity is handled here.")]
+ [MonoTODO] // FIXME: Check how expanded entity is handled here.
public override int ReadElementContentAsBinHex (byte [] buffer, int offset, int length)
{
if (entity != null)