本文整理汇总了C#中Sgml.Node类的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于Sgml命名空间,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
void Init() {
this.state = State.Initial;
this.stack = new HWStack(10);
this.node = Push(null, XmlNodeType.Document, null);
this.node.IsEmpty = false;
this.sb = new StringBuilder();
this.name = new StringBuilder();
this.poptodepth = 0;
this.current = null;
this.partial = '\0';
this.endTag = null;
this.a = null;
this.apos = 0;
this.newnode = null;
this.rootCount = 0;
this.foundRoot = false;
}
示例2: ValidateContent
void ValidateContent(Node node) {
if (this.dtd != null) {
// See if this element is allowed inside the current element.
// If it isn't, then auto-close elements until we find one
// that it is allowed to be in.
string name = this.nametable.Add(node.Name.ToUpper()); // DTD is in upper case
int i = 0;
int top = this.stack.Count-2;
if (node.DtdType != null) {
// it is a known element, let's see if it's allowed in the
// current context.
for (i = top; i>0; i--) {
Node n = (Node)this.stack[i];
if (n.IsEmpty)
continue; // we'll have to pop this one
ElementDecl f = n.DtdType;
if (f != null) {
if (f.Name == this.dtd.Name)
break; // can't pop the root element.
if (f.CanContain(name, this.dtd)) {
break;
}
else if (!f.EndTagOptional) {
// If the end tag is not optional then we can't
// auto-close it. We'll just have to live with the
// junk we've found and move on.
break;
}
}
else {
// Since we don't understand this tag anyway,
// we might as well allow this content!
break;
}
}
}
if (i == 0) {
// Tag was not found or is not allowed anywhere, ignore it and
// continue on.
}
else if (i < top) {
Node n = (Node)this.stack[top];
if (i == top - 1 && name == n.Name) {
// e.g. p not allowed inside p, not an interesting error.
} else {
string closing = "";
for (int k = top; k >= i+1; k--) {
if (closing != "") closing += ",";
Node n2 = (Node)this.stack[k];
closing += "<"+n2.Name+">";
}
Log("Element '{0}' not allowed inside '{1}', closing {2}.",
name, n.Name, closing);
}
this.state = State.AutoClose;
this.newnode = node;
Pop(); // save this new node until we pop the others
this.poptodepth = i+1;
}
}
}
示例3: CopyAttributes
public void CopyAttributes(Node n) {
for (int i = 0, len = n.attributes.Count; i < len; i++) {
Attribute a = (Attribute)n.attributes[i];
Attribute na = this.AddAttribute(a.Name, a.Value, a.QuoteChar, false);
na.DtdType = a.DtdType;
}
}
示例4: Validate
void Validate(Node node) {
if (this.dtd != null) {
ElementDecl e = this.dtd.FindElement(node.Name);
if (e != null) {
node.DtdType = e;
if (e.ContentModel.DeclaredContent == DeclaredContent.EMPTY)
node.IsEmpty = true;
}
}
}
示例5: ValidateAttribute
void ValidateAttribute(Node node, Attribute a) {
ElementDecl e = node.DtdType;
if (e != null) {
AttDef ad = e.FindAttribute(a.Name);
if (ad != null) {
a.DtdType = ad;
}
}
}
示例6: Pop
void Pop() {
if (this.stack.Count > 1) {
this.node = (Node)this.stack.Pop();
}
}
示例7: ParseEndTag
private bool ParseEndTag()
{
this.m_state = State.EndTag;
this.m_current.ReadChar(); // consume '/' char.
string name = this.ScanName(SgmlReader.tagterm);
char ch = this.m_current.SkipWhitespace();
if (ch != '>')
{
Log("Expected empty start tag '/>' sequence instead of '{0}'", ch);
this.m_current.ScanToEnd(null, "Recovering", ">");
}
this.m_current.ReadChar(); // consume '>'
this.m_endTag = name;
// Make sure there's a matching start tag for it.
bool caseInsensitive = (this.m_folding == CaseFolding.None);
this.m_node = (Node)this.m_stack[this.m_stack.Count - 1];
for (int i = this.m_stack.Count - 1; i > 0; i--)
{
Node n = (Node)this.m_stack[i];
if (string.Equals(n.Name, name, caseInsensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal))
{
this.m_endTag = n.Name;
return true;
}
}
Log("No matching start tag for '</{0}>'", name);
this.m_state = State.Markup;
return false;
}
示例8: Pop
private void Pop()
{
if (this.m_stack.Count > 1)
{
this.m_node = (Node)this.m_stack.Pop();
}
}
示例9: Init
void Init()
{
_state = State.Initial;
_stack = new Node[10];
_size = 10;
_depth = 0;
_node = Push(null, XmlNodeType.Document, null);
_node.IsEmpty = false;
_sb = new StringBuilder();
_name = new StringBuilder();
_poptodepth = 0;
_current = null;
_partial = '\0';
_endTag = null;
_a = null;
_apos = 0;
_newnode = null;
_poptodepth = 0;
_rootCount = 0;
}
示例10: Init
private void Init()
{
this.m_state = State.Initial;
this.m_stack = new HWStack(10);
this.m_node = Push(null, XmlNodeType.Document, null);
this.m_node.IsEmpty = false;
this.m_sb = new StringBuilder();
this.m_name = new StringBuilder();
this.m_poptodepth = 0;
this.m_current = null;
this.m_partial = '\0';
this.m_endTag = null;
this.m_a = null;
this.m_apos = 0;
this.m_newnode = null;
this.m_rootCount = 0;
this.m_foundRoot = false;
this.unknownNamespaces.Clear();
}
示例11: Grow
void Grow()
{
int inc = 10;
int newsize = _size+inc;
Node[] narray = new Node[newsize];
Array.Copy(_stack, narray, _size);
_size = newsize;
_stack = narray;
}
示例12: CopyAttributes
public void CopyAttributes(Node n)
{
for (int i = 0; i < n._attcount; i++) {
Attribute a = n._attributes[i];
Attribute na = this.AddAttribute(a.Name, a.Value, a.QuoteChar);
na.DtdType = a.DtdType;
}
}
示例13: Push
Node Push(string name, XmlNodeType nt, string value)
{
if (_depth == _size) Grow();
Node result;
if (_stack[_depth] == null) {
result = new Node(name, nt, value);
_stack[_depth] = result;
}
else {
result = _stack[_depth];
result.Reset(name, nt, value);
}
_depth++;
_node = result;
return result;
}
示例14: Push
Node Push(string name, XmlNodeType nt, string value) {
Node result = (Node)this.stack.Push();
if (result == null) {
result = new Node();
this.stack[this.stack.Count-1] = result;
}
result.Reset(name, nt, value);
this.node = result;
return result;
}
示例15: ValidateContent
private void ValidateContent(Node node)
{
if (node.NodeType == XmlNodeType.Element)
{
if (!VerifyName(node.Name))
{
Pop();
Push(null, XmlNodeType.Text, "<" + node.Name + ">");
return;
}
}
if (this.m_dtd != null)
{
// See if this element is allowed inside the current element.
// If it isn't, then auto-close elements until we find one
// that it is allowed to be in.
string name = node.Name.ToUpperInvariant(); // DTD is in upper case
int i = 0;
int top = this.m_stack.Count - 2;
if (node.DtdType != null) {
// it is a known element, let's see if it's allowed in the
// current context.
for (i = top; i > 0; i--)
{
Node n = (Node)this.m_stack[i];
if (n.IsEmpty)
continue; // we'll have to pop this one
ElementDecl f = n.DtdType;
if (f != null)
{
if ((i == 2) && string.Equals(f.Name, "BODY", StringComparison.OrdinalIgnoreCase)) // NOTE (steveb): never close the BODY tag too early
break;
else if (string.Equals(f.Name, this.m_dtd.Name, StringComparison.OrdinalIgnoreCase))
break; // can't pop the root element.
else if (f.CanContain(name, this.m_dtd))
{
break;
}
else if (!f.EndTagOptional)
{
// If the end tag is not optional then we can't
// auto-close it. We'll just have to live with the
// junk we've found and move on.
break;
}
}
else
{
// Since we don't understand this tag anyway,
// we might as well allow this content!
break;
}
}
}
if (i == 0)
{
// Tag was not found or is not allowed anywhere, ignore it and
// continue on.
return;
}
else if (i < top)
{
Node n = (Node)this.m_stack[top];
if (i == top - 1 && string.Equals(name, n.Name, StringComparison.OrdinalIgnoreCase))
{
// e.g. p not allowed inside p, not an interesting error.
}
else
{
#if DEBUG
string closing = "";
for (int k = top; k >= i+1; k--) {
if (closing != "") closing += ",";
Node n2 = (Node)this.m_stack[k];
closing += "<" + n2.Name + ">";
}
Log("Element '{0}' not allowed inside '{1}', closing {2}.", name, n.Name, closing);
#endif
}
this.m_state = State.AutoClose;
this.m_newnode = node;
Pop(); // save this new node until we pop the others
this.m_poptodepth = i + 1;
}
}
}