/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-EncodingDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationEncodingValueDQ(Char c, XmlDeclarationToken decl) { while (c != Specification.EOF && c != Specification.DQ) { stringBuffer.Append(c); c = src.Next; } if (c == Specification.EOF) { RaiseErrorOccurred(ErrorCode.EOF); return XmlToken.EOF; } decl.Encoding = stringBuffer.ToString(); return DeclarationAfterEncoding(src.Next, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-SDDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationAfterEncoding(Char c, XmlDeclarationToken decl) { while (Specification.IsSpaceCharacter(c)) c = src.Next; if (src.ContinuesWith("standalone", false)) { src.Advance(9); return DeclarationStandaloneAfterName(src.Next, decl); } return DeclarationEnd(c, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionInfo. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationVersionValueSQ(Char c, XmlDeclarationToken decl) { while (c != Specification.EOF && c != Specification.SQ) { stringBuffer.Append(c); c = src.Next; } if (c == Specification.EOF) { RaiseErrorOccurred(ErrorCode.EOF); return XmlToken.EOF; } decl.Version = stringBuffer.ToString(); return DeclarationAfterVersion(src.Next, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionNum. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationAfterVersion(Char c, XmlDeclarationToken decl) { while (Specification.IsSpaceCharacter(c)) c = src.Next; if (src.ContinuesWith("encoding", false)) { src.Advance(7); return DeclarationEncodingAfterName(src.Next, decl); } return DeclarationEnd(c, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-EncodingDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationEncodingBeforeValue(Char c, XmlDeclarationToken decl) { while (c.IsSpaceCharacter()) c = _src.Next; if (c == Specification.DQ || c == Specification.SQ) { var q = c; _stringBuffer.Clear(); c = _src.Next; if (c.IsLetter()) return DeclarationEncodingValue(c, q, decl); } throw Errors.Xml(ErrorCode.XmlDeclarationInvalid); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionInfo. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationVersionBeforeValue(Char c, XmlDeclarationToken decl) { while (c.IsSpaceCharacter()) c = _src.Next; if (c == Specification.DQ) { _stringBuffer.Clear(); return DeclarationVersionValueDQ(_src.Next, decl); } else if(c == Specification.SQ) { _stringBuffer.Clear(); return DeclarationVersionValueSQ(_src.Next, decl); } throw new ArgumentException("Invalid XML declaration."); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionInfo. /// </summary> /// <param name="c">The next input character.</param> /// <param name="q">The quote character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationVersionValue(Char c, Char q, XmlDeclarationToken decl) { while (c != q) { if (c == Specification.EOF) throw Errors.Xml(ErrorCode.EOF); _stringBuffer.Append(c); c = _src.Next; } decl.Version = _stringBuffer.ToString(); c = _src.Next; if (c.IsSpaceCharacter()) return DeclarationAfterVersion(c, decl); return DeclarationEnd(c, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-SDDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationStandaloneValueDQ(Char c, XmlDeclarationToken decl) { while (c != Specification.EOF && c != Specification.DQ) { stringBuffer.Append(c); c = src.Next; } if (c == Specification.EOF) { RaiseErrorOccurred(ErrorCode.EOF); return XmlToken.EOF; } var s = stringBuffer.ToString(); if (s.Equals("yes")) decl.Standalone = true; else if (s.Equals("no")) decl.Standalone = false; else throw new ArgumentException("Invalid XML declaration."); return DeclarationEnd(src.Next, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionInfo. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationVersionAfterName(Char c, XmlDeclarationToken decl) { while (c.IsSpaceCharacter()) c = _src.Next; if (c == Specification.EQ) return DeclarationVersionBeforeValue(_src.Next, decl); throw Errors.Xml(ErrorCode.XmlDeclarationInvalid); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionInfo. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationVersionBeforeValue(Char c, XmlDeclarationToken decl) { while (c.IsSpaceCharacter()) c = _src.Next; if (c == Specification.DQ || c == Specification.SQ) { _stringBuffer.Clear(); return DeclarationVersionValue(_src.Next, c, decl); } throw Errors.Xml(ErrorCode.XmlDeclarationInvalid); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-SDDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="q">The quote character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationStandaloneValue(Char c, Char q, XmlDeclarationToken decl) { while (c != q) { if (c == Specification.EOF) throw Errors.Xml(ErrorCode.EOF); _stringBuffer.Append(c); c = _src.Next; } var s = _stringBuffer.ToString(); if (s.Equals(YES)) decl.Standalone = true; else if (s.Equals(NO)) decl.Standalone = false; else throw Errors.Xml(ErrorCode.XmlDeclarationInvalid); return DeclarationEnd(_src.Next, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-XMLDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlDeclarationToken DeclarationEnd(Char c, XmlDeclarationToken decl) { while (c.IsSpaceCharacter()) c = _src.Next; if (c != Specification.QM || _src.Next != Specification.GT) throw Errors.Xml(ErrorCode.XmlDeclarationInvalid); return decl; }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-EncodingDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="q">The quote character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationEncodingValue(Char c, Char q, XmlDeclarationToken decl) { do { if (c.IsAlphanumericAscii() || c == Specification.DOT || c == Specification.UNDERSCORE || c == Specification.MINUS) { _stringBuffer.Append(c); c = _src.Next; } else throw Errors.Xml(ErrorCode.XmlDeclarationInvalid); } while (c != q); decl.Encoding = _stringBuffer.ToString(); c = _src.Next; if(c.IsSpaceCharacter()) return DeclarationAfterEncoding(c, decl); return DeclarationEnd(c, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-SDDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationStandaloneAfterName(Char c, XmlDeclarationToken decl) { while (Specification.IsSpaceCharacter(c)) c = src.Next; if (c == Specification.EQ) return DeclarationStandaloneBeforeValue(src.Next, decl); throw new ArgumentException("Invalid XML declaration."); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionNum. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationAfterVersion(Char c, XmlDeclarationToken decl) { while (c.IsSpaceCharacter()) c = _src.Next; if (_src.ContinuesWith("encoding", false)) { _src.Advance(7); return DeclarationEncodingAfterName(_src.Next, decl); } else if (_src.ContinuesWith("standalone", false)) { _src.Advance(9); return DeclarationStandaloneAfterName(_src.Next, decl); } return DeclarationEnd(c, decl); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-SDDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationStandaloneBeforeValue(Char c, XmlDeclarationToken decl) { while (Specification.IsSpaceCharacter(c)) c = src.Next; if (c == Specification.DQ) { stringBuffer.Clear(); return DeclarationStandaloneValueDQ(src.Next, decl); } else if (c == Specification.SQ) { stringBuffer.Clear(); return DeclarationStandaloneValueSQ(src.Next, decl); } throw new ArgumentException("Invalid XML declaration."); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionInfo. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationVersionAfterName(Char c, XmlDeclarationToken decl) { while (c.IsSpaceCharacter()) c = _src.Next; if (c == Specification.EQ) return DeclarationVersionBeforeValue(_src.Next, decl); throw new ArgumentException("Invalid XML declaration."); }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-XMLDecl. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlDeclarationToken DeclarationEnd(Char c, XmlDeclarationToken decl) { while (Specification.IsSpaceCharacter(c)) c = src.Next; if (c != Specification.QM || src.Next != Specification.GT) throw new ArgumentException("Invalid XML declaration."); return decl; }
/// <summary> /// More http://www.w3.org/TR/REC-xml/#NT-VersionNum. /// </summary> /// <param name="c">The next input character.</param> /// <param name="decl">The current declaration token.</param> XmlToken DeclarationAfterVersion(Char c, XmlDeclarationToken decl) { while (c.IsSpaceCharacter()) c = _src.Next; if (_src.ContinuesWith(AttributeNames.ENCODING, false)) { _src.Advance(7); return DeclarationEncodingAfterName(_src.Next, decl); } else if (_src.ContinuesWith(AttributeNames.STANDALONE, false)) { _src.Advance(9); return DeclarationStandaloneAfterName(_src.Next, decl); } return DeclarationEnd(c, decl); }