本文整理汇总了C#中System.Char.IsXmlName方法的典型用法代码示例。如果您正苦于以下问题:C# Char.IsXmlName方法的具体用法?C# Char.IsXmlName怎么用?C# Char.IsXmlName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Char
的用法示例。
在下文中一共展示了Char.IsXmlName方法的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: ProcessingTarget
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#sec-pi.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="pi">The processing instruction token.</param>
XmlToken ProcessingTarget(Char c, XmlPIToken pi)
{
while (c.IsXmlName())
{
_stringBuffer.Append(c);
c = GetNext();
}
pi.Target = FlushBuffer();
if (pi.Target.Isi(TagNames.Xml))
throw XmlParseError.XmlInvalidPI.At(GetCurrentPosition());
if (c == Symbols.QuestionMark)
{
c = GetNext();
if (c == Symbols.GreaterThan)
return pi;
}
else if (c.IsSpaceCharacter())
return ProcessingContent(GetNext(), pi);
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: DoctypeName
/// <summary>
/// See 8.2.4.54 DOCTYPE name state
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="doctype">The current doctype token.</param>
/// <returns>The emitted token.</returns>
XmlToken DoctypeName(Char c, XmlDoctypeToken doctype)
{
while (c.IsXmlName())
{
_stringBuffer.Append(c);
c = GetNext();
}
doctype.Name = FlushBuffer();
if (c == Symbols.GreaterThan)
return doctype;
else if (c.IsSpaceCharacter())
return DoctypeNameAfter(GetNext(), doctype);
throw XmlParseError.DoctypeInvalid.At(GetCurrentPosition());
}
示例7: TagName
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#NT-Name.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="tag">The current tag token.</param>
/// <returns>The emitted token.</returns>
XmlToken TagName(Char c, XmlTagToken tag)
{
while (c.IsXmlName())
{
_stringBuffer.Append(c);
c = _src.Next;
}
tag.Name = _stringBuffer.ToString();
if (c == Specification.EOF)
throw Errors.Xml(ErrorCode.EOF);
if (c == Specification.GT)
return tag;
else if (c.IsSpaceCharacter())
return AttributeBeforeName(_src.Next, tag);
else if (c == Specification.SOLIDUS)
return TagSelfClosing(_src.Next, tag);
throw Errors.Xml(ErrorCode.XmlInvalidName);
}
示例8: EntityDeclarationAfter
DtdToken EntityDeclarationAfter(Char c, DtdEntityToken decl)
{
if (c.IsSpaceCharacter())
{
c = SkipSpaces(c);
if (decl.IsExtern && !decl.IsParameter && String.IsNullOrEmpty(decl.ExternNotation) && _stream.ContinuesWith(NDATA))
{
_stream.Advance(4);
c = _stream.Next;
while (c.IsSpaceCharacter())
c = _stream.Next;
if (c.IsXmlNameStart())
{
_stringBuffer.Clear();
do
{
_stringBuffer.Append(c);
c = _stream.Next;
}
while (c.IsXmlName());
decl.ExternNotation = _stringBuffer.ToString();
return EntityDeclarationAfter(c, decl);
}
throw Errors.Xml(ErrorCode.DtdEntityInvalid);
}
}
if (c == Specification.EOF)
throw Errors.Xml(ErrorCode.EOF);
else if (c == Specification.GT)
return decl;
throw Errors.Xml(ErrorCode.DtdEntityInvalid);
}
示例9: AttributeDeclarationName
AttributeDeclarationEntry AttributeDeclarationName(Char c)
{
var value = new AttributeDeclarationEntry();
do
{
_stringBuffer.Append(c);
c = _stream.Next;
}
while (c.IsXmlName());
if (!c.IsSpaceCharacter())
throw Errors.Xml(ErrorCode.DtdAttListInvalid);
value.Name = _stringBuffer.ToString();
_stringBuffer.Clear();
return AttributeDeclarationType(_stream.Next, value);
}
示例10: ProcessingTarget
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#sec-pi.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="pi">The processing instruction token.</param>
DtdToken ProcessingTarget(Char c, DtdPIToken pi)
{
while (c.IsXmlName())
{
_stringBuffer.Append(c);
c = _stream.Next;
}
pi.Target = _stringBuffer.ToString();
_stringBuffer.Clear();
if (String.Compare(pi.Target, Tags.XML, StringComparison.OrdinalIgnoreCase) == 0)
return TextDecl(c);
if (c == Specification.QM)
{
c = _stream.Next;
if(c == Specification.GT)
return pi;
}
else if (c.IsSpaceCharacter())
return ProcessingContent(_stream.Next, pi);
throw Errors.Xml(ErrorCode.XmlInvalidPI);
}
示例11: DeclarationName
Boolean DeclarationName(Char c, DtdToken decl)
{
while (c.IsXmlName())
{
_stringBuffer.Append(c);
c = _stream.Next;
}
if (c == Specification.PERCENT)
{
PEReference(_stream.Next);
return DeclarationName(_stream.Current, decl);
}
decl.Name = _stringBuffer.ToString();
_stringBuffer.Clear();
if (c == Specification.EOF)
throw Errors.Xml(ErrorCode.EOF);
return c.IsSpaceCharacter();
}
示例12: DoctypeName
/// <summary>
/// See 8.2.4.54 DOCTYPE name state
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="doctype">The current doctype token.</param>
/// <returns>The emitted token.</returns>
XmlToken DoctypeName(Char c, XmlDoctypeToken doctype)
{
while (c.IsXmlName())
{
_stringBuffer.Append(c);
c = _src.Next;
}
doctype.Name = _stringBuffer.ToString();
_stringBuffer.Clear();
if (c == Specification.GT)
return doctype;
else if(c.IsSpaceCharacter())
return DoctypeNameAfter(_src.Next, 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: AttributeName
/// <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 AttributeName(Char c, XmlTagToken tag)
{
while (c.IsXmlName())
{
_stringBuffer.Append(c);
c = _src.Next;
}
var name = _stringBuffer.ToString();
if(!String.IsNullOrEmpty(tag.GetAttribute(name)))
throw Errors.Xml(ErrorCode.XmlUniqueAttribute);
tag.AddAttribute(name);
if (c.IsSpaceCharacter())
{
do c = _src.Next;
while (c.IsSpaceCharacter());
}
if (c == Specification.EQ)
return AttributeBeforeValue(_src.Next, tag);
throw Errors.Xml(ErrorCode.XmlInvalidAttribute);
}
示例15: TagEnd
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#dt-etag.
/// </summary>
/// <param name="c">The next input character.</param>
XmlToken TagEnd(Char c)
{
if (c.IsXmlNameStart())
{
do
{
_stringBuffer.Append(c);
c = GetNext();
}
while (c.IsXmlName());
while (c.IsSpaceCharacter())
c = GetNext();
if (c == Symbols.GreaterThan)
{
var tag = NewCloseTag();
tag.Name = FlushBuffer();
return tag;
}
}
if (c == Symbols.EndOfFile)
throw XmlParseError.EOF.At(GetCurrentPosition());
throw XmlParseError.XmlInvalidEndTag.At(GetCurrentPosition());
}