本文整理汇总了C#中System.Char.IsXmlNameStart方法的典型用法代码示例。如果您正苦于以下问题:C# Char.IsXmlNameStart方法的具体用法?C# Char.IsXmlNameStart怎么用?C# Char.IsXmlNameStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Char
的用法示例。
在下文中一共展示了Char.IsXmlNameStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CharacterReference
/// <summary>
/// Called once an & character is being seen.
/// </summary>
/// <param name="c">The next character after the & character.</param>
/// <returns>The entity token.</returns>
String CharacterReference(Char c)
{
var start = _stringBuffer.Length;
var hex = false;
var numeric = c == Symbols.Num;
if (numeric)
{
c = GetNext();
hex = c == 'x' || c == 'X';
if (hex)
{
c = GetNext();
while (c.IsHex())
{
_stringBuffer.Append(c);
c = GetNext();
}
}
else
{
while (c.IsDigit())
{
_stringBuffer.Append(c);
c = GetNext();
}
}
}
else if (c.IsXmlNameStart())
{
do
{
_stringBuffer.Append(c);
c = GetNext();
}
while (c.IsXmlName());
}
if (c == Symbols.Semicolon && _stringBuffer.Length > start)
{
var length = _stringBuffer.Length - start;
var content = _stringBuffer.ToString(start, length);
_stringBuffer.Remove(start, length);
if (numeric)
{
var number = numeric ? content.FromHex() : content.FromDec();
if (!number.IsValidAsCharRef())
throw XmlParseError.CharacterReferenceInvalidNumber.At(_position);
return number.ConvertFromUtf32();
}
else
{
var entity = _resolver.GetSymbol(content);
if (String.IsNullOrEmpty(entity))
throw XmlParseError.CharacterReferenceInvalidCode.At(_position);
return entity;
}
}
throw XmlParseError.CharacterReferenceNotTerminated.At(GetCurrentPosition());
}
示例2: EReference
protected String EReference(Char c)
{
var buffer = Pool.NewStringBuilder();
if (c.IsXmlNameStart())
{
do
{
buffer.Append(c);
c = _stream.Next;
}
while (c.IsXmlName());
var temp = buffer.ToPool();
if (temp.Length > 0 && c == Specification.SC)
{
var p = _container.GetEntity(temp);
if (p != null)
return p.NodeValue;
}
}
else if (c == Specification.NUM)
{
c = _src.Next;
var hex = c == 'x' || c == 'X';
if (hex)
c = _stream.Next;
while (hex ? c.IsHex() : c.IsDigit())
{
buffer.Append(c);
c = _src.Next;
}
var temp = buffer.ToPool();
if (temp.Length > 0 && c == Specification.SC)
{
var num = hex ? temp.FromHex() : temp.FromDec();
if (num.IsValidAsCharRef())
return Char.ConvertFromUtf32(num);
throw Errors.Xml(ErrorCode.CharacterReferenceInvalidNumber);
}
}
throw Errors.Xml(ErrorCode.CharacterReferenceNotTerminated);
}
示例3: ProcessingStart
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#sec-pi.
/// </summary>
/// <param name="c">The next input character.</param>
XmlToken ProcessingStart(Char c)
{
if (c.IsXmlNameStart())
{
_stringBuffer.Append(c);
return ProcessingTarget(GetNext(), NewProcessing());
}
throw XmlParseError.XmlInvalidPI.At(GetCurrentPosition());
}
示例4: CharacterReference
/// <summary>
/// Called once an & character is being seen.
/// </summary>
/// <param name="c">The next character after the & character.</param>
/// <returns>The entity token.</returns>
XmlEntityToken CharacterReference(Char c)
{
if (c == Symbols.Num)
{
c = GetNext();
var isHex = c == 'x' || c == 'X';
if (isHex)
{
c = GetNext();
while (c.IsHex())
{
_stringBuffer.Append(c);
c = GetNext();
}
}
else
{
while (c.IsDigit())
{
_stringBuffer.Append(c);
c = GetNext();
}
}
if (_stringBuffer.Length > 0 && c == Symbols.Semicolon)
return NewEntity(numeric: true, hex: isHex);
}
else if (c.IsXmlNameStart())
{
do
{
_stringBuffer.Append(c);
c = GetNext();
}
while (c.IsXmlName());
if (c == Symbols.Semicolon)
return NewEntity();
}
throw XmlParseError.CharacterReferenceNotTerminated.At(GetCurrentPosition());
}
示例5: PEReference
protected void PEReference(Char c, Boolean use = true)
{
var buffer = Pool.NewStringBuilder();
if (c.IsXmlNameStart())
{
do
{
buffer.Append(c);
c = _stream.Next;
}
while (c.IsXmlName());
var temp = buffer.ToPool();
if (c == Specification.SC)
{
var p = _container.GetParameter(temp);
if (p != null)
{
if (use)
{
_stream.Push(temp, p.NodeValue);
return;
}
else
throw Errors.Xml(ErrorCode.DtdPEReferenceInvalid);
}
}
}
if (use)
throw Errors.Xml(ErrorCode.DtdPEReferenceInvalid);
_stringBuffer.Append(Specification.PERCENT).Append(buffer.ToString());
}
示例6: DoctypeNameBefore
/// <summary>
/// See 8.2.4.53 Before DOCTYPE name state
/// </summary>
/// <param name="c">The next input character.</param>
XmlToken DoctypeNameBefore(Char c)
{
while (c.IsSpaceCharacter())
c = GetNext();
if (c.IsXmlNameStart())
{
_stringBuffer.Append(c);
return DoctypeName(GetNext(), NewDoctype());
}
throw XmlParseError.DoctypeInvalid.At(GetCurrentPosition());
}
示例7: TagOpen
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#sec-starttags.
/// </summary>
/// <param name="c">The next input character.</param>
XmlToken TagOpen(Char c)
{
if (c == Specification.EM)
return MarkupDeclaration(_src.Next);
if (c == Specification.QM)
{
c = _src.Next;
if (_src.ContinuesWith(Tags.XML, false))
{
_src.Advance(2);
return DeclarationStart(_src.Next);
}
return ProcessingStart(c);
}
if (c == Specification.SOLIDUS)
return TagEnd(_src.Next);
if (c.IsXmlNameStart())
{
_stringBuffer.Clear();
_stringBuffer.Append(c);
return TagName(_src.Next, XmlToken.OpenTag());
}
throw Errors.Xml(ErrorCode.XmlInvalidStartTag);
}
示例8: ProcessingStart
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#sec-pi.
/// </summary>
/// <param name="c">The next input character.</param>
DtdToken ProcessingStart(Char c)
{
if (c.IsXmlNameStart())
{
_stringBuffer.Clear();
_stringBuffer.Append(c);
return ProcessingTarget(_stream.Next, new DtdPIToken());
}
throw Errors.Xml(ErrorCode.XmlInvalidPI);
}
示例9: DeclarationNameBefore
Boolean DeclarationNameBefore(Char c, DtdToken decl)
{
while (c.IsSpaceCharacter())
c = _stream.Next;
if (c == Specification.EOF)
throw Errors.Xml(ErrorCode.EOF);
if (c == Specification.PERCENT)
{
PEReference(_stream.Next);
return DeclarationNameBefore(_stream.Current, decl);
}
if (c.IsXmlNameStart())
{
_stringBuffer.Clear();
_stringBuffer.Append(c);
return DeclarationName(_stream.Next, decl);
}
return false;
}
示例10: TypeDeclarationChildren
ElementChildrenDeclarationEntry TypeDeclarationChildren(Char c)
{
var entries = new List<ElementQuantifiedDeclarationEntry>();
var connection = Specification.NULL;
while (true)
{
if (entries.Count > 0)
{
if (c != Specification.PIPE && c != Specification.COMMA)
throw Errors.Xml(ErrorCode.DtdTypeContent);
if (entries.Count == 1)
connection = c;
else if (connection != c)
throw Errors.Xml(ErrorCode.DtdTypeContent);
c = _stream.Next;
}
while (c.IsSpaceCharacter())
c = _stream.Next;
if (c.IsXmlNameStart())
{
var name = TypeDeclarationName(c);
entries.Add(name);
}
else if (c == Specification.RBO)
entries.Add(TypeDeclarationChildren(_stream.Next));
else
throw Errors.Xml(ErrorCode.DtdTypeContent);
c = _stream.Current;
while (c.IsSpaceCharacter())
c = _stream.Next;
if (c == Specification.RBC)
break;
}
c = _stream.Next;
if (entries.Count == 0)
throw Errors.Xml(ErrorCode.DtdTypeInvalid);
if (connection == Specification.COMMA)
{
var sequence = new ElementSequenceDeclarationEntry();
sequence.Sequence.AddRange(entries);
sequence.Quantifier = TypeDeclarationQuantifier(c);
return sequence;
}
else
{
var choice = new ElementChoiceDeclarationEntry();
choice.Choice.AddRange(entries);
choice.Quantifier = TypeDeclarationQuantifier(c);
return choice;
}
}
示例11: TypeDeclarationMixed
ElementMixedDeclarationEntry TypeDeclarationMixed(Char c)
{
var entry = new ElementMixedDeclarationEntry();
while (true)
{
while (c.IsSpaceCharacter())
c = _stream.Next;
if (c == Specification.RBC)
{
c = _stream.Next;
if (c == Specification.ASTERISK)
{
entry.Quantifier = ElementQuantifier.ZeroOrMore;
_stream.Advance();
return entry;
}
if (entry.Names.Count == 0)
break;
}
else if (c == Specification.PIPE)
{
c = _stream.Next;
while (c.IsSpaceCharacter())
c = _stream.Next;
_stringBuffer.Clear();
if (c.IsXmlNameStart())
{
_stringBuffer.Append(c);
while ((c = _stream.Next).IsXmlName())
_stringBuffer.Append(c);
entry.Names.Add(_stringBuffer.ToString());
continue;
}
}
throw Errors.Xml(ErrorCode.DtdTypeContent);
}
return entry;
}
示例12: DoctypeNameBefore
/// <summary>
/// See 8.2.4.53 Before DOCTYPE name state
/// </summary>
/// <param name="c">The next input character.</param>
XmlToken DoctypeNameBefore(Char c)
{
while (c.IsSpaceCharacter())
c = _src.Next;
if (c.IsXmlNameStart())
{
_stringBuffer.Clear();
_stringBuffer.Append(c);
return DoctypeName(_src.Next, XmlToken.Doctype());
}
throw Errors.Xml(ErrorCode.DoctypeInvalid);
}
示例13: CharacterReference
/// <summary>
/// Called once an & character is being seen.
/// </summary>
/// <param name="c">The next character after the & character.</param>
/// <returns>The entity token.</returns>
XmlEntityToken CharacterReference(Char c)
{
var buffer = Pool.NewStringBuilder();
if (c == Specification.NUM)
{
c = _src.Next;
var hex = c == 'x' || c == 'X';
if (hex)
{
c = _src.Next;
while (c.IsHex())
{
buffer.Append(c);
c = _src.Next;
}
}
else
{
while (c.IsDigit())
{
buffer.Append(c);
c = _src.Next;
}
}
if (buffer.Length > 0 && c == Specification.SC)
return new XmlEntityToken { Value = buffer.ToPool(), IsNumeric = true, IsHex = hex };
}
else if (c.IsXmlNameStart())
{
do
{
buffer.Append(c);
c = _src.Next;
}
while (c.IsXmlName());
if (c == Specification.SC)
return new XmlEntityToken { Value = buffer.ToPool() };
}
buffer.ToPool();
throw Errors.Xml(ErrorCode.CharacterReferenceNotTerminated);
}
示例14: AttributeBeforeName
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#NT-Attribute.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="tag">The current tag token.</param>
XmlToken AttributeBeforeName(Char c, XmlTagToken tag)
{
while (c.IsSpaceCharacter())
c = _src.Next;
if (c == Specification.SOLIDUS)
return TagSelfClosing(_src.Next, tag);
else if (c == Specification.GT)
return tag;
else if (c == Specification.EOF)
throw Errors.Xml(ErrorCode.EOF);
if (c.IsXmlNameStart())
{
_stringBuffer.Clear();
_stringBuffer.Append(c);
return AttributeName(_src.Next, tag);
}
throw Errors.Xml(ErrorCode.XmlInvalidAttribute);
}
示例15: TagOpen
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#sec-starttags.
/// </summary>
/// <param name="c">The next input character.</param>
XmlToken TagOpen(Char c)
{
if (c == Symbols.ExclamationMark)
return MarkupDeclaration(GetNext());
if (c == Symbols.QuestionMark)
{
c = GetNext();
if (ContinuesWithSensitive(TagNames.Xml))
{
Advance(2);
return DeclarationStart(GetNext());
}
return ProcessingStart(c);
}
if (c == Symbols.Solidus)
return TagEnd(GetNext());
if (c.IsXmlNameStart())
{
_stringBuffer.Append(c);
return TagName(GetNext(), NewOpenTag());
}
throw XmlParseError.XmlInvalidStartTag.At(GetCurrentPosition());
}