1 write to ps
System.Xml (1)
System\Xml\Core\XmlTextReaderImpl.cs (1)
7301
ps
= parsingStatesStack[ parsingStatesStackTop-- ];
1682 references to ps
System.Xml (1682)
System\Xml\Core\XmlTextReaderImpl.cs (1011)
390
ps
.lineNo = 1;
391
ps
.lineStartPos = -1;
453
ps
.lineNo = lineNumberOffset + 1;
454
ps
.lineStartPos = - linePositionOffset - 1;
455
curNode.SetLineInfo(
ps
.LineNo - 1,
ps
.LinePos - 1 );
507
reportedBaseUri =
ps
.baseUriStr;
508
reportedEncoding =
ps
.encoding;
523
reportedEncoding =
ps
.encoding;
547
reportedBaseUri =
ps
.baseUriStr;
548
reportedEncoding =
ps
.encoding;
569
reportedEncoding =
ps
.encoding;
611
ps
.baseUri = GetTempResolver().ResolveUri(null, url);
612
ps
.baseUriStr =
ps
.baseUri.ToString();
613
reportedBaseUri =
ps
.baseUriStr;
693
reportedEncoding =
ps
.encoding;
761
reportedEncoding =
ps
.encoding;
807
reportedEncoding =
ps
.encoding;
825
reportedBaseUri =
ps
.baseUriStr;
826
reportedEncoding =
ps
.encoding;
1174
Debug.Assert( !
ps
.appendMode );
1182
reportedEncoding =
ps
.encoding;
1185
reportedEncoding =
ps
.encoding;
1223
reportedEncoding =
ps
.encoding;
1224
reportedBaseUri =
ps
.baseUriStr;
1230
curNode.SetLineInfo(
ps
.lineNo,
ps
.LinePos );
1231
reportedEncoding =
ps
.encoding;
1232
reportedBaseUri =
ps
.baseUriStr;
1401
attributeValueBaseEntityId =
ps
.entityId;
1409
if (
ps
.entityId == attributeValueBaseEntityId ) {
1442
if (
ps
.charsUsed -
ps
.charPos == 0 ) { // entity value == ""
1460
if (
ps
.charsUsed -
ps
.charPos == 0 && !
ps
.entity.IsExternal ) { // empty internal entity value
1476
ps
.entityResolvedManually = true;
1787
BlockCopyChars(
ps
.chars, startPos, buffer, ( index + readCount ), copyCount );
1807
curNode.SetValue(
ps
.chars, startPos, endPos - startPos );
1906
if (
ps
.entity == null ||
ps
.entity.IsExternal ) {
1907
ps
.eolNormalized = !value;
1979
ps
.baseUri = null;
2037
stringBuilder.Append(
ps
.chars, incReadLeftStartPos, incReadLeftEndPos - incReadLeftStartPos );
2046
ps
.appendMode = false;
2048
stringBuilder.Append(
ps
.chars,
ps
.charPos,
ps
.charsUsed -
ps
.charPos );
2049
ps
.charPos =
ps
.charsUsed;
2205
if (
ps
.baseUriStr.Length > 0 &&
ps
.baseUri == null && xmlResolver != null ) {
2206
ps
.baseUri = xmlResolver.ResolveUri( null,
ps
.baseUriStr );
2208
return
ps
.baseUri;
2214
return
ps
.isEof;
2220
return
ps
.chars;
2226
return
ps
.charsUsed;
2232
return
ps
.charPos;
2235
Debug.Assert( value >= 0 && value <=
ps
.charsUsed );
2236
ps
.charPos = value;
2248
return
ps
.eolNormalized;
2269
return
ps
.LineNo;
2275
return
ps
.lineStartPos;
2326
if ( e.ResString == Res.Xml_UnexpectedEOF &&
ps
.entity != null ) {
2327
SendValidationEvent( XmlSeverityType.Error, Res.Sch_ParEntityRefNesting, null,
ps
.LineNo,
ps
.LinePos );
2368
entityId =
ps
.entityId;
2378
oldEntity =
ps
.entity;
2380
newEntityId =
ps
.entityId;
2397
if (
ps
.baseUri == null && !string.IsNullOrEmpty(
ps
.baseUriStr)) {
2398
ps
.baseUri = xmlResolver.ResolveUri(null,
ps
.baseUriStr);
2400
PushExternalEntityOrSubset( publicId, systemId,
ps
.baseUri, null );
2402
ps
.entity = null;
2403
ps
.entityId = 0;
2405
Debug.Assert(
ps
.appendMode );
2406
int initialPos =
ps
.charPos;
2411
ps
.charPos = initialPos;
2426
ps
.entity = null;
2427
ps
.entityId = 0;
2428
ps
.eolNormalized = false;
2453
ps
.charPos = pos;
2458
ps
.charPos = pos;
2463
ps
.charPos = pos;
2472
Throw( new XmlException( res, string.Empty, lineNo, linePos,
ps
.baseUriStr ) );
2476
Throw( new XmlException( res, arg,
ps
.LineNo,
ps
.LinePos,
ps
.baseUriStr ) );
2480
Throw( new XmlException( res, arg, lineNo, linePos,
ps
.baseUriStr ) );
2484
Throw( new XmlException( res, args,
ps
.LineNo,
ps
.LinePos,
ps
.baseUriStr ) );
2492
Throw( new XmlException( res, args, innerException,
ps
.LineNo,
ps
.LinePos,
ps
.baseUriStr ) );
2505
Throw( new XmlException( e.Message, (Exception)null, lineNo, linePos,
ps
.baseUriStr ) );
2509
Throw( new XmlException( res, string.Empty,
ps
.baseUriStr ) );
2513
Throw( new XmlException( res, arg,
ps
.baseUriStr ) );
2517
Throw( new XmlException( res, args, innerException, 0, 0,
ps
.baseUriStr ) );
2531
SendValidationEvent( severity, new XmlSchemaException( code, arg,
ps
.baseUriStr, lineNo, linePos ) );
2562
while (
ps
.entityId != attributeValueBaseEntityId ) {
2602
Debug.Assert(
ps
.charPos == 0 &&
ps
.charsUsed == 0 &&
ps
.textReader == null );
2606
ps
.stream = stream;
2607
ps
.baseUri = baseUri;
2608
ps
.baseUriStr = baseUriStr;
2613
ps
.bytes = bytes;
2614
ps
.bytesUsed = byteCount;
2615
bufferSize =
ps
.bytes.Length;
2629
if (
ps
.bytes == null ||
ps
.bytes.Length < bufferSize ) {
2630
ps
.bytes = new byte[ bufferSize ];
2635
if (
ps
.chars == null ||
ps
.chars.Length < bufferSize + 1 ) {
2636
ps
.chars = new char[ bufferSize + 1 ];
2640
ps
.bytePos = 0;
2641
while (
ps
.bytesUsed < 4 &&
ps
.bytes.Length -
ps
.bytesUsed > 0 ) {
2642
int read = stream.Read(
ps
.bytes,
ps
.bytesUsed,
ps
.bytes.Length -
ps
.bytesUsed );
2644
ps
.isStreamEof = true;
2647
ps
.bytesUsed += read;
2657
byte[] preamble =
ps
.encoding.GetPreamble();
2660
for ( i = 0; i < preambleLen && i <
ps
.bytesUsed; i++ ) {
2661
if (
ps
.bytes[i] != preamble[i] ) {
2666
ps
.bytePos = preambleLen;
2669
documentStartBytePos =
ps
.bytePos;
2671
ps
.eolNormalized = !normalize;
2674
ps
.appendMode = true;
2683
Debug.Assert(
ps
.charPos == 0 &&
ps
.charsUsed == 0 &&
ps
.stream == null );
2686
ps
.textReader = input;
2687
ps
.baseUriStr = baseUriStr;
2688
ps
.baseUri = baseUri;
2690
if (
ps
.chars == null ) {
2695
ps
.chars = new char[XmlReader.AsyncBufferSize + 1];
2698
ps
.chars = new char[XmlReader.DefaultBufferSize + 1];
2703
ps
.encoding = Encoding.Unicode;
2704
ps
.eolNormalized = !normalize;
2707
ps
.appendMode = true;
2712
Debug.Assert(
ps
.stream == null &&
ps
.textReader == null );
2713
Debug.Assert(
ps
.charPos == 0 &&
ps
.charsUsed == 0 );
2717
ps
.baseUriStr = baseUriStr;
2718
ps
.baseUri = null;
2721
ps
.chars = new char[ len + 1 ];
2722
str.CopyTo( 0,
ps
.chars, 0, str.Length );
2723
ps
.charsUsed = len;
2724
ps
.chars[len] = (char)0;
2726
ps
.encoding = originalEncoding;
2728
ps
.eolNormalized = !normalize;
2729
ps
.isEof = true;
2746
ps
.baseUriStr = parserContext.BaseURI;
2747
ps
.baseUri = null;
2753
ps
.baseUriStr = string.Empty;
2754
ps
.baseUri = null;
2757
reportedBaseUri =
ps
.baseUriStr;
2761
ps
.appendMode = false;
2775
ps
.appendMode = false;
2821
if (
ps
.baseUri != null ) {
2825
ps
.baseUri = tmpResolver.ResolveUri( null, url );
2826
ps
.baseUriStr =
ps
.baseUri.ToString();
2837
if (
ps
.stream == null ) {
2838
ThrowWithoutLineInfo( Res.Xml_CannotResolveUrl,
ps
.baseUriStr );
2841
InitStreamInput(
ps
.baseUri,
ps
.baseUriStr,
ps
.stream, null );
2842
reportedEncoding =
ps
.encoding;
2847
ps
.stream = (Stream) GetTempResolver().GetEntity(
ps
.baseUri, null, typeof(Stream));
2853
Debug.Assert(
ps
.bytes != null );
2854
Debug.Assert(
ps
.bytePos == 0 );
2856
if (
ps
.bytesUsed < 2 ) {
2859
int first2Bytes =
ps
.bytes[0] << 8 |
ps
.bytes[1];
2860
int next2Bytes = (
ps
.bytesUsed >= 4 ) ? (
ps
.bytes[2] << 8 |
ps
.bytes[3] ) : 0;
2941
Debug.Assert(
ps
.charPos == 0 );
2942
ps
.encoding = Encoding.UTF8;
2943
ps
.decoder = new SafeAsciiDecoder();
2946
ps
.encoding = encoding;
2948
switch (
ps
.encoding.WebName ) { // Encoding.Codepage is not supported in Silverlight
2950
ps
.decoder = new UTF16Decoder( false );
2953
ps
.decoder = new UTF16Decoder( true );
2956
ps
.decoder = encoding.GetDecoder();
2967
if ( ( newEncoding.WebName !=
ps
.encoding.WebName ||
ps
.decoder is SafeAsciiDecoder ) && !afterResetState) {
2969
Debug.Assert(
ps
.stream != null );
2971
ps
.appendMode = false;
2981
if (
ps
.stream == null ) {
2982
return
ps
.encoding;
2989
if (
ps
.encoding.WebName != "utf-16BE" &&
2990
ps
.encoding.WebName != "utf-16" &&
3003
return
ps
.encoding;
3027
if ( afterResetState &&
ps
.encoding.WebName != newEncoding.WebName ) {
3036
Debug.Assert(
ps
.stream != null &&
ps
.decoder != null &&
ps
.bytes != null );
3037
Debug.Assert(
ps
.appendMode, "UnDecodeChars cannot be called after ps.appendMode has been changed to false" );
3039
Debug.Assert(
ps
.charsUsed >=
ps
.charPos, "The current position must be in the valid character range.");
3046
Debug.Assert(charactersInDocument >=
ps
.charsUsed -
ps
.charPos,
3048
charactersInDocument -=
ps
.charsUsed -
ps
.charPos;
3052
Debug.Assert(charactersFromEntities >=
ps
.charsUsed -
ps
.charPos,
3054
charactersFromEntities -=
ps
.charsUsed -
ps
.charPos;
3058
ps
.bytePos = documentStartBytePos; // byte position after preamble
3059
if (
ps
.charPos > 0 ) {
3060
ps
.bytePos +=
ps
.encoding.GetByteCount(
ps
.chars, 0,
ps
.charPos );
3062
ps
.charsUsed =
ps
.charPos;
3063
ps
.isEof = false;
3077
if (
ps
.isEof ) {
3082
if (
ps
.appendMode ) {
3084
if (
ps
.charsUsed ==
ps
.chars.Length - 1 ) {
3090
char[] newChars = new char[
ps
.chars.Length * 2 ];
3091
BlockCopyChars(
ps
.chars, 0, newChars, 0,
ps
.chars.Length );
3092
ps
.chars = newChars;
3095
if (
ps
.stream != null ) {
3097
if (
ps
.bytesUsed -
ps
.bytePos < MaxByteSequenceLen ) {
3098
if (
ps
.bytes.Length -
ps
.bytesUsed < MaxByteSequenceLen ) {
3099
byte[] newBytes = new byte[
ps
.bytes.Length * 2 ];
3100
BlockCopy(
ps
.bytes, 0, newBytes, 0,
ps
.bytesUsed );
3101
ps
.bytes = newBytes;
3106
charsRead =
ps
.chars.Length -
ps
.charsUsed - 1;
3112
int charsLen =
ps
.chars.Length;
3113
if ( charsLen -
ps
.charsUsed <= charsLen/2 ) {
3120
int copyCharsCount =
ps
.charsUsed -
ps
.charPos;
3122
ps
.lineStartPos =
ps
.lineStartPos -
ps
.charPos;
3124
BlockCopyChars(
ps
.chars,
ps
.charPos,
ps
.chars, 0, copyCharsCount );
3126
ps
.charPos = 0;
3127
ps
.charsUsed = copyCharsCount;
3130
char[] newChars = new char[
ps
.chars.Length * 2 ];
3131
BlockCopyChars(
ps
.chars, 0, newChars, 0,
ps
.chars.Length );
3132
ps
.chars = newChars;
3136
if (
ps
.stream != null ) {
3138
int bytesLeft =
ps
.bytesUsed -
ps
.bytePos;
3141
ps
.bytesUsed = 0;
3144
BlockCopy(
ps
.bytes,
ps
.bytePos,
ps
.bytes, 0, bytesLeft );
3145
ps
.bytesUsed = bytesLeft;
3147
ps
.bytePos = 0;
3150
charsRead =
ps
.chars.Length -
ps
.charsUsed - 1;
3153
if (
ps
.stream != null ) {
3154
if ( !
ps
.isStreamEof ) {
3156
if (
ps
.bytePos ==
ps
.bytesUsed &&
ps
.bytes.Length -
ps
.bytesUsed > 0 ) {
3157
int read =
ps
.stream.Read(
ps
.bytes,
ps
.bytesUsed,
ps
.bytes.Length -
ps
.bytesUsed );
3159
ps
.isStreamEof = true;
3161
ps
.bytesUsed += read;
3165
int originalBytePos =
ps
.bytePos;
3169
if ( charsRead == 0 &&
ps
.bytePos != originalBytePos ) {
3174
else if (
ps
.textReader != null ) {
3176
charsRead =
ps
.textReader.Read(
ps
.chars,
ps
.charsUsed,
ps
.chars.Length -
ps
.charsUsed - 1 );
3177
ps
.charsUsed += charsRead;
3186
Debug.Assert (
ps
.charsUsed <
ps
.chars.Length );
3187
ps
.isEof = true;
3189
ps
.chars[
ps
.charsUsed ] = (char)0;
3195
Debug.Assert(
ps
.stream != null &&
ps
.decoder != null &&
ps
.bytes != null );
3196
Debug.Assert( maxCharsCount <=
ps
.chars.Length -
ps
.charsUsed - 1 );
3199
int bytesCount =
ps
.bytesUsed -
ps
.bytePos;
3208
ps
.decoder.Convert(
ps
.bytes,
ps
.bytePos, bytesCount,
ps
.chars,
ps
.charsUsed, maxCharsCount, false, out bytesCount, out charsCount, out completed );
3215
ps
.bytePos += bytesCount;
3216
ps
.charsUsed += charsCount;
3229
ps
.decoder.Convert(
ps
.bytes,
ps
.bytePos + bytesDecoded, 1,
ps
.chars,
ps
.charsUsed + charsDecoded, 1, false, out bDec, out chDec, out completed );
3239
Throw(
ps
.charsUsed, Res.Xml_InvalidCharInThisEncoding );
3254
ps
.Close( closeInput );
3268
BlockCopyChars(
ps
.chars, sourcePos,
ps
.chars, destPos, count );
3273
while (
ps
.charsUsed -
ps
.charPos < 6 ) { // minimum "<?xml "
3279
if ( !XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, 5, XmlDeclarationBegining ) ||
3280
xmlCharType.IsNameSingleChar(
ps
.chars[
ps
.charPos + 5] )
3289
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos + 2 );
3292
ps
.charPos += 5;
3307
if (
ps
.chars[
ps
.charPos] == '?' ) {
3310
if (
ps
.chars[
ps
.charPos + 1] == '>' ) {
3315
ps
.charPos += 2;
3332
string encodingName =
ps
.encoding.WebName;
3334
encodingName != "utf-16BE" && !(
ps
.encoding is Ucs4Encoding ) ) {
3335
Throw( Res.Xml_EncodingSwitchAfterResetState, (
ps
.encoding.GetByteCount( "A" ) == 1 ) ? "UTF-8" : "UTF-16" );
3339
if (
ps
.decoder is SafeAsciiDecoder ) {
3346
ps
.appendMode = false;
3349
else if (
ps
.charPos + 1 ==
ps
.charsUsed ) {
3365
switch (
ps
.chars[
ps
.charPos] ) {
3367
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos, "version" ) && xmlDeclState == 0 ) {
3375
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos, "encoding" ) &&
3385
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos, "standalone" ) &&
3399
attr.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
3401
sb.Append(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos );
3402
ps
.charPos = nameEndPos;
3405
if (
ps
.chars[
ps
.charPos] != '=' ) {
3407
if (
ps
.chars[
ps
.charPos] != '=' ) {
3412
ps
.charPos++;
3414
char quoteChar =
ps
.chars[
ps
.charPos];
3417
quoteChar =
ps
.chars[
ps
.charPos];
3423
ps
.charPos++;
3426
attr.SetLineInfo2(
ps
.LineNo,
ps
.LinePos );
3430
int pos =
ps
.charPos;
3433
chars =
ps
.chars;
3446
if (
ps
.chars[pos] == quoteChar ) {
3458
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, pos -
ps
.charPos, "1.0" ) ) {
3461
attr.SetValue(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
3466
string badVersion = new string(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
3471
string encName = new string(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
3479
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, pos -
ps
.charPos, "yes" ) ) {
3482
else if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, pos -
ps
.charPos, "no" ) ) {
3487
Throw( Res.Xml_InvalidXmlDecl,
ps
.LineNo,
ps
.LinePos - 1 );
3490
attr.SetValue(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
3498
sb.Append( chars,
ps
.charPos, pos -
ps
.charPos );
3500
ps
.charPos = pos + 1;
3503
else if ( pos ==
ps
.charsUsed ) {
3516
if (
ps
.isEof || ReadData() == 0 ) {
3529
string encodingName =
ps
.encoding.WebName;
3531
encodingName != "utf-16BE" && !(
ps
.encoding is Ucs4Encoding ) ) {
3532
Throw( Res.Xml_EncodingSwitchAfterResetState, (
ps
.encoding.GetByteCount( "A" ) == 1 ) ? "UTF-8" : "UTF-16" );
3536
if (
ps
.decoder is SafeAsciiDecoder ) {
3539
ps
.appendMode = false;
3558
int pos =
ps
.charPos;
3559
char[] chars =
ps
.chars;
3564
if (
ps
.charsUsed - pos < 4 ) // minimum "<a/>"
3570
ps
.charPos = pos + 1;
3577
if (
ps
.charsUsed - pos < 2 ) // minimum characters expected "--"
3582
ps
.charPos = pos + 2;
3596
if (
ps
.charsUsed - pos < 6 ) {
3600
ps
.charPos = pos + 6;
3612
Throw(
ps
.charPos, Res.Xml_InvalidRootData );
3619
ps
.charPos = pos;
3648
ps
.charPos = pos;
3680
chars =
ps
.chars;
3681
pos =
ps
.charPos;
3687
else if ( pos ==
ps
.charsUsed || ( ( v1Compat || mangoQuirks ) && chars[pos] == 0x0 ) ) {
3708
Debug.Assert( pos ==
ps
.charsUsed && !
ps
.isEof );
3713
pos =
ps
.charPos;
3744
pos =
ps
.charPos;
3745
chars =
ps
.chars;
3753
int pos =
ps
.charPos;
3754
char[] chars =
ps
.chars;
3762
ps
.charPos = pos + 2;
3769
if (
ps
.charsUsed - pos < 2 )
3774
ps
.charPos = pos + 2;
3787
if (
ps
.charsUsed - pos < 6 ) {
3791
ps
.charPos = pos + 6;
3811
ps
.charPos = pos + 2;
3816
if ( pos+1 ==
ps
.charsUsed ) {
3821
ps
.charPos = pos + 1;
3834
if ( pos ==
ps
.charsUsed ) {
3849
if (
ps
.charsUsed -
ps
.charPos != 0 ) {
3873
Throw(
ps
.charsUsed, Res.Xml_UnexpectedEOF1 );
3891
Throw (
ps
.charsUsed, Res.Xml_UnexpectedEOFInElementContent, stringBuilder.ToString() );
3897
int pos =
ps
.charPos;
3898
char[] chars =
ps
.chars;
3901
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
3964
else if ( pos + 1 <
ps
.charsUsed ) {
3970
chars =
ps
.chars;
3979
nameTable.Add( chars,
ps
.charPos, pos -
ps
.charPos ) );
3982
int startPos =
ps
.charPos;
3993
nameTable.Add( chars,
ps
.charPos, prefixLen ),
4010
ps
.charPos = pos;
4018
ps
.charPos = pos + 1;
4023
if ( pos+1 ==
ps
.charsUsed ) {
4024
ps
.charPos = pos;
4028
pos =
ps
.charPos;
4029
chars =
ps
.chars;
4035
ps
.charPos = pos + 2;
4043
Throw( pos, Res.Xml_BadNameChar, XmlException.BuildCharExceptionArgs( chars,
ps
.charsUsed, pos ) );
4131
while (
ps
.charsUsed -
ps
.charPos < prefLen + locLen + 1 ) {
4138
char[] chars =
ps
.chars;
4140
if ( !XmlConvert.StrEqual( chars,
ps
.charPos, locLen, startTagNode.localName ) ) {
4146
int colonPos =
ps
.charPos + prefLen;
4147
if ( !XmlConvert.StrEqual( chars,
ps
.charPos, prefLen, startTagNode.prefix ) ||
4155
LineInfo endTagLineInfo = new LineInfo(
ps
.lineNo,
ps
.LinePos );
4159
pos =
ps
.charPos + nameLen;
4160
chars =
ps
.chars;
4162
if ( pos ==
ps
.charsUsed ) {
4194
else if (pos ==
ps
.charsUsed && !
ps
.isEof) {
4206
else if ( pos ==
ps
.charsUsed ) {
4229
ps
.charPos = pos + 1;
4246
args[3] = new string(
ps
.chars,
ps
.charPos, endPos -
ps
.charPos );
4257
int pos =
ps
.charPos;
4258
char[] chars =
ps
.chars;
4284
else if ( pos+1 !=
ps
.charsUsed ) {
4289
ps
.charPos = pos;
4319
ps
.charPos = pos + 1;
4326
if ( pos+1 ==
ps
.charsUsed ) {
4330
ps
.charPos = pos + 2;
4340
else if ( pos ==
ps
.charsUsed ) {
4344
Throw( pos, Res.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs( chars,
ps
.charsUsed, pos ) );
4348
if ( pos ==
ps
.charPos ) {
4351
ps
.charPos = pos;
4354
int attrNameLinePos =
ps
.LinePos;
4424
chars =
ps
.chars;
4427
else if ( pos + 1 >=
ps
.charsUsed ) {
4429
chars =
ps
.chars;
4433
attr.SetLineInfo(
ps
.LineNo, attrNameLinePos );
4441
ps
.charPos = pos;
4443
pos =
ps
.charPos;
4452
ps
.charPos = pos;
4454
pos =
ps
.charPos;
4461
ps
.charPos = pos;
4464
attr.SetLineInfo2(
ps
.LineNo,
ps
.LinePos );
4488
attr.SetValue( chars,
ps
.charPos, pos -
ps
.charPos );
4490
ps
.charPos = pos;
4494
pos =
ps
.charPos;
4495
chars =
ps
.chars;
4518
ps
.lineNo -= lineNoDelta;
4520
pos =
ps
.charPos;
4521
chars =
ps
.chars;
4653
char[] chars =
ps
.chars;
4654
int attributeBaseEntityId =
ps
.entityId;
4657
LineInfo valueChunkLineInfo = new LineInfo(
ps
.lineNo,
ps
.LinePos);
4677
if ( pos -
ps
.charPos > 0 ) {
4678
stringBuilder.Append( chars,
ps
.charPos, pos -
ps
.charPos );
4679
ps
.charPos = pos;
4682
if ( chars[pos] == quoteChar && attributeBaseEntityId ==
ps
.entityId ) {
4693
ps
.charPos++;
4700
stringBuilder.Append(
ps
.eolNormalized ? "\u0020\u0020" : "\u0020" ); // CDATA normalization of 0xD 0xA
4701
ps
.charPos = pos;
4704
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
4708
ps
.charPos = pos;
4721
ps
.charPos++;
4735
if ( pos -
ps
.charPos > 0 ) {
4736
stringBuilder.Append( chars,
ps
.charPos, pos -
ps
.charPos );
4738
ps
.charPos = pos;
4741
int enclosingEntityId =
ps
.entityId;
4742
LineInfo entityLineInfo = new LineInfo(
ps
.lineNo,
ps
.LinePos + 1 );
4751
if ( parsingMode == ParsingMode.Full &&
ps
.entityId == attributeBaseEntityId ) {
4763
ps
.charPos++;
4780
valueChunkLineInfo.Set(
ps
.LineNo,
ps
.LinePos );
4785
ps
.charPos++;
4788
pos =
ps
.charPos;
4808
entityChunk.SetNamedNode( XmlNodeType.EntityReference,
ps
.entity.Name );
4816
pos =
ps
.charPos;
4820
pos =
ps
.charPos;
4823
chars =
ps
.chars;
4827
if ( pos ==
ps
.charsUsed ) {
4834
if ( pos + 1 ==
ps
.charsUsed ) {
4843
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
4852
if (
ps
.charsUsed -
ps
.charPos > 0 ) {
4853
if (
ps
.chars[
ps
.charPos] != (char)0xD ) {
4857
Debug.Assert(
ps
.isEof );
4862
if ( attributeBaseEntityId !=
ps
.entityId ) {
4877
if ( attributeBaseEntityId ==
ps
.entityId ) {
4879
valueChunkLineInfo.Set(
ps
.LineNo,
ps
.LinePos );
4885
pos =
ps
.charPos;
4886
chars =
ps
.chars;
4903
ps
.charPos = pos + 1;
4938
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
4951
curNode.SetValueNode( nodeType,
ps
.chars, startPos, endPos - startPos );
4960
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
4965
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
4987
curNode.SetValueNode( XmlNodeType.Text,
ps
.chars, startPos, endPos - startPos );
4995
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
5000
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
5053
char[] chars =
ps
.chars;
5054
int pos =
ps
.charPos;
5087
if ( !
ps
.eolNormalized && parsingMode == ParsingMode.Full ) {
5088
if ( pos -
ps
.charPos > 0 ) {
5100
ps
.charPos++;
5105
else if ( pos + 1 <
ps
.charsUsed ||
ps
.isEof ) {
5106
if ( !
ps
.eolNormalized ) {
5138
if ( pos >
ps
.charPos ) {
5158
if ( !xmlCharType.IsWhiteSpace(
ps
.chars[pos-1]) ) {
5163
pos =
ps
.charPos;
5166
chars =
ps
.chars;
5170
if (
ps
.charsUsed - pos < 3 && !
ps
.isEof ) {
5181
if ( pos ==
ps
.charsUsed ) {
5188
if ( pos + 1 ==
ps
.charsUsed ) {
5198
int offset = pos -
ps
.charPos;
5200
chars =
ps
.chars;
5201
pos =
ps
.charPos + offset;
5205
ThrowInvalidChar(
ps
.chars,
ps
.charsUsed,
ps
.charPos + offset );
5212
if ( pos >
ps
.charPos ) {
5217
if (
ps
.charsUsed -
ps
.charPos > 0 ) {
5218
if (
ps
.chars[
ps
.charPos] != (char)0xD &&
ps
.chars[
ps
.charPos] != ']') {
5221
Debug.Assert(
ps
.isEof );
5241
pos =
ps
.charPos;
5242
chars =
ps
.chars;
5253
startPos =
ps
.charPos;
5255
ps
.charPos = pos;
5272
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
5274
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
5380
if (
ps
.chars[
ps
.charPos] == '<' ||
ps
.charsUsed -
ps
.charPos == 0 || ZeroEndingStream(
ps
.charPos ) ) {
5385
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
5387
if (
ps
.chars[
ps
.charPos] == '<' ||
ps
.charsUsed -
ps
.charPos == 0 || ZeroEndingStream(
ps
.charPos ) ) {
5397
if ( xmlCharType.IsCharData(
ps
.chars[
ps
.charPos] ) ) {
5401
ThrowInvalidChar(
ps
.chars,
ps
.charsUsed,
ps
.charPos );
5408
Debug.Assert(
ps
.chars[
ps
.charPos] == '&' );
5409
ps
.charPos++;
5411
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
5417
Debug.Assert(
ps
.chars[
ps
.charPos] == '&' );
5419
if (
ps
.charPos + 1 ==
ps
.charsUsed ) {
5426
if (
ps
.chars[
ps
.charPos+1] == '#' ) {
5452
ps
.charPos++;
5453
int savedLinePos =
ps
.LinePos;
5458
Throw( Res.Xml_ErrorParsingEntityName,
ps
.LineNo, savedLinePos );
5463
if (
ps
.chars[endPos] != ';' ) {
5467
int entityLinePos =
ps
.LinePos;
5468
string entityName = nameTable.Add(
ps
.chars,
ps
.charPos, endPos -
ps
.charPos );
5469
ps
.charPos = endPos + 1;
5473
reportedBaseUri =
ps
.baseUriStr;
5474
reportedEncoding =
ps
.encoding;
5498
Throw( Res.Xml_UndeclaredEntity, name,
ps
.LineNo, entityStartLinePos );
5510
Throw( Res.Xml_UnparsedEntityRef, name,
ps
.LineNo, entityStartLinePos );
5514
Throw( Res.Xml_ExternalEntityInStandAloneDocument, entity.Name,
ps
.LineNo, entityStartLinePos );
5519
Throw( Res.Xml_ExternalEntityInAttValue, name,
ps
.LineNo, entityStartLinePos );
5530
curNode.entityId =
ps
.entityId;
5537
curNode.entityId =
ps
.entityId;
5552
curNode.entityId =
ps
.entityId;
5579
if (
ps
.entityResolvedManually ) {
5583
if (
ps
.entityId != nodes[index].entityId ) {
5588
lastEntity =
ps
.entity; // save last entity for the EndEntity node
5596
if (
ps
.entityId != nodes[index].entityId ) {
5603
reportedEncoding =
ps
.encoding;
5604
reportedBaseUri =
ps
.baseUriStr;
5615
reportedEncoding =
ps
.encoding;
5616
reportedBaseUri =
ps
.baseUriStr;
5621
curNode.lineInfo.Set(
ps
.lineNo,
ps
.LinePos - 1 );
5645
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
5652
string target = nameTable.Add(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos );
5657
ps
.charPos = nameEndPos;
5669
char ch =
ps
.chars[
ps
.charPos];
5670
Debug.Assert(
ps
.charPos <
ps
.charsUsed );
5672
if (
ps
.charsUsed -
ps
.charPos < 2 ) {
5675
if ( ch != '?' ||
ps
.chars[
ps
.charPos+1] != '>' ) {
5676
Throw( Res.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(
ps
.chars,
ps
.charsUsed,
ps
.charPos ) );
5688
curNode.SetValue(
ps
.chars, startPos, endPos - startPos );
5692
piInDtdStringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
5710
sb.Append(
ps
.chars, startPos, endPos - startPos );
5712
sb.Append(
ps
.chars, startPos, endPos - startPos );
5724
if (
ps
.charsUsed -
ps
.charPos < 2 ) {
5726
Throw(
ps
.charsUsed, Res.Xml_UnexpectedEOF, "PI" );
5730
int pos =
ps
.charPos;
5731
char[] chars =
ps
.chars;
5757
Debug.Assert( !
ps
.eolNormalized );
5764
outStartPos =
ps
.charPos;
5765
ps
.charPos = pos + 2;
5768
else if ( pos+1 ==
ps
.charsUsed ) {
5782
if ( !
ps
.eolNormalized && parsingMode == ParsingMode.Full ) {
5784
if ( pos -
ps
.charPos > 0 ) {
5796
ps
.charPos++;
5801
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
5802
if ( !
ps
.eolNormalized ) {
5820
if ( pos ==
ps
.charsUsed ) {
5827
if ( pos + 1 ==
ps
.charsUsed ) {
5836
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
5851
outStartPos =
ps
.charPos;
5852
ps
.charPos = pos;
5879
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
5882
curNode.SetValueNode( type,
ps
.chars, startPos, endPos - startPos );
5886
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
5888
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
5900
if (
ps
.charsUsed -
ps
.charPos < 3 ) {
5907
int pos =
ps
.charPos;
5908
char[] chars =
ps
.chars;
5935
Debug.Assert( !
ps
.eolNormalized );
5942
outStartPos =
ps
.charPos;
5943
ps
.charPos = pos + 3;
5946
else if ( pos+2 ==
ps
.charsUsed ) {
5953
else if ( pos+1 ==
ps
.charsUsed ) {
5969
if ( !
ps
.eolNormalized && parsingMode == ParsingMode.Full ) {
5970
if ( pos -
ps
.charPos > 0 ) {
5982
ps
.charPos++;
5987
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
5988
if ( !
ps
.eolNormalized ) {
6006
if ( pos ==
ps
.charsUsed ) {
6012
if ( pos + 1 ==
ps
.charsUsed ) {
6021
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
6034
outStartPos =
ps
.charPos;
6036
ps
.charPos = pos;
6048
while (
ps
.charsUsed -
ps
.charPos < 8 ) {
6053
if ( !XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, 7, "DOCTYPE" ) ) {
6056
if ( !xmlCharType.IsWhiteSpace(
ps
.chars[
ps
.charPos + 7] ) ) {
6057
ThrowExpectingWhitespace(
ps
.charPos + 7 );
6061
Throw(
ps
.charPos - 2, Res.Xml_MultipleDTDsProvided ); // position just before <!DOCTYPE
6064
Throw(
ps
.charPos - 2, Res.Xml_DtdAfterRootElement );
6067
ps
.charPos += 8;
6073
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos);
6112
ps
.charPos = pos;
6118
if (
ps
.chars[
ps
.charPos] == 'P' ) {
6120
while (
ps
.charsUsed -
ps
.charPos < 6 ) {
6126
if ( !XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, 6, "PUBLIC" ) ) {
6129
ps
.charPos += 6;
6133
ThrowExpectingWhitespace(
ps
.charPos );
6141
ThrowExpectingWhitespace(
ps
.charPos );
6149
else if (
ps
.chars[
ps
.charPos] == 'S' ) {
6151
while (
ps
.charsUsed -
ps
.charPos < 6 ) {
6157
if ( !XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, 6, "SYSTEM" ) ) {
6160
ps
.charPos += 6;
6164
ThrowExpectingWhitespace(
ps
.charPos );
6172
else if (
ps
.chars[
ps
.charPos] != '[' &&
ps
.chars[
ps
.charPos] != '>' ) {
6177
if (
ps
.chars[
ps
.charPos] == '[' ) {
6178
ps
.charPos++;
6183
if (
ps
.chars[
ps
.charPos] != '>' ) {
6187
else if (
ps
.chars[
ps
.charPos] == '>' ) {
6193
ps
.charPos++;
6198
char quoteChar =
ps
.chars[
ps
.charPos];
6203
ps
.charPos++;
6213
char[] chars =
ps
.chars;
6214
int pos =
ps
.charPos;
6233
ps
.charPos = pos + 1;
6238
ps
.charPos = pos;
6249
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
6270
if ( pos + 3 >=
ps
.charsUsed && !
ps
.isEof ) {
6282
else if ( pos + 1 >=
ps
.charsUsed && !
ps
.isEof ) {
6290
if ( pos + 2 >=
ps
.charsUsed && !
ps
.isEof ) {
6305
if (pos + 1 >=
ps
.charsUsed && !
ps
.isEof) {
6340
if ( pos ==
ps
.charsUsed ) {
6347
if ( pos + 1 ==
ps
.charsUsed ) {
6356
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
6364
if (
ps
.charsUsed -
ps
.charPos > 0 ) {
6365
if (
ps
.chars[
ps
.charPos] != (char)0xD ) {
6369
Debug.Assert(
ps
.isEof );
6375
chars =
ps
.chars;
6376
pos =
ps
.charPos;
6381
int pos =
ps
.charPos;
6383
char[] chars =
ps
.chars;
6394
int tmp1 = pos -
ps
.charPos;
6395
if ( sb != null && !
ps
.eolNormalized ) {
6397
sb.Append( chars,
ps
.charPos, tmp1 );
6400
ps
.charPos = pos + 1;
6404
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
6405
if ( !
ps
.eolNormalized ) {
6420
if ( pos ==
ps
.charsUsed ) {
6424
int tmp2 = pos -
ps
.charPos;
6427
sb.Append(
ps
.chars,
ps
.charPos, tmp2 );
6429
ps
.charPos = pos;
6438
int tmp3 = pos -
ps
.charPos;
6441
sb.Append(
ps
.chars,
ps
.charPos, tmp3 );
6443
ps
.charPos = pos;
6448
if (
ps
.charsUsed -
ps
.charPos == 0 ) {
6451
if (
ps
.chars[
ps
.charPos] != (char)0xD ) {
6455
Debug.Assert(
ps
.isEof );
6457
pos =
ps
.charPos;
6458
chars =
ps
.chars;
6463
Debug.Assert(
ps
.chars[startPos] == '&' );
6464
if (
ps
.chars[startPos + 1] == '#' ) {
6483
switch ( newPos = ParseNumericCharRefInline(
ps
.charPos, expand, internalSubsetBuilder, out charCount, out entityType ) ) {
6489
Debug.Assert(
ps
.chars[
ps
.charPos] == '&' );
6493
ps
.charPos = newPos - charCount;
6507
Debug.Assert(
ps
.chars[startPos] == '&' &&
ps
.chars[startPos + 1] == '#' );
6515
chars =
ps
.chars;
6539
else if ( pos <
ps
.charsUsed ) {
6555
ps
.charPos = pos;
6561
if ( pos ==
ps
.charsUsed ) {
6575
Throw((
ps
.chars[startPos + 2] == 'x') ? startPos + 3 : startPos + 2, Res.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(ch, '\0'));
6580
internalSubsetBuilder.Append(
ps
.chars,
ps
.charPos, pos -
ps
.charPos + 1 );
6598
Throw((
ps
.chars[startPos + 2] == 'x') ? startPos + 3 : startPos + 2, Res.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(high, low));
6605
internalSubsetBuilder.Append(
ps
.chars,
ps
.charPos, pos -
ps
.charPos + 1 );
6624
switch ( newPos = ParseNamedCharRefInline(
ps
.charPos, expand, internalSubsetBuilder ) ) {
6632
Debug.Assert(
ps
.chars[
ps
.charPos] == '&' );
6636
ps
.charPos = newPos - 1;
6650
Debug.Assert( startPos <
ps
.charsUsed );
6651
Debug.Assert(
ps
.chars[startPos] == '&' );
6652
Debug.Assert(
ps
.chars[startPos + 1] != '#' );
6655
char[] chars =
ps
.chars;
6664
if (
ps
.charsUsed - pos >= 3 ) {
6677
if (
ps
.charsUsed - pos >= 4 ) {
6689
else if ( pos <
ps
.charsUsed ) {
6695
if (
ps
.charsUsed - pos >= 5 ) {
6709
if (
ps
.charsUsed - pos >= 3 ) {
6722
if (
ps
.charsUsed - pos >= 3 ) {
6744
internalSubsetBuilder.Append(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
6746
ps
.chars[pos-1] = ch;
6762
int pos =
ps
.charPos + startOffset;
6765
char[] chars =
ps
.chars;
6782
if ( pos + 1 >=
ps
.charsUsed ) {
6789
Throw( pos, Res.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs( chars,
ps
.charsUsed, pos ) );
6822
colonOffset = pos -
ps
.charPos;
6827
colonOffset = pos -
ps
.charPos;
6833
else if ( pos ==
ps
.charsUsed
6839
chars =
ps
.chars;
6846
colonPos = ( colonOffset == -1 ) ? -1 :
ps
.charPos + colonOffset;
6851
int offset = pos -
ps
.charPos;
6853
pos =
ps
.charPos + offset;
6869
if (
ps
.chars[endPos] != ';' ) {
6873
string entityName = nameTable.Add(
ps
.chars,
ps
.charPos, endPos -
ps
.charPos );
6874
ps
.charPos = endPos + 1;
6921
string localName = nameTable.Add(
ps
.chars,
ps
.charPos, endNamePos -
ps
.charPos );
6926
int startPos =
ps
.charPos;
6928
if ( prefixLen == lastPrefix.Length && XmlConvert.StrEqual(
ps
.chars, startPos, prefixLen, lastPrefix ) ) {
6929
return AddAttribute( nameTable.Add(
ps
.chars, colonPos + 1, endNamePos - colonPos - 1 ),
6934
string prefix = nameTable.Add(
ps
.chars, startPos, prefixLen );
6936
return AddAttribute( nameTable.Add(
ps
.chars, colonPos + 1, endNamePos - colonPos - 1 ),
6985
ps
.lineNo++;
6986
ps
.lineStartPos = pos - 1;
6990
Debug.Assert(
ps
.isEof );
6993
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
7201
Debug.Assert(
ps
.appendMode );
7202
int initialPos =
ps
.charPos;
7207
ps
.charPos = initialPos;
7212
Encoding enc =
ps
.encoding;
7228
Encoding enc =
ps
.encoding;
7236
ps
.lineNo = entity.LineNumber;
7237
ps
.lineStartPos = - entity.LinePosition - 1;
7239
ps
.eolNormalized = true;
7245
if (
ps
.stream != null ) {
7246
ps
.stream.Close();
7250
curNode.entityId =
ps
.entityId;
7263
ps
.entity = entity;
7264
ps
.entityId = nextEntityId++;
7277
if (
ps
.entity != null) {
7278
currentEntities.Remove(
ps
.entity);
7293
parsingStatesStack[ parsingStatesStackTop ] =
ps
;
7295
ps
.Clear();
7300
ps
.Close( true );
7312
incReadLeftStartPos =
ps
.charPos;
7313
incReadLeftEndPos =
ps
.charPos;
7314
incReadLineInfo.Set(
ps
.LineNo,
ps
.LinePos );
7352
count = incReadDecoder.Decode(
ps
.chars, incReadLeftStartPos, charsLeft );
7385
Debug.Assert( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos - 2, 2, "?>" ) );
7386
ps
.charPos -= 2;
7392
Debug.Assert( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos - 3, 3, "-->" ) );
7393
ps
.charPos -= 3;
7399
Debug.Assert( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos - 3, 3, "]]>" ) );
7400
ps
.charPos -= 3;
7418
startPos =
ps
.charPos;
7429
char[] chars =
ps
.chars;
7430
startPos =
ps
.charPos;
7434
incReadLineInfo.Set(
ps
.LineNo,
ps
.LinePos );
7469
else if ( pos+1 <
ps
.charsUsed ) {
7483
if (
ps
.charsUsed - pos < 2 ) {
7494
if (
ps
.charsUsed - pos < 4 ) {
7502
if (
ps
.charsUsed - pos < 9 ) {
7517
Debug.Assert(
ps
.charPos - pos == 0 );
7518
Debug.Assert(
ps
.charPos - startPos == 0);
7523
if ( XmlConvert.StrEqual( chars,
ps
.charPos + 2, endPos -
ps
.charPos - 2, curNode.GetNameWPrefix( nameTable ) ) &&
7524
(
ps
.chars[endPos] == '>' || xmlCharType.IsWhiteSpace(
ps
.chars[endPos] ) ) ) {
7531
ps
.charPos = endPos;
7532
if ( xmlCharType.IsWhiteSpace(
ps
.chars[endPos] ) ) {
7535
if (
ps
.chars[
ps
.charPos] != '>' ) {
7538
ps
.charPos++;
7545
startPos =
ps
.charPos;
7546
chars =
ps
.chars;
7553
Debug.Assert(
ps
.charPos - pos == 0 );
7554
Debug.Assert(
ps
.charPos - startPos == 0 );
7559
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos + 1, endPos -
ps
.charPos - 1, curNode.localName ) &&
7560
(
ps
.chars[endPos] == '>' ||
ps
.chars[endPos] == '/' || xmlCharType.IsWhiteSpace(
ps
.chars[endPos] ) ) ) {
7567
startPos =
ps
.charPos;
7568
chars =
ps
.chars;
7576
if (
ps
.charsUsed - pos < 2 ) {
7610
if ( pos ==
ps
.charsUsed ) {
7625
ps
.charPos = pos;
7633
count = incReadDecoder.Decode(
ps
.chars, startPos, charsParsed );
7665
ParseAttributeValueSlow(
ps
.charPos, ' ', curNode ); // The quote char is intentionally empty (space) because we need to parse ' and " into the attribute value
7687
char[] chars =
ps
.chars;
7688
int pos =
ps
.charPos;
7691
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
7710
Debug.Assert(
ps
.eolNormalized, "Entity replacement text for attribute values should be EOL-normalized!" );
7732
if ( pos -
ps
.charPos > 0 ) {
7733
stringBuilder.Append( chars,
ps
.charPos, pos -
ps
.charPos );
7735
ps
.charPos = pos;
7742
chars =
ps
.chars;
7743
if ( normalize && xmlCharType.IsWhiteSpace( chars[
ps
.charPos] ) && pos -
ps
.charPos == 1 ) {
7744
chars[
ps
.charPos] = (char)0x20; // CDATA normalization of character references in entities
7750
ps
.charPos++;
7761
chars =
ps
.chars;
7765
if ( pos ==
ps
.charsUsed ) {
7772
if ( pos + 1 ==
ps
.charsUsed ) {
7781
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
7787
if ( pos -
ps
.charPos > 0 ) {
7788
stringBuilder.Append( chars,
ps
.charPos, pos -
ps
.charPos );
7789
ps
.charPos = pos;
7807
pos =
ps
.charPos;
7808
chars =
ps
.chars;
7812
if ( pos -
ps
.charPos > 0 ) {
7813
stringBuilder.Append( chars,
ps
.charPos, pos -
ps
.charPos );
7814
ps
.charPos = pos;
7840
ps
.charPos = pos;
7858
ps
.charPos = pos;
7863
if (
ps
.charPos ==
ps
.charsUsed ) {
7866
if ( xmlCharType.IsNCNameSingleChar(
ps
.chars[
ps
.charPos] ) ) {
7867
int pos =
ps
.charPos + 1;
7868
while ( xmlCharType.IsNCNameSingleChar(
ps
.chars[pos] ) ) {
7871
return new string(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
7874
Debug.Assert(
ps
.charPos <
ps
.charsUsed );
7875
return new string(
ps
.chars,
ps
.charPos, 1 );
7922
if ( v1Compat && pos ==
ps
.charsUsed - 1 &&
ps
.chars[pos] == (char)0 && ReadData() == 0 &&
ps
.isStreamEof ) {
7923
ps
.charsUsed--;
8360
curNode.AdjustLineInfo( readValueOffset,
ps
.eolNormalized, ref incReadLineInfo );
8381
incReadLineInfo.Set(
ps
.LineNo,
ps
.LinePos );
8385
charsRead = incReadDecoder.Decode(
ps
.chars, startPos, endPos - startPos );
8397
curNode.SetValue(
ps
.chars, startPos, endPos - startPos );
8399
AdjustLineInfo(
ps
.chars, startPos - charsRead, startPos,
ps
.eolNormalized, ref incReadLineInfo );
System\Xml\Core\XmlTextReaderImplAsync.cs (671)
93
reportedEncoding =
ps
.encoding;
120
reportedEncoding =
ps
.encoding;
134
reportedEncoding =
ps
.encoding;
165
Debug.Assert(!
ps
.appendMode);
206
reportedEncoding =
ps
.encoding;
207
reportedBaseUri =
ps
.baseUriStr;
213
curNode.SetLineInfo(
ps
.lineNo,
ps
.LinePos);
214
reportedEncoding =
ps
.encoding;
215
reportedBaseUri =
ps
.baseUriStr;
278
reportedEncoding =
ps
.encoding;
282
reportedEncoding =
ps
.encoding;
665
BlockCopyChars(
ps
.chars, startPos, buffer, ( index + readCount ), copyCount );
685
curNode.SetValue(
ps
.chars, startPos, endPos - startPos );
744
if ( e.ResString == Res.Xml_UnexpectedEOF &&
ps
.entity != null ) {
745
SendValidationEvent( XmlSeverityType.Error, Res.Sch_ParEntityRefNesting, null,
ps
.LineNo,
ps
.LinePos );
774
entityId =
ps
.entityId;
796
if (
ps
.baseUri == null && !string.IsNullOrEmpty(
ps
.baseUriStr)) {
797
ps
.baseUri = xmlResolver.ResolveUri(null,
ps
.baseUriStr);
799
await PushExternalEntityOrSubsetAsync( publicId, systemId,
ps
.baseUri, null ).ConfigureAwait(false);
801
ps
.entity = null;
802
ps
.entityId = 0;
804
Debug.Assert(
ps
.appendMode );
805
int initialPos =
ps
.charPos;
810
ps
.charPos = initialPos;
828
Debug.Assert(
ps
.charPos == 0 &&
ps
.charsUsed == 0 &&
ps
.textReader == null );
832
ps
.stream = stream;
833
ps
.baseUri = baseUri;
834
ps
.baseUriStr = baseUriStr;
839
ps
.bytes = bytes;
840
ps
.bytesUsed = byteCount;
841
bufferSize =
ps
.bytes.Length;
853
if (
ps
.bytes == null ||
ps
.bytes.Length < bufferSize ) {
854
ps
.bytes = new byte[ bufferSize ];
859
if (
ps
.chars == null ||
ps
.chars.Length < bufferSize + 1 ) {
860
ps
.chars = new char[ bufferSize + 1 ];
864
ps
.bytePos = 0;
865
while (
ps
.bytesUsed < 4 &&
ps
.bytes.Length -
ps
.bytesUsed > 0 ) {
866
int read = await stream.ReadAsync(
ps
.bytes,
ps
.bytesUsed,
ps
.bytes.Length -
ps
.bytesUsed ).ConfigureAwait(false);
868
ps
.isStreamEof = true;
871
ps
.bytesUsed += read;
881
byte[] preamble =
ps
.encoding.GetPreamble();
884
for ( i = 0; i < preambleLen && i <
ps
.bytesUsed; i++ ) {
885
if (
ps
.bytes[i] != preamble[i] ) {
890
ps
.bytePos = preambleLen;
893
documentStartBytePos =
ps
.bytePos;
895
ps
.eolNormalized = !normalize;
898
ps
.appendMode = true;
906
Debug.Assert(
ps
.charPos == 0 &&
ps
.charsUsed == 0 &&
ps
.stream == null );
909
ps
.textReader = input;
910
ps
.baseUriStr = baseUriStr;
911
ps
.baseUri = baseUri;
913
if (
ps
.chars == null ) {
925
ps
.chars = new char[bufferSize + 1];
928
ps
.encoding = Encoding.Unicode;
929
ps
.eolNormalized = !normalize;
932
ps
.appendMode = true;
963
if ( ( newEncoding.WebName !=
ps
.encoding.WebName ||
ps
.decoder is SafeAsciiDecoder ) && !afterResetState) {
965
Debug.Assert(
ps
.stream != null );
967
ps
.appendMode = false;
987
if (
ps
.isEof ) {
992
if (
ps
.appendMode ) {
994
if (
ps
.charsUsed ==
ps
.chars.Length - 1 ) {
1000
char[] newChars = new char[
ps
.chars.Length * 2 ];
1001
BlockCopyChars(
ps
.chars, 0, newChars, 0,
ps
.chars.Length );
1002
ps
.chars = newChars;
1005
if (
ps
.stream != null ) {
1007
if (
ps
.bytesUsed -
ps
.bytePos < MaxByteSequenceLen ) {
1008
if (
ps
.bytes.Length -
ps
.bytesUsed < MaxByteSequenceLen ) {
1009
byte[] newBytes = new byte[
ps
.bytes.Length * 2 ];
1010
BlockCopy(
ps
.bytes, 0, newBytes, 0,
ps
.bytesUsed );
1011
ps
.bytes = newBytes;
1016
charsRead =
ps
.chars.Length -
ps
.charsUsed - 1;
1022
int charsLen =
ps
.chars.Length;
1023
if ( charsLen -
ps
.charsUsed <= charsLen/2 ) {
1030
int copyCharsCount =
ps
.charsUsed -
ps
.charPos;
1032
ps
.lineStartPos =
ps
.lineStartPos -
ps
.charPos;
1034
BlockCopyChars(
ps
.chars,
ps
.charPos,
ps
.chars, 0, copyCharsCount );
1036
ps
.charPos = 0;
1037
ps
.charsUsed = copyCharsCount;
1040
char[] newChars = new char[
ps
.chars.Length * 2 ];
1041
BlockCopyChars(
ps
.chars, 0, newChars, 0,
ps
.chars.Length );
1042
ps
.chars = newChars;
1046
if (
ps
.stream != null ) {
1048
int bytesLeft =
ps
.bytesUsed -
ps
.bytePos;
1051
ps
.bytesUsed = 0;
1054
BlockCopy(
ps
.bytes,
ps
.bytePos,
ps
.bytes, 0, bytesLeft );
1055
ps
.bytesUsed = bytesLeft;
1057
ps
.bytePos = 0;
1060
charsRead =
ps
.chars.Length -
ps
.charsUsed - 1;
1063
if (
ps
.stream != null ) {
1064
if ( !
ps
.isStreamEof ) {
1066
if (
ps
.bytePos ==
ps
.bytesUsed &&
ps
.bytes.Length -
ps
.bytesUsed > 0 ) {
1067
int read = await
ps
.stream.ReadAsync(
ps
.bytes,
ps
.bytesUsed,
ps
.bytes.Length -
ps
.bytesUsed ).ConfigureAwait(false);
1069
ps
.isStreamEof = true;
1071
ps
.bytesUsed += read;
1075
int originalBytePos =
ps
.bytePos;
1079
if ( charsRead == 0 &&
ps
.bytePos != originalBytePos ) {
1084
else if (
ps
.textReader != null ) {
1086
charsRead = await
ps
.textReader.ReadAsync(
ps
.chars,
ps
.charsUsed,
ps
.chars.Length -
ps
.charsUsed - 1 ).ConfigureAwait(false);
1087
ps
.charsUsed += charsRead;
1096
Debug.Assert (
ps
.charsUsed <
ps
.chars.Length );
1097
ps
.isEof = true;
1099
ps
.chars[
ps
.charsUsed ] = (char)0;
1105
while (
ps
.charsUsed -
ps
.charPos < 6 ) { // minimum "<?xml "
1111
if ( !XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, 5, XmlDeclarationBegining ) ||
1112
xmlCharType.IsNameSingleChar(
ps
.chars[
ps
.charPos + 5] )
1121
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos + 2 );
1124
ps
.charPos += 5;
1139
if (
ps
.chars[
ps
.charPos] == '?' ) {
1142
if (
ps
.chars[
ps
.charPos + 1] == '>' ) {
1147
ps
.charPos += 2;
1164
string encodingName =
ps
.encoding.WebName;
1166
encodingName != "utf-16BE" && !(
ps
.encoding is Ucs4Encoding ) ) {
1167
Throw( Res.Xml_EncodingSwitchAfterResetState, (
ps
.encoding.GetByteCount( "A" ) == 1 ) ? "UTF-8" : "UTF-16" );
1171
if (
ps
.decoder is SafeAsciiDecoder ) {
1178
ps
.appendMode = false;
1181
else if (
ps
.charPos + 1 ==
ps
.charsUsed ) {
1197
switch (
ps
.chars[
ps
.charPos] ) {
1199
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos, "version" ) && xmlDeclState == 0 ) {
1207
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos, "encoding" ) &&
1217
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos, "standalone" ) &&
1231
attr.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
1233
sb.Append(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos );
1234
ps
.charPos = nameEndPos;
1237
if (
ps
.chars[
ps
.charPos] != '=' ) {
1239
if (
ps
.chars[
ps
.charPos] != '=' ) {
1244
ps
.charPos++;
1246
char quoteChar =
ps
.chars[
ps
.charPos];
1249
quoteChar =
ps
.chars[
ps
.charPos];
1255
ps
.charPos++;
1258
attr.SetLineInfo2(
ps
.LineNo,
ps
.LinePos );
1262
int pos =
ps
.charPos;
1265
chars =
ps
.chars;
1279
if (
ps
.chars[pos] == quoteChar ) {
1291
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, pos -
ps
.charPos, "1.0" ) ) {
1294
attr.SetValue(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
1299
string badVersion = new string(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
1304
string encName = new string(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
1312
if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, pos -
ps
.charPos, "yes" ) ) {
1315
else if ( XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, pos -
ps
.charPos, "no" ) ) {
1320
Throw( Res.Xml_InvalidXmlDecl,
ps
.LineNo,
ps
.LinePos - 1 );
1323
attr.SetValue(
ps
.chars,
ps
.charPos, pos -
ps
.charPos );
1331
sb.Append( chars,
ps
.charPos, pos -
ps
.charPos );
1333
ps
.charPos = pos + 1;
1336
else if ( pos ==
ps
.charsUsed ) {
1349
if (
ps
.isEof || await ReadDataAsync().ConfigureAwait(false) == 0 ) {
1362
string encodingName =
ps
.encoding.WebName;
1364
encodingName != "utf-16BE" && !(
ps
.encoding is Ucs4Encoding ) ) {
1365
Throw( Res.Xml_EncodingSwitchAfterResetState, (
ps
.encoding.GetByteCount( "A" ) == 1 ) ? "UTF-8" : "UTF-16" );
1369
if (
ps
.decoder is SafeAsciiDecoder ) {
1372
ps
.appendMode = false;
1382
int pos =
ps
.charPos;
1383
char[] chars =
ps
.chars;
1388
if (
ps
.charsUsed - pos < 4) // minimum "<a/>"
1394
ps
.charPos = pos + 1;
1398
if (
ps
.charsUsed - pos < 2) // minimum characters expected "--"
1403
ps
.charPos = pos + 2;
1414
if (
ps
.charsUsed - pos < 6) {
1418
ps
.charPos = pos + 6;
1426
Throw(
ps
.charPos, Res.Xml_InvalidRootData);
1433
ps
.charPos = pos;
1459
ps
.charPos = pos;
1468
else if (pos ==
ps
.charsUsed || (v1Compat && chars[pos] == 0x0)) {
1481
Debug.Assert(pos ==
ps
.charsUsed && !
ps
.isEof);
1494
int pos =
ps
.charPos;
1597
int pos =
ps
.charPos;
1598
char[] chars =
ps
.chars;
1606
ps
.charPos = pos + 2;
1610
if (
ps
.charsUsed - pos < 2)
1615
ps
.charPos = pos + 2;
1625
if (
ps
.charsUsed - pos < 6) {
1629
ps
.charPos = pos + 6;
1648
ps
.charPos = pos + 2;
1652
if (pos + 1 ==
ps
.charsUsed) {
1657
ps
.charPos = pos + 1;
1666
if (pos ==
ps
.charsUsed) {
1680
if (
ps
.charsUsed -
ps
.charPos != 0) {
1704
int pos =
ps
.charPos;
1705
char[] chars =
ps
.chars;
1708
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos);
1773
else if (pos + 1 <
ps
.charsUsed) {
1805
char[] chars =
ps
.chars;
1813
nameTable.Add(chars,
ps
.charPos, pos -
ps
.charPos));
1816
int startPos =
ps
.charPos;
1827
nameTable.Add(chars,
ps
.charPos, prefixLen),
1845
ps
.charPos = pos;
1857
int pos =
ps
.charPos;
1858
char[] chars =
ps
.chars;
1862
ps
.charPos = pos + 1;
1867
if (pos + 1 ==
ps
.charsUsed) {
1868
ps
.charPos = pos;
1875
ps
.charPos = pos + 2;
1883
Throw(pos, Res.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(chars,
ps
.charsUsed, pos));
1911
if (
ps
.charsUsed -
ps
.charPos < prefLen + locLen + 1) {
1930
while (
ps
.charsUsed -
ps
.charPos < prefLen + locLen + 1) {
1944
char[] chars =
ps
.chars;
1946
if (!XmlConvert.StrEqual(chars,
ps
.charPos, locLen, startTagNode.localName)) {
1952
int colonPos =
ps
.charPos + prefLen;
1953
if (!XmlConvert.StrEqual(chars,
ps
.charPos, prefLen, startTagNode.prefix) ||
1960
LineInfo endTagLineInfo = new LineInfo(
ps
.lineNo,
ps
.LinePos);
2015
pos =
ps
.charPos + nameLen;
2016
chars =
ps
.chars;
2018
if (pos ==
ps
.charsUsed) {
2057
else if (pos ==
ps
.charsUsed && !
ps
.isEof) {
2069
else if (pos ==
ps
.charsUsed) {
2088
ps
.charPos = pos + 1;
2120
args[3] = new string(
ps
.chars,
ps
.charPos, endPos -
ps
.charPos );
2131
int pos =
ps
.charPos;
2132
char[] chars =
ps
.chars;
2159
else if ( pos+1 !=
ps
.charsUsed ) {
2164
ps
.charPos = pos;
2194
ps
.charPos = pos + 1;
2201
if ( pos+1 ==
ps
.charsUsed ) {
2205
ps
.charPos = pos + 2;
2215
else if ( pos ==
ps
.charsUsed ) {
2219
Throw( pos, Res.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs( chars,
ps
.charsUsed, pos ) );
2223
if ( pos ==
ps
.charPos ) {
2226
ps
.charPos = pos;
2229
int attrNameLinePos =
ps
.LinePos;
2305
chars =
ps
.chars;
2308
else if ( pos + 1 >=
ps
.charsUsed ) {
2315
chars =
ps
.chars;
2319
attr.SetLineInfo(
ps
.LineNo, attrNameLinePos );
2327
ps
.charPos = pos;
2329
pos =
ps
.charPos;
2338
ps
.charPos = pos;
2340
pos =
ps
.charPos;
2347
ps
.charPos = pos;
2350
attr.SetLineInfo2(
ps
.LineNo,
ps
.LinePos );
2374
attr.SetValue( chars,
ps
.charPos, pos -
ps
.charPos );
2376
ps
.charPos = pos;
2380
pos =
ps
.charPos;
2381
chars =
ps
.chars;
2404
ps
.lineNo -= lineNoDelta;
2406
pos =
ps
.charPos;
2407
chars =
ps
.chars;
2435
char[] chars =
ps
.chars;
2436
int attributeBaseEntityId =
ps
.entityId;
2439
LineInfo valueChunkLineInfo = new LineInfo(
ps
.lineNo,
ps
.LinePos);
2459
if ( pos -
ps
.charPos > 0 ) {
2460
stringBuilder.Append( chars,
ps
.charPos, pos -
ps
.charPos );
2461
ps
.charPos = pos;
2464
if ( chars[pos] == quoteChar && attributeBaseEntityId ==
ps
.entityId ) {
2475
ps
.charPos++;
2482
stringBuilder.Append(
ps
.eolNormalized ? "\u0020\u0020" : "\u0020" ); // CDATA normalization of 0xD 0xA
2483
ps
.charPos = pos;
2486
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
2490
ps
.charPos = pos;
2503
ps
.charPos++;
2517
if ( pos -
ps
.charPos > 0 ) {
2518
stringBuilder.Append( chars,
ps
.charPos, pos -
ps
.charPos );
2520
ps
.charPos = pos;
2523
int enclosingEntityId =
ps
.entityId;
2524
LineInfo entityLineInfo = new LineInfo(
ps
.lineNo,
ps
.LinePos + 1 );
2538
if ( parsingMode == ParsingMode.Full &&
ps
.entityId == attributeBaseEntityId ) {
2550
ps
.charPos++;
2567
valueChunkLineInfo.Set(
ps
.LineNo,
ps
.LinePos );
2572
ps
.charPos++;
2575
pos =
ps
.charPos;
2595
entityChunk.SetNamedNode( XmlNodeType.EntityReference,
ps
.entity.Name );
2603
pos =
ps
.charPos;
2607
pos =
ps
.charPos;
2610
chars =
ps
.chars;
2614
if ( pos ==
ps
.charsUsed ) {
2621
if ( pos + 1 ==
ps
.charsUsed ) {
2630
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
2639
if (
ps
.charsUsed -
ps
.charPos > 0 ) {
2640
if (
ps
.chars[
ps
.charPos] != (char)0xD ) {
2644
Debug.Assert(
ps
.isEof );
2649
if ( attributeBaseEntityId !=
ps
.entityId ) {
2664
if ( attributeBaseEntityId ==
ps
.entityId ) {
2666
valueChunkLineInfo.Set(
ps
.LineNo,
ps
.LinePos );
2672
pos =
ps
.charPos;
2673
chars =
ps
.chars;
2690
ps
.charPos = pos + 1;
2706
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos);
2733
curNode.SetValueNode(nodeType,
ps
.chars, startPos, endPos - startPos);
2770
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
2791
curNode.SetValueNode( nodeType,
ps
.chars, startPos, endPos - startPos );
2803
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
2814
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
2836
curNode.SetValueNode( XmlNodeType.Text,
ps
.chars, startPos, endPos - startPos );
2844
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
2856
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
2959
Task<Tuple<int, int, int, bool>> task = ParseTextAsync(outOrChars,
ps
.chars,
ps
.charPos, 0, -1, outOrChars, (char)0);
3059
if (!
ps
.eolNormalized && parsingMode == ParsingMode.Full) {
3060
if (pos -
ps
.charPos > 0) {
3072
ps
.charPos++;
3077
else if (pos + 1 <
ps
.charsUsed ||
ps
.isEof) {
3078
if (!
ps
.eolNormalized) {
3101
if (
ps
.charsUsed - pos < 3 && !
ps
.isEof) {
3114
if (pos ==
ps
.charsUsed) {
3147
if (pos >
ps
.charPos) {
3176
if (!xmlCharType.IsWhiteSpace(
ps
.chars[pos - 1])) {
3181
pos =
ps
.charPos;
3184
chars =
ps
.chars;
3195
if (pos + 1 ==
ps
.charsUsed) {
3209
int offset = pos -
ps
.charPos;
3211
chars =
ps
.chars;
3212
pos =
ps
.charPos + offset;
3218
ThrowInvalidChar(
ps
.chars,
ps
.charsUsed,
ps
.charPos + offset);
3226
if (pos >
ps
.charPos) {
3233
if (
ps
.charsUsed -
ps
.charPos > 0) {
3234
if (
ps
.chars[
ps
.charPos] != (char)0xD &&
ps
.chars[
ps
.charPos] != ']') {
3237
Debug.Assert(
ps
.isEof);
3261
pos =
ps
.charPos;
3262
chars =
ps
.chars;
3276
int startPos =
ps
.charPos;
3278
ps
.charPos = pos;
3304
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
3312
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
3430
if (
ps
.chars[
ps
.charPos] == '<' ||
ps
.charsUsed -
ps
.charPos == 0 || await ZeroEndingStreamAsync(
ps
.charPos ).ConfigureAwait(false) ) {
3435
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
3437
if (
ps
.chars[
ps
.charPos] == '<' ||
ps
.charsUsed -
ps
.charPos == 0 || await ZeroEndingStreamAsync(
ps
.charPos ).ConfigureAwait(false) ) {
3447
if ( xmlCharType.IsCharData(
ps
.chars[
ps
.charPos] ) ) {
3451
ThrowInvalidChar(
ps
.chars,
ps
.charsUsed,
ps
.charPos );
3458
Debug.Assert(
ps
.chars[
ps
.charPos] == '&' );
3459
ps
.charPos++;
3461
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
3469
Debug.Assert(
ps
.chars[
ps
.charPos] == '&' );
3471
if (
ps
.charPos + 1 ==
ps
.charsUsed ) {
3478
if (
ps
.chars[
ps
.charPos+1] == '#' ) {
3515
ps
.charPos++;
3516
int savedLinePos =
ps
.LinePos;
3521
Throw( Res.Xml_ErrorParsingEntityName,
ps
.LineNo, savedLinePos );
3528
if (
ps
.chars[endPos] != ';' ) {
3532
int entityLinePos =
ps
.LinePos;
3533
string entityName = nameTable.Add(
ps
.chars,
ps
.charPos, endPos -
ps
.charPos );
3534
ps
.charPos = endPos + 1;
3538
reportedBaseUri =
ps
.baseUriStr;
3539
reportedEncoding =
ps
.encoding;
3565
Throw( Res.Xml_UndeclaredEntity, name,
ps
.LineNo, entityStartLinePos );
3577
Throw( Res.Xml_UnparsedEntityRef, name,
ps
.LineNo, entityStartLinePos );
3581
Throw( Res.Xml_ExternalEntityInStandAloneDocument, entity.Name,
ps
.LineNo, entityStartLinePos );
3586
Throw( Res.Xml_ExternalEntityInAttValue, name,
ps
.LineNo, entityStartLinePos );
3597
curNode.entityId =
ps
.entityId;
3604
curNode.entityId =
ps
.entityId;
3619
curNode.entityId =
ps
.entityId;
3636
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
3643
string target = nameTable.Add(
ps
.chars,
ps
.charPos, nameEndPos -
ps
.charPos );
3648
ps
.charPos = nameEndPos;
3660
char ch =
ps
.chars[
ps
.charPos];
3661
Debug.Assert(
ps
.charPos <
ps
.charsUsed );
3663
if (
ps
.charsUsed -
ps
.charPos < 2 ) {
3666
if ( ch != '?' ||
ps
.chars[
ps
.charPos+1] != '>' ) {
3667
Throw( Res.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(
ps
.chars,
ps
.charsUsed,
ps
.charPos ) );
3685
curNode.SetValue(
ps
.chars, startPos, endPos - startPos );
3689
piInDtdStringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
3717
sb.Append(
ps
.chars, startPos, endPos - startPos );
3725
sb.Append(
ps
.chars, startPos, endPos - startPos );
3740
if (
ps
.charsUsed -
ps
.charPos < 2 ) {
3742
Throw(
ps
.charsUsed, Res.Xml_UnexpectedEOF, "PI" );
3746
int pos =
ps
.charPos;
3747
char[] chars =
ps
.chars;
3774
Debug.Assert( !
ps
.eolNormalized );
3781
outStartPos =
ps
.charPos;
3782
ps
.charPos = pos + 2;
3787
else if ( pos+1 ==
ps
.charsUsed ) {
3801
if ( !
ps
.eolNormalized && parsingMode == ParsingMode.Full ) {
3803
if ( pos -
ps
.charPos > 0 ) {
3815
ps
.charPos++;
3820
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
3821
if ( !
ps
.eolNormalized ) {
3839
if ( pos ==
ps
.charsUsed ) {
3846
if ( pos + 1 ==
ps
.charsUsed ) {
3855
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
3870
outStartPos =
ps
.charPos;
3871
ps
.charPos = pos;
3900
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos );
3909
curNode.SetValueNode( type,
ps
.chars, startPos, endPos - startPos );
3916
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
3924
stringBuilder.Append(
ps
.chars, startPos, endPos - startPos );
3948
if (
ps
.charsUsed -
ps
.charPos < 3 ) {
3955
int pos =
ps
.charPos;
3956
char[] chars =
ps
.chars;
3983
Debug.Assert( !
ps
.eolNormalized );
3990
outStartPos =
ps
.charPos;
3991
ps
.charPos = pos + 3;
3996
else if ( pos+2 ==
ps
.charsUsed ) {
4003
else if ( pos+1 ==
ps
.charsUsed ) {
4019
if ( !
ps
.eolNormalized && parsingMode == ParsingMode.Full ) {
4020
if ( pos -
ps
.charPos > 0 ) {
4032
ps
.charPos++;
4037
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
4038
if ( !
ps
.eolNormalized ) {
4056
if ( pos ==
ps
.charsUsed ) {
4062
if ( pos + 1 ==
ps
.charsUsed ) {
4071
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
4084
outStartPos =
ps
.charPos;
4086
ps
.charPos = pos;
4100
while (
ps
.charsUsed -
ps
.charPos < 8 ) {
4105
if ( !XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, 7, "DOCTYPE" ) ) {
4108
if ( !xmlCharType.IsWhiteSpace(
ps
.chars[
ps
.charPos + 7] ) ) {
4109
ThrowExpectingWhitespace(
ps
.charPos + 7 );
4113
Throw(
ps
.charPos - 2, Res.Xml_MultipleDTDsProvided ); // position just before <!DOCTYPE
4116
Throw(
ps
.charPos - 2, Res.Xml_DtdAfterRootElement );
4119
ps
.charPos += 8;
4125
curNode.SetLineInfo(
ps
.LineNo,
ps
.LinePos);
4169
ps
.charPos = pos;
4175
if (
ps
.chars[
ps
.charPos] == 'P' ) {
4177
while (
ps
.charsUsed -
ps
.charPos < 6 ) {
4183
if ( !XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, 6, "PUBLIC" ) ) {
4186
ps
.charPos += 6;
4190
ThrowExpectingWhitespace(
ps
.charPos );
4198
ThrowExpectingWhitespace(
ps
.charPos );
4206
else if (
ps
.chars[
ps
.charPos] == 'S' ) {
4208
while (
ps
.charsUsed -
ps
.charPos < 6 ) {
4214
if ( !XmlConvert.StrEqual(
ps
.chars,
ps
.charPos, 6, "SYSTEM" ) ) {
4217
ps
.charPos += 6;
4221
ThrowExpectingWhitespace(
ps
.charPos );
4229
else if (
ps
.chars[
ps
.charPos] != '[' &&
ps
.chars[
ps
.charPos] != '>' ) {
4234
if (
ps
.chars[
ps
.charPos] == '[' ) {
4235
ps
.charPos++;
4240
if (
ps
.chars[
ps
.charPos] != '>' ) {
4244
else if (
ps
.chars[
ps
.charPos] == '>' ) {
4250
ps
.charPos++;
4255
char quoteChar =
ps
.chars[
ps
.charPos];
4260
ps
.charPos++;
4270
char[] chars =
ps
.chars;
4271
int pos =
ps
.charPos;
4290
ps
.charPos = pos + 1;
4295
ps
.charPos = pos;
4306
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
4327
if ( pos + 3 >=
ps
.charsUsed && !
ps
.isEof ) {
4339
else if ( pos + 1 >=
ps
.charsUsed && !
ps
.isEof ) {
4347
if ( pos + 2 >=
ps
.charsUsed && !
ps
.isEof ) {
4362
if (pos + 1 >=
ps
.charsUsed && !
ps
.isEof) {
4397
if ( pos ==
ps
.charsUsed ) {
4404
if ( pos + 1 ==
ps
.charsUsed ) {
4413
ThrowInvalidChar( chars,
ps
.charsUsed, pos );
4421
if (
ps
.charsUsed -
ps
.charPos > 0 ) {
4422
if (
ps
.chars[
ps
.charPos] != (char)0xD ) {
4426
Debug.Assert(
ps
.isEof );
4432
chars =
ps
.chars;
4433
pos =
ps
.charPos;
4438
int pos =
ps
.charPos;
4440
char[] chars =
ps
.chars;
4451
int tmp1 = pos -
ps
.charPos;
4452
if ( sb != null && !
ps
.eolNormalized ) {
4454
sb.Append( chars,
ps
.charPos, tmp1 );
4457
ps
.charPos = pos + 1;
4461
else if ( pos+1 <
ps
.charsUsed ||
ps
.isEof ) {
4462
if ( !
ps
.eolNormalized ) {
4477
if ( pos ==
ps
.charsUsed ) {
4481
int tmp2 = pos -
ps
.charPos;
4484
sb.Append(
ps
.chars,
ps
.charPos, tmp2 );
4486
ps
.charPos = pos;
4495
int tmp3 = pos -
ps
.charPos;
4498
sb.Append(
ps
.chars,
ps
.charPos, tmp3 );
4500
ps
.charPos = pos;
4505
if (
ps
.charsUsed -
ps
.charPos == 0 ) {
4508
if (
ps
.chars[
ps
.charPos] != (char)0xD ) {
4512
Debug.Assert(
ps
.isEof );
4514
pos =
ps
.charPos;
4515
chars =
ps
.chars;
4531
switch ( newPos = ParseNumericCharRefInline(
ps
.charPos, expand, internalSubsetBuilder, out charCount, out entityType ) ) {
4537
Debug.Assert(
ps
.chars[
ps
.charPos] == '&' );
4541
ps
.charPos = newPos - charCount;
4559
switch ( newPos = ParseNamedCharRefInline(
ps
.charPos, expand, internalSubsetBuilder ) ) {
4567
Debug.Assert(
ps
.chars[
ps
.charPos] == '&' );
4571
ps
.charPos = newPos - 1;
4595
int pos =
ps
.charPos + startOffset;
4598
char[] chars =
ps
.chars;
4618
if (pos + 1 >=
ps
.charsUsed) {
4622
Throw(pos, Res.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars,
ps
.charsUsed, pos));
4665
colonOffset = pos -
ps
.charPos;
4670
colonOffset = pos -
ps
.charPos;
4676
else if ( pos ==
ps
.charsUsed
4687
chars =
ps
.chars;
4694
colonPos = ( colonOffset == -1 ) ? -1 :
ps
.charPos + colonOffset;
4702
int offset = pos -
ps
.charPos;
4704
pos =
ps
.charPos + offset;
4722
if (
ps
.chars[endPos] != ';' ) {
4726
string entityName = nameTable.Add(
ps
.chars,
ps
.charPos, endPos -
ps
.charPos );
4727
ps
.charPos = endPos + 1;
4846
Debug.Assert(
ps
.appendMode );
4847
int initialPos =
ps
.charPos;
4852
ps
.charPos = initialPos;
4857
Encoding enc =
ps
.encoding;
4877
if ( v1Compat && pos ==
ps
.charsUsed - 1 &&
ps
.chars[pos] == (char)0 && await ReadDataAsync().ConfigureAwait(false) == 0 &&
ps
.isStreamEof ) {
4878
ps
.charsUsed--;
4995
curNode.AdjustLineInfo( readValueOffset,
ps
.eolNormalized, ref incReadLineInfo );
5016
incReadLineInfo.Set(
ps
.LineNo,
ps
.LinePos );
5026
charsRead = incReadDecoder.Decode(
ps
.chars, startPos, endPos - startPos );
5038
curNode.SetValue(
ps
.chars, startPos, endPos - startPos );
5040
AdjustLineInfo(
ps
.chars, startPos - charsRead, startPos,
ps
.eolNormalized, ref incReadLineInfo );