Changeset 12 for trunk/src/engine.c


Ignore:
Timestamp:
Dec 25, 2007, 5:55:15 AM (11 years ago)
Author:
cameron
Message:

Text declarations for external parsed entities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine.c

    r11 r12  
    583583  else {Error_action(decl_start, AbsPos()); return;}
    584584  Advance(5);
    585   xml_info.has_version_decl = true;
    586585  if (at_PI_End()) {Advance(2); return;}
    587586  if (!S_at(0)) {Error_action(decl_start, AbsPos()); return;}
     
    627626  else {Error_action(decl_start, AbsPos()); return;}
    628627}
     628
     629// Similar to reading the XML_declaration of the document entity,
     630// ReadTextDeclaration reads the text declaration of an external
     631// parsed entity.  This is not really needed at present, for DTDless
     632// processing.
     633void ParsingEngine::ReadTextDeclaration(Entity_Declaration_Info& xml_info) {
     634  int BOM = lex->BOM_size(0);
     635  xml_info.has_ByteOrderMark = BOM > 0;
     636  xml_info.has_version_decl = false;
     637  xml_info.has_encoding_decl = false;
     638  xml_info.has_standalone_decl = false;
     639  Advance(BOM);
     640  int decl_start = AbsPos();
     641  // It is possible that there is no XML declaration.
     642  if (!at_XmlDecl_start()) return;
     643  // Otherwise, the text declaration exists and may have
     644  // version information.
     645  Advance(6);
     646  ScanTo(NonWS);
     647  if (at_version()) {
     648    xml_info.has_version_decl = true;
     649    Advance(7);
     650    ScanTo(NonWS);
     651    if (!AtChar('=')) {Error_action(decl_start, AbsPos()); return;}
     652    Advance(1);
     653    ScanTo(NonWS);
     654    if (at_1_0()) xml_info.version = 0;
     655    else if (at_1_1()) xml_info.version = 1;
     656    else {Error_action(decl_start, AbsPos()); return;}
     657    Advance(5);
     658    // Must have whitespace character before declaration.
     659    if (!S_at(0)) {Error_action(decl_start, AbsPos()); return;}
     660    ScanTo(NonWS);
     661  }
     662  if (!at_encoding()) {Error_action(decl_start, AbsPos()); return;}
     663  xml_info.has_encoding_decl = true;
     664  Advance(8);
     665  ScanTo(NonWS);
     666  if (!AtChar('=')) {Error_action(decl_start, AbsPos()); return;}
     667  Advance(1);
     668  ScanTo(NonWS);
     669  xml_info.encoding_start_pos = AbsPos()+1;
     670  if (AtChar('"')) {
     671      Advance(1);
     672      ScanTo(DQuote);
     673      if (!AtChar('"')) {Error_action(decl_start, AbsPos()); return;}
     674  }
     675  else if (AtChar('\'')) {
     676      Advance(1);
     677      ScanTo(SQuote);
     678      if (!AtChar('\'')) {Error_action(decl_start, AbsPos()); return;}
     679  }
     680  else {Error_action(decl_start, AbsPos()); return;}
     681  xml_info.encoding_end_pos = AbsPos();
     682  Advance(1);
     683  ScanTo(NonWS);
     684  if (at_PI_End()) {Advance(2); return;}
     685  else {Error_action(decl_start, AbsPos()); return;}
     686}
Note: See TracChangeset for help on using the changeset viewer.