+2006-04-19 Atsushi Enomoto <atsushi@ximian.com>
+
+ * NvdlFilteredXmlReader.cs :
+ Made placeholder element as "empty" i.e. IsEmptyElement = true.
+ As long as it is at placeholder state, it keeps being placeholder
+ empty element until DetachPlaceholder() is explicitly called. It
+ makes this reader simpler.
+ * NvdlValidator.cs : (NvdlResultInterp) for AttachPlaceHolder it does
+ not have to do anything other than AttachPlaceholder().
+ (NvdlValidateInterp) Now that placeholder becomes an empty element
+ it does not have to validate content anymore at DetachPlaceholder().
+
2006-04-19 Atsushi Enomoto <atsushi@ximian.com>
* NvdlReader.cs, NvdlFilteredXmlReader.cs :
{
internal class NvdlFilteredXmlReader : XmlReader, IXmlLineInfo
{
+ // In this XmlReader, when AttachPlaceHolder() is called,
+ // it treats the next node as to point virtual "placeholder"
+ // element where IsEmptyElement is false. When it is
+ // Detached, then *current* node becomes the usual reader
+ // node.
+
bool initial = true;
- int placeHolderDepth = -1;
+ int placeHolderDepth = 0;
XmlNodeType nextPlaceHolder;
XmlNodeType placeHolder = XmlNodeType.None;
bool placeHolderLocalNameAttr;
- Stack placeHolderDepthStack;
NvdlValidateInterp validate;
XmlReader reader;
IXmlLineInfo reader_as_line_info;
public void AttachPlaceholder ()
{
- if (placeHolderDepthStack == null)
- placeHolderDepthStack = new Stack ();
- else
- placeHolderDepthStack.Push (placeHolderDepth);
- placeHolderDepth = reader.Depth;
+ placeHolderDepth++;
nextPlaceHolder = XmlNodeType.Element;
}
public void DetachPlaceholder ()
{
- if (placeHolderDepthStack.Count > 0)
- placeHolderDepth = (int) placeHolderDepthStack.Pop ();
- else
- placeHolderDepth = -1;
- nextPlaceHolder = XmlNodeType.EndElement;
+ placeHolderDepth--;
+ placeHolder = XmlNodeType.None;
}
private void AddAttribute ()
return true;
}
+ if (placeHolder != XmlNodeType.None)
+ // Inside placeHolder, ignore all contents.
+ // The source XmlReader should proceed
+ // regardless of this filtered reader.
+ return true;
+
if (!reader.MoveToFirstAttribute ())
return true;
public override int Depth {
get {
- if (placeHolderDepth < 0)
+ if (placeHolderDepth == 0)
return reader.Depth;
- int basis = reader.Depth + placeHolderDepthStack.Count + 1;
+ int basis = reader.Depth + 1;
switch (placeHolder) {
case XmlNodeType.Text:
return basis + 2;
public override bool IsEmptyElement {
get {
- return placeHolder == XmlNodeType.None &&
+ return placeHolder != XmlNodeType.None ||
reader.IsEmptyElement;
}
}
Parent.ValidateStartElement ();
break;
case NvdlResultType.AttachPlaceholder:
- throw new NotImplementedException ();
+ break;
}
}
public override void ValidateEndElement ()
Parent.ValidateEndElement ();
break;
case NvdlResultType.AttachPlaceholder:
- throw new NotImplementedException ();
+ break;
}
}
public override void ValidateText ()
Parent.ValidateText ();
break;
case NvdlResultType.AttachPlaceholder:
- throw new NotImplementedException ();
+ break;
}
}
public override void ValidateWhitespace ()
Parent.ValidateWhitespace ();
break;
case NvdlResultType.AttachPlaceholder:
- throw new NotImplementedException ();
+ break;
}
}
}
public override void DetachPlaceholder ()
{
reader.DetachPlaceholder ();
- validator.Read (); // check EndElement
+ // since placeholder is *empty*, we don't have to
+ // validate this virtual element.
+ //validator.Read ();
}
public override void EndSection ()