| 
    SNAP Library 2.1, User Reference
    2013-09-25 10:47:25
    
   SNAP, a general purpose, high performance system for analysis and manipulation of large networks 
   | 
  
  
  
 
#include <xml.h>
Public Member Functions | |
| void | SkipWs () | 
| TXmlLx (const PSIn &_SIn, const TXmlSpacing &_Spacing=xspIntact) | |
| TXmlLx & | operator= (const TXmlLx &) | 
| TXmlLxSym | GetSym () | 
| TStr | GetSymStr () const | 
| void | EThrow (const TStr &MsgStr) const | 
| TStr | GetFPosStr () const | 
| void | ClrArgV () | 
| void | AddArg (const TStr &ArgNm, const TStr &ArgVal) | 
| bool | IsArgNm (const TStr &ArgNm) const | 
| int | GetArgs () const | 
| void | GetArg (const int &ArgN, TStr &ArgNm, TStr &ArgVal) const | 
| TStr | GetArgVal (const TStr &ArgNm, const TStr &DfVal=TStr()) const | 
| bool | IsEntityNm (const TStr &EntityNm, TStr &EntityVal) const | 
| void | PutEntityVal (const TStr &Nm, const TStr &Val) | 
| bool | IsPEntityNm (const TStr &EntityNm, TStr &EntityVal) const | 
| void | PutPEntityVal (const TStr &Nm, const TStr &Val) | 
Static Public Member Functions | |
| static char | GetArgValQCh (const TStr &ArgVal) | 
| static TStr | GetXmlLxSymStr (const TXmlLxSym &XmlLxSym) | 
| static bool | IsTagNm (const TStr &Str) | 
| static TStr | GetXmlStrFromPlainMem (const TMem &PlainMem) | 
| static TStr | GetXmlStrFromPlainStr (const TChA &PlainChA) | 
| static TStr | GetPlainStrFromXmlStr (const TStr &XmlStr) | 
| static TStr | GetUsAsciiStrFromXmlStr (const TStr &EntRefStr) | 
| static TStr | GetChRefFromYuEntRef (const TStr &YuEntRefStr) | 
Public Attributes | |
| TXmlLxSym | Sym | 
| TChA | TxtChA | 
| TStr | TagNm | 
| TStrKdV | ArgNmValKdV | 
Private Member Functions | |
| uchar | GetCh () | 
| void | PutCh (const uchar &_Ch) | 
| void | PutStr (const TStr &Str) | 
| void | ToNrSpacing () | 
| void | GetWs (const bool &IsRq) | 
| TStr | GetReference () | 
| void | GetEq () | 
| TStr | GetName () | 
| TStr | GetName (const TStr &RqNm) | 
| void | GetComment () | 
| TStr | GetAttValue () | 
| TStr | GetVersionNum () | 
| TStr | GetEncName () | 
| TStr | GetStalVal () | 
| void | GetXmlDecl () | 
| void | GetPI () | 
| TStr | GetSystemLiteral () | 
| TStr | GetPubidLiteral () | 
| TStr | GetPEReference () | 
| void | GetExternalId () | 
| void | GetNData () | 
| void | GetDocTypeDecl () | 
| void | GetElement () | 
| void | GetAttList () | 
| TStr | GetEntityValue () | 
| void | GetEntity () | 
| void | GetNotation () | 
| void | GetCDSect () | 
Private Attributes | |
| PSIn | SIn | 
| TSIn & | RSIn | 
| TChA | ChStack | 
| uchar | PrevCh | 
| uchar | Ch | 
| int | LnN | 
| int | LnChN | 
| int | ChN | 
| TXmlSpacing | Spacing | 
| TStrStrH | EntityNmToValH | 
| TStrStrH | PEntityNmToValH | 
Static Private Attributes | |
| static TXmlChDef | ChDef | 
| TXmlLx::TXmlLx | ( | const PSIn & | _SIn, | 
| const TXmlSpacing & | _Spacing = xspIntact  | 
        ||
| ) |  [inline] | 
        
| void TXmlLx::AddArg | ( | const TStr & | ArgNm, | 
| const TStr & | ArgVal | ||
| ) |  [inline] | 
        
Definition at line 161 of file xml.h.
                                                    {
    ArgNmValKdV.Add(TStrKd(ArgNm, ArgVal));}
| void TXmlLx::ClrArgV | ( | ) |  [inline] | 
        
Definition at line 160 of file xml.h.
{ArgNmValKdV.Clr();}
| void TXmlLx::EThrow | ( | const TStr & | MsgStr | ) | const | 
Definition at line 885 of file xml.cpp.
                                            {
  TChA FPosChA;
  FPosChA+=" [File:"; FPosChA+=SIn->GetSNm();
  FPosChA+=" Line:"; FPosChA+=TInt::GetStr(LnN);
  FPosChA+=" Char:"; FPosChA+=TInt::GetStr(LnChN);
  FPosChA+="]";
  TStr FullMsgStr=MsgStr+FPosChA;
  TExcept::Throw(FullMsgStr);
}
| void TXmlLx::GetArg | ( | const int & | ArgN, | 
| TStr & | ArgNm, | ||
| TStr & | ArgVal | ||
| ) |  const [inline] | 
        
Definition at line 166 of file xml.h.
                                                                {
    ArgNm=ArgNmValKdV[ArgN].Key; ArgVal=ArgNmValKdV[ArgN].Dat;}
| int TXmlLx::GetArgs | ( | ) |  const [inline] | 
        
Definition at line 165 of file xml.h.
{return ArgNmValKdV.Len();}
| TStr TXmlLx::GetArgVal | ( | const TStr & | ArgNm, | 
| const TStr & | DfVal = TStr()  | 
        ||
| ) |  const [inline] | 
        
Definition at line 168 of file xml.h.
                                                                    {
    int ArgN=ArgNmValKdV.SearchForw(TStrKd(ArgNm));
    if (ArgN==-1){return DfVal;} else {return ArgNmValKdV[ArgN].Dat;}}
| static char TXmlLx::GetArgValQCh | ( | const TStr & | ArgVal | ) |  [inline, static] | 
        
| void TXmlLx::GetAttList | ( | ) |  [private] | 
        
| TStr TXmlLx::GetAttValue | ( | ) |  [private] | 
        
Definition at line 457 of file xml.cpp.
                        {
  // [10]  AttValue ::=  '"' ([^<&"] | Reference)* '"'
  //  |  "'" ([^<&'] | Reference)* "'"
  uchar QCh=Ch;
  if ((QCh!='"')&&(QCh!='\'')){EThrow("Invalid attribute-value start.");}
  TChA ValChA; GetCh();
  forever {
    if ((Ch=='<')||(!ChDef.IsChar(Ch))){
      EThrow("Invalid attribute-value character.");}
    if (Ch==QCh){GetCh(); break;} // final quote
    else if (Ch=='&'){GetCh(); ValChA+=GetReference();} // reference
    else {ValChA+=Ch; GetCh();} // usual char
  }
  return ValChA;
}
| void TXmlLx::GetCDSect | ( | ) |  [private] | 
        
Definition at line 733 of file xml.cpp.
                      {
  // [18]  CDSect ::=  CDStart CData CDEnd
  // [19]  CDStart ::=  '<![CDATA{{['}}
  // [20]  CData ::=  (Char* - (Char* ']]>' Char*))
  // [21]  CDEnd ::=  ']]>'
  if (Ch=='['){GetCh();}
  else {EThrow("Invalid start of CDATA section.");}
  TxtChA.Clr();
  forever {
    if (!ChDef.IsChar(Ch)){EThrow("Invalid CDATA character.");}
    if ((Ch=='>')&&(TxtChA.Len()>=2)&&
     (TxtChA.LastLastCh()==']') && (TxtChA.LastCh()==']')){
      GetCh(); TxtChA.Pop(); TxtChA.Pop(); break;
    } else {
      TxtChA+=Ch; GetCh();
    }
  }
}
| uchar TXmlLx::GetCh | ( | ) |  [private] | 
        
| TStr TXmlLx::GetChRefFromYuEntRef | ( | const TStr & | YuEntRefStr | ) |  [static] | 
        
Definition at line 1072 of file xml.cpp.
                                                        {
  TStr ChRefStr=YuEntRefStr;
  ChRefStr.ChangeStrAll("&ch;", "è");
  ChRefStr.ChangeStrAll("&Ch;", "È");
  ChRefStr.ChangeStrAll("&sh;", "š");
  ChRefStr.ChangeStrAll("&Sh;", "Š");
  ChRefStr.ChangeStrAll("&zh;", "ž");
  ChRefStr.ChangeStrAll("&Zh;", "Ž");
  ChRefStr.ChangeStrAll("&cs", "c");
  ChRefStr.ChangeStrAll("&Cs;", "C");
  ChRefStr.ChangeStrAll("&dz;", "dz");
  ChRefStr.ChangeStrAll("&Dz;", "Dz");
  return ChRefStr;
}
| void TXmlLx::GetComment | ( | ) |  [private] | 
        
Definition at line 436 of file xml.cpp.
                       {
  // [15] Comment ::=  {{'<!-}}-' ((Char - '-') | ('-' (Char - '-')))* '-->'
  if (GetCh()!='-'){EThrow("Invalid comment start.");}
  TxtChA.Clr();
  forever {
    GetCh();
    if (!ChDef.IsChar(Ch)){EThrow("Invalid comment character.");}
    if (Ch=='-'){
      if (GetCh()=='-'){
        if (GetCh()=='>'){GetCh(); break;} // final bracket
        else {EThrow("Invalid comment end.");}
      } else {
        if (!ChDef.IsChar(Ch)){EThrow("Invalid comment character.");}
        TxtChA+='-'; TxtChA+=Ch; // special case if single '-'
      }
    } else {
      TxtChA+=Ch; // usual char
    }
  }
}
| void TXmlLx::GetDocTypeDecl | ( | ) |  [private] | 
        
Definition at line 627 of file xml.cpp.
                           {
  // [28] doctypedecl ::=  {{'<!DOCTYPE'}} S Name (S ExternalID)? S?
  //  ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
  GetWs(true);
  TStr DocTypeDeclNm=GetName();
  GetWs(false);
  if (Ch=='>'){GetCh(); return;}
  if (Ch!='['){GetExternalId();}
  GetWs(false);
  if (Ch=='['){
    GetCh();
    // [28] (markupdecl | PEReference | S)*
    GetWs(false);
    while (Ch!=']'){
      if (ChDef.IsWs(Ch)){GetWs(true);}
      else if (Ch=='%'){GetPEReference();}
      else {
        GetSym();
      }
    }
    GetCh();
  }
  GetWs(false);
  // '>'
  if (Ch=='>'){GetCh();}
  else {EThrow("Invalid end-of-tag in document-type-declaration.");}
  TagNm=DocTypeDeclNm;
}
| void TXmlLx::GetElement | ( | ) |  [private] | 
        
| TStr TXmlLx::GetEncName | ( | ) |  [private] | 
        
Definition at line 493 of file xml.cpp.
                       {
  // [80] EncodingDecl ::=  {{S 'encoding' Eq}} ('"' EncName '"' |  "'" EncName "'" )
  // [81] EncName ::=  [A-Za-z] ([A-Za-z0-9._] | '-')*
  char QCh=Ch;
  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
  TChA EncNmChA;
  GetCh();
  if ((('a'<=Ch)&&(Ch<='z'))||(('A'<=Ch)&&(Ch<='Z'))){EncNmChA+=Ch;}
  else {EThrow("Invalid encoding-name character.");}
  GetCh();
  while (Ch!=QCh){
    if ((('a'<=Ch)&&(Ch<='z'))||(('A'<=Ch)&&(Ch<='Z'))||
     (('0'<=Ch)&&(Ch<='9'))||(Ch=='.')||(Ch=='_')||(Ch=='-')){EncNmChA+=Ch;}
    else {EThrow("Invalid version-number character.");}
    GetCh();
  }
  GetCh();
  return EncNmChA;
}
| void TXmlLx::GetEntity | ( | ) |  [private] | 
        
Definition at line 690 of file xml.cpp.
                      {
  // [70] EntityDecl ::=  GEDecl | PEDecl
  // [71] GEDecl ::=  '<!ENTITY' S Name S EntityDef S? '>'
  // [72] PEDecl ::=  '<!ENTITY' S '%' S Name S PEDef S? '>'
  GetWs(true); TStr EntityNm;
  if (Ch=='%'){
    GetCh(); GetWs(true); EntityNm=GetName(); GetWs(true);
    // [74] PEDef ::=  EntityValue | ExternalID
    if ((Ch=='\"')||(Ch=='\'')){
      TStr EntityVal=GetEntityValue();
      PutPEntityVal(EntityNm, EntityVal);
    } else {
      GetExternalId();
      GetWs(false);
      if (Ch!='>'){GetNData();}
    }
  } else {
    EntityNm=GetName(); GetWs(true);
    // [73] EntityDef ::=  EntityValue | (ExternalID NDataDecl?)
    if ((Ch=='\"')||(Ch=='\'')){
      TStr EntityVal=GetEntityValue();
      PutEntityVal(EntityNm, EntityVal);
    } else {
      GetExternalId();
    }
  }
  GetWs(false);
  if (Ch=='>'){GetCh();}
  else {EThrow("Invalid end-of-tag in entity-declaration.");}
  TagNm=EntityNm;
}
| TStr TXmlLx::GetEntityValue | ( | ) |  [private] | 
        
Definition at line 674 of file xml.cpp.
                           {
  // [9]  EntityValue ::=  '"' ([^%&"] | PEReference | Reference)* '"'
  //  | "'" ([^%&'] | PEReference | Reference)* "'"
  uchar QCh=Ch;
  if ((QCh!='"')&&(QCh!='\'')){EThrow("Invalid entity-value start.");}
  TChA ValChA; GetCh();
  forever {
    if (!ChDef.IsChar(Ch)){EThrow("Invalid entity-value character.");}
    if (Ch==QCh){GetCh(); break;} // final quote
    else if (Ch=='&'){GetCh(); ValChA+=GetReference();} // reference
    else if (Ch=='%'){GetCh(); ValChA+=GetPEReference();} // pereference
    else {ValChA+=Ch; GetCh();} // usual char
  }
  return ValChA;
}
| void TXmlLx::GetEq | ( | ) |  [private] | 
        
| void TXmlLx::GetExternalId | ( | ) |  [private] | 
        
Definition at line 609 of file xml.cpp.
                          {
  // ExternalID ::=  'SYSTEM' S SystemLiteral
  //  | 'PUBLIC' S PubidLiteral S SystemLiteral
  TStr ExtIdNm=GetName();
  if (ExtIdNm=="SYSTEM"){
    GetWs(true); GetSystemLiteral();
  } else if (ExtIdNm=="PUBLIC"){
    GetWs(true); GetPubidLiteral(); GetWs(true); GetSystemLiteral();
  } else {
    EThrow("Invalid external-id ('SYSTEM' or 'PUBLIC' expected).");
  }
}
| TStr TXmlLx::GetFPosStr | ( | ) | const | 
Definition at line 895 of file xml.cpp.
                              {
  TChA FPosChA;
  FPosChA+=" [File:"; FPosChA+=SIn->GetSNm();
  FPosChA+=" Line:"; FPosChA+=TInt::GetStr(LnN);
  FPosChA+=" Char:"; FPosChA+=TInt::GetStr(LnChN);
  FPosChA+="]";
  return FPosChA;
}
| TStr TXmlLx::GetName | ( | ) |  [private] | 
        
Definition at line 416 of file xml.cpp.
                    {
  // [5] Name ::=  (Letter | '_' | ':') (NameChar)*
  TChA NmChA;
  if (ChDef.IsFirstNameCh(Ch)){
    do {NmChA+=Ch;} while (ChDef.IsName(GetCh()));
  } else {
    EThrow("Invalid first name character.");
    // EThrow(TStr::Fmt("Invalid first name character [%u:'%c%c%c%c%c'].", 
    //  uint(Ch), Ch, RSIn.GetCh(), RSIn.GetCh(), RSIn.GetCh(), RSIn.GetCh()));
  }
  return NmChA;
}
| TStr TXmlLx::GetName | ( | const TStr & | RqNm | ) |  [private] | 
        
| void TXmlLx::GetNData | ( | ) |  [private] | 
        
| void TXmlLx::GetNotation | ( | ) |  [private] | 
        
| TStr TXmlLx::GetPEReference | ( | ) |  [private] | 
        
Definition at line 397 of file xml.cpp.
                           {
  // [69]  PEReference ::=  '%' Name ';'
  TStr EntityNm=GetName();
  if ((EntityNm.Empty())||(Ch!=';')){EThrow("Invalid PEntity-Reference.");}
  GetCh();
  TStr EntityVal;
  if (IsPEntityNm(EntityNm, EntityVal)){/*intentionaly empty*/}
  else {EThrow(TStr("PEntity-Reference (")+EntityNm+") does not exist.");}
  return EntityVal;
}
| void TXmlLx::GetPI | ( | ) |  [private] | 
        
Definition at line 562 of file xml.cpp.
                  {
  // [16]  PI ::=  {{'<?' PITarget}} (S (Char* - (Char* '?>' Char*)))? '?>'
  // [17]  PITarget ::=  Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
  GetWs(false);
  TxtChA.Clr();
  forever {
    if (!ChDef.IsChar(Ch)){EThrow("Invalid PI character.");}
    if (Ch=='?'){
      if (GetCh()=='>'){
        GetCh(); break;
      } else {
        if (!ChDef.IsChar(Ch)){EThrow("Invalid PI character.");}
        TxtChA+='?'; TxtChA+=Ch; // special case if single '?'
      }
    } else {
      TxtChA+=Ch; // usual char
    }
    GetCh();
  }
}
| TStr TXmlLx::GetPlainStrFromXmlStr | ( | const TStr & | XmlStr | ) |  [static] | 
        
Definition at line 991 of file xml.cpp.
                                                    {
  TChA PlainChA;
  TChRet Ch(TStrIn::New(XmlStr));
  Ch.GetCh();
  while (!Ch.Eof()){
    if (Ch()!='&'){
      PlainChA+=Ch(); Ch.GetCh();
    } else {
      // [67] Reference ::=  EntityRef | CharRef
      if (Ch.GetCh()=='#'){
        // [66]  CharRef ::=  '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
        TChA RefChA; int RefCd=0;
        if (Ch.GetCh()=='x'){
          // hex-decimal character code
          forever {
            Ch.GetCh();
            if (TCh::IsHex(Ch())){
              RefChA+=Ch();
              RefCd=RefCd*16+TCh::GetHex(Ch());
            } else {
              break;
            }
          }
        } else {
          // decimal character code
          forever {
            if (TCh::IsNum(Ch())){
              RefChA+=Ch();
              RefCd=RefCd*10+TCh::GetNum(Ch());
            } else {
              break;
            }
            Ch.GetCh();
          }
        }
        if ((!RefChA.Empty())&&(Ch()==';')){
          Ch.GetCh();
                  if (RefCd < 0x80) {
                        // ascii character
                        uchar RefCh=uchar(RefCd);
                        PlainChA+=RefCh;
                  } else {
                        // unicode
                        TUnicode::EncodeUtf8(RefCd, PlainChA);
                  }
        }
      } else {
        // [68]  EntityRef ::=  '&' Name ';'
        TChA EntityNm;
        while ((!Ch.Eof())&&(Ch()!=';')){
          EntityNm+=Ch(); Ch.GetCh();}
        if ((!EntityNm.Empty())&&(Ch()==';')){
          Ch.GetCh();
          if (EntityNm=="quot"){PlainChA+='"';}
          else if (EntityNm=="amp"){PlainChA+='&';}
          else if (EntityNm=="apos"){PlainChA+='\'';}
          else if (EntityNm=="lt"){PlainChA+='<';}
          else if (EntityNm=="gt"){PlainChA+='>';}
        }
      }
    }
  }
  return PlainChA;
}
| TStr TXmlLx::GetPubidLiteral | ( | ) |  [private] | 
        
Definition at line 596 of file xml.cpp.
                            {
  // [12]  PubidLiteral ::=  '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
  char QCh=Ch;
  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
  TChA LitChA; GetCh();
  while (Ch!=QCh){
    if (!ChDef.IsPubid(Ch)){EThrow("Invalid Public-Id-Literal character.");}
    LitChA+=Ch; GetCh();
  }
  GetCh();
  return LitChA;
}
| TStr TXmlLx::GetReference | ( | ) |  [private] | 
        
Definition at line 340 of file xml.cpp.
                         {
  // [67] Reference ::=  EntityRef | CharRef
  if (Ch=='#'){
    // [66]  CharRef ::=  '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
    TChA RefChA; int RefCd=0;
    if (GetCh()=='x'){
      // hex-decimal character code
      forever {
        GetCh();
        if (TCh::IsHex(Ch)){
          RefChA+=Ch;
          RefCd=RefCd*16+TCh::GetHex(Ch);
        } else {
          break;
        }
      }
    } else {
      // decimal character code
      forever {
        if (TCh::IsNum(Ch)){
          RefChA+=Ch;
          RefCd=RefCd*10+TCh::GetNum(Ch);
        } else {
          break;
        }
        GetCh();
      }
    }
    if ((!RefChA.Empty())&&(Ch==';')){
      GetCh();
          if (RefCd < 0x80) {
                  // 8-bit char
              uchar RefCh=uchar(RefCd);
                  return TStr(RefCh);
          } else {
                  TStr ResStr = TUnicode::EncodeUtf8(RefCd);
                  return ResStr;
          }
    } else {
      EThrow("Invalid Char-Reference."); Fail; return TStr();
    }
  } else {
    // [68]  EntityRef ::=  '&' Name ';'
    TStr EntityNm=GetName();
    if ((!EntityNm.Empty())&&(Ch==';')){
      GetCh();
      TStr EntityVal;
      if (IsEntityNm(EntityNm, EntityVal)){/*intentionaly empty*/}
      else if (ChDef.IsEntityNm(EntityNm, EntityVal)){/*intentionaly empty*/}
      else {EThrow(TStr("Entity-Reference (")+EntityNm+") does not exist.");}
      return EntityVal;
    } else {
      EThrow("Invalid Entity-Reference."); Fail; return TStr();
    }
  }
}
| TStr TXmlLx::GetStalVal | ( | ) |  [private] | 
        
Definition at line 513 of file xml.cpp.
                       {
  // [32] SDDecl ::=  {{S 'standalone' Eq}}
  //  (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
  char QCh=Ch;
  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
  TChA StalChA;
  GetCh();
  while (Ch!=QCh){
    if (('a'<=Ch)&&(Ch<='z')){StalChA+=Ch;}
    else {EThrow("Invalid standalone-value character.");}
    GetCh();
  }
  GetCh();
  TStr StalVal=StalChA;
  if ((StalVal=="yes")||(StalVal=="no")){return StalVal;}
  else {EThrow("Invalid standalone-value."); Fail; return TStr();}
}
Definition at line 757 of file xml.cpp.
                        {
  if (Ch=='<'){
    GetCh(); ClrArgV();
    if (Ch=='?'){
      GetCh(); TagNm=GetName();
      if (TagNm.GetLc()=="xml"){Sym=xsyXmlDecl; GetXmlDecl();}
      else {Sym=xsyPI; GetPI();}
    } else
    if (Ch=='!'){
      GetCh();
      if (Ch=='['){
        GetCh(); TagNm=GetName();
        if (TagNm=="CDATA"){Sym=xsyQStr; GetCDSect();}
        else {EThrow(TStr("Invalid tag after '<![' (")+TagNm+").");}
      } else
      if (Ch=='-'){
        Sym=xsyComment; GetComment();
      } else {
        TagNm=GetName();
        if (TagNm=="DOCTYPE"){GetDocTypeDecl(); Sym=xsyDocTypeDecl;}
        else if (TagNm=="ELEMENT"){GetElement(); Sym=xsyElement;}
        else if (TagNm=="ATTLIST"){GetAttList(); Sym=xsyAttList;}
        else if (TagNm=="ENTITY"){GetEntity(); Sym=xsyEntity;}
        else if (TagNm=="NOTATION"){GetNotation(); Sym=xsyNotation;}
        else {EThrow(TStr("Invalid tag (")+TagNm+").");}
      }
    } else
    if (Ch=='/'){
      // xsyETag
      GetCh(); Sym=xsyETag; TagNm=GetName(); GetWs(false);
      if (Ch=='>'){GetCh();}
      else {EThrow("Invalid End-Tag.");}
    } else {
      // xsySTag or xsySETag
      TagNm=GetName(); GetWs(false);
      while ((Ch!='>')&&(Ch!='/')){
        TStr AttrNm=GetName();
        GetEq();
        TStr AttrVal=GetAttValue();
        GetWs(false);
        AddArg(AttrNm, AttrVal);
      }
      if (Ch=='/'){
        if (GetCh()=='>'){Sym=xsySETag; GetCh();}
        else {EThrow("Invalid Empty-Element-Tag.");}
      } else {
        Sym=xsySTag; GetCh();
      }
    }
    if (Spacing==xspTruncate){SkipWs();}
  } else
  if (ChDef.IsWs(Ch)){
    Sym=xsyWs; GetWs(true); ToNrSpacing();
    if (Spacing==xspTruncate){GetSym();}
  } else
  if (Ch==TCh::EofCh){
    Sym=xsyEof;
  } else {
    Sym=xsyStr; TxtChA.Clr();
    // [14]  CharData ::=  [^<&]* - ([^<&]* ']]>' [^<&]*)
    forever {
      if (!ChDef.IsChar(Ch)){
        EThrow(TUInt::GetStr(Ch, "Invalid character (%d)."));}
                // GetCh();  continue; // skip invalid characters
      if (Ch=='<'){break;} // tag
      if (Ch=='&'){GetCh(); TxtChA+=GetReference();} // reference
      else {
        if ((Ch=='>')&&(TxtChA.Len()>=2)&&
         (TxtChA.LastLastCh()==']')&&(TxtChA.LastCh()==']')){
          EThrow("Forbidden substring ']]>' in character data.");}
        TxtChA+=Ch; GetCh(); // usual char
      }
    }
    ToNrSpacing();
  }
  return Sym;
}
| TStr TXmlLx::GetSymStr | ( | ) | const | 
Definition at line 835 of file xml.cpp.
                             {
  TChA SymChA;
  switch (Sym){
    case xsyUndef:
      SymChA="{Undef}"; break;
    case xsyWs:
      SymChA+="{Space:'"; SymChA+=TStr(TxtChA).GetHex(); SymChA+="'}"; break;
    case xsyComment:
      SymChA+="<!--"; SymChA+=TxtChA; SymChA+="-->"; break;
    case xsyXmlDecl:{
      SymChA+="<?"; SymChA+=TagNm;
      for (int ArgN=0; ArgN<GetArgs(); ArgN++){
        TStr ArgNm; TStr ArgVal; GetArg(ArgN, ArgNm, ArgVal);
        char ArgValQCh=GetArgValQCh(ArgVal);
        SymChA+=' '; SymChA+=ArgNm; SymChA+='=';
        SymChA+=ArgValQCh; SymChA+=ArgVal; SymChA+=ArgValQCh;
      }
      SymChA+="?>"; break;}
    case xsyPI:
      SymChA+="<?"; SymChA+=TagNm;
      if (!TxtChA.Empty()){SymChA+=' '; SymChA+=TxtChA;}
      SymChA+="?>"; break;
    case xsyDocTypeDecl:
      SymChA+="<!DOCTYPE "; SymChA+=TagNm; SymChA+=">"; break;
    case xsySTag:
    case xsySETag:{
      SymChA+="<"; SymChA+=TagNm;
      for (int ArgN=0; ArgN<GetArgs(); ArgN++){
        TStr ArgNm; TStr ArgVal; GetArg(ArgN, ArgNm, ArgVal);
        char ArgValQCh=GetArgValQCh(ArgVal);
        SymChA+=' '; SymChA+=ArgNm; SymChA+='=';
        SymChA+=ArgValQCh; SymChA+=ArgVal; SymChA+=ArgValQCh;
      }
      if (Sym==xsySTag){SymChA+=">";}
      else if (Sym==xsySETag){SymChA+="/>";}
      else {Fail;}
      break;}
    case xsyETag:
      SymChA+="</"; SymChA+=TagNm; SymChA+=">"; break;
    case xsyStr:
      SymChA="{String:'"; SymChA+=TxtChA; SymChA+="'}"; break;
    case xsyQStr:
      SymChA="{QString:'"; SymChA+=TxtChA; SymChA+="'}"; break;
    case xsyEof:
      SymChA="{Eof}"; break;
    default: Fail;
  }
  return SymChA;
}
| TStr TXmlLx::GetSystemLiteral | ( | ) |  [private] | 
        
Definition at line 583 of file xml.cpp.
                             {
  // [11]  SystemLiteral ::=  ('"' [^"]* '"') | ("'" [^']* "'")
  char QCh=Ch;
  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
  TChA LitChA; GetCh();
  while (Ch!=QCh){
    if (!ChDef.IsChar(Ch)){EThrow("Invalid System-Literal character.");}
    LitChA+=Ch; GetCh();
  }
  GetCh();
  return LitChA;
}
| TStr TXmlLx::GetUsAsciiStrFromXmlStr | ( | const TStr & | EntRefStr | ) |  [static] | 
        
Definition at line 1056 of file xml.cpp.
                                                      {
  TStr UsAsciiStr=XmlStr;
  UsAsciiStr.ChangeStrAll("è", "c");
  UsAsciiStr.ChangeStrAll("È", "C");
  UsAsciiStr.ChangeStrAll("š", "s");
  UsAsciiStr.ChangeStrAll("Š", "S");
  UsAsciiStr.ChangeStrAll("ž", "z");
  UsAsciiStr.ChangeStrAll("Ž", "Z");
  TChA UsAsciiChA=TXmlLx::GetPlainStrFromXmlStr(UsAsciiStr);
  for (int ChN=0; ChN<UsAsciiChA.Len(); ChN++){
    char Ch=UsAsciiChA[ChN];
    if ((Ch<' ')||('~'<Ch)){UsAsciiChA.PutCh(ChN, 'x');}
  }
  return UsAsciiChA;
}
| TStr TXmlLx::GetVersionNum | ( | ) |  [private] | 
        
Definition at line 473 of file xml.cpp.
                          {
  // [24] VersionInfo ::=  {{S 'version' Eq}} (' VersionNum ' | " VersionNum ")
  // [26] VersionNum ::=  ([a-zA-Z0-9_.:] | '-')+
  char QCh=Ch;
  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
  TChA VerNumChA;
  GetCh();
  do {
    if ((('a'<=Ch)&&(Ch<='z'))||(('A'<=Ch)&&(Ch<='Z'))||
     (('0'<=Ch)&&(Ch<='9'))||(Ch=='_')||(Ch=='.')||(Ch==':')||(Ch=='-')){
      VerNumChA+=Ch;
    } else {
      EThrow("Invalid version-number character.");
    }
    GetCh();
  } while (Ch!=QCh);
  GetCh();
  return VerNumChA;
}
| void TXmlLx::GetWs | ( | const bool & | IsRq | ) |  [private] | 
        
| void TXmlLx::GetXmlDecl | ( | ) |  [private] | 
        
Definition at line 531 of file xml.cpp.
                       {
  // [23] XMLDecl ::=  {{'<?xml'}}... VersionInfo EncodingDecl? SDDecl? S? '?>'
  // [24] VersionInfo ::=  S 'version' Eq (' VersionNum ' | " VersionNum ")
  GetWs(true);
  TStr VerNm=GetName("version"); GetEq(); TStr VerVal=GetVersionNum();
  if (VerVal!="1.0"){EThrow("Invalid XML version.");}
  AddArg(VerNm, VerVal);
  GetWs(false);
  if (Ch!='?'){
    // EncodingDecl ::=  {{S}} 'encoding' Eq
    //  ('"' EncName '"' |  "'" EncName "'" )
    TStr EncNm=GetName("encoding"); GetEq(); TStr EncVal=GetEncName();
    AddArg(EncNm, EncVal);
  }
  GetWs(false);
  if (Ch!='?'){
    // SDDecl ::=  {{S}} 'standalone' Eq
    //  (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
    TStr StalNm=GetName("standalone"); GetEq(); TStr StalVal=GetStalVal();
    AddArg(StalNm, StalVal);
  }
  GetWs(false);
  if (Ch=='?'){
    GetCh();
    if (Ch=='>'){GetCh();}
    else {EThrow("Invalid end-of-tag in XML-declaration.");}
  } else {
    EThrow("Invalid end-of-tag in XML-declaration.");
  }
}
| TStr TXmlLx::GetXmlLxSymStr | ( | const TXmlLxSym & | XmlLxSym | ) |  [static] | 
        
Definition at line 904 of file xml.cpp.
                                                    {
  switch (XmlLxSym){
    case xsyUndef: return "Undef";
    case xsyWs: return "White-Space";
    case xsyComment: return "Comment";
    case xsyXmlDecl: return "Declaration";
    case xsyPI: return "PI";
    case xsyDocTypeDecl: return "Document-Type";
    case xsyElement: return "Element";
    case xsyAttList: return "Attribute-List";
    case xsyEntity: return "Entity";
    case xsyNotation: return "Notation";
    case xsyTag: return "Tag";
    case xsySTag: return "Start-Tag";
    case xsyETag: return "End-Tag";
    case xsySETag: return "Start-End-Tag";
    case xsyStr: return "String";
    case xsyQStr: return "Quoted-String";
    case xsyEof: return "Eon-Of-File";
    default: return "Undef";
  }
}
| TStr TXmlLx::GetXmlStrFromPlainMem | ( | const TMem & | PlainMem | ) |  [static] | 
        
Definition at line 945 of file xml.cpp.
                                                      {
  TChA XmlChA;
  for (int ChN=0; ChN<PlainMem.Len(); ChN++){
    uchar Ch=PlainMem[ChN];
    if ((' '<=Ch)&&(Ch<='~')){
      switch (Ch){
        case '"': XmlChA+="""; break;
        case '&': XmlChA+="&"; break;
        case '\'': XmlChA+="'"; break;
        case '<': XmlChA+="<"; break;
        case '>': XmlChA+=">"; break;
        default: XmlChA+=Ch;
      }
    } else
    if ((Ch=='\r')||(Ch=='\n')){
      XmlChA+=Ch;
    } else {
      XmlChA+='&'; XmlChA+='#'; XmlChA+=TUInt::GetStr(Ch); XmlChA+=';';
    }
  }
  return XmlChA;
}
| TStr TXmlLx::GetXmlStrFromPlainStr | ( | const TChA & | PlainChA | ) |  [static] | 
        
Definition at line 968 of file xml.cpp.
                                                      {
  TChA XmlChA;
  for (int ChN=0; ChN<PlainChA.Len(); ChN++){
    uchar Ch=PlainChA[ChN];
    if ((' '<=Ch)&&(Ch<='~')){
      switch (Ch){
        case '"': XmlChA+="""; break;
        case '&': XmlChA+="&"; break;
        case '\'': XmlChA+="'"; break;
        case '<': XmlChA+="<"; break;
        case '>': XmlChA+=">"; break;
        default: XmlChA+=Ch;
      }
    } else
    if ((Ch=='\r')||(Ch=='\n')){
      XmlChA+=Ch;
    } else {
      XmlChA+='&'; XmlChA+='#'; XmlChA+=TUInt::GetStr(Ch); XmlChA+=';';
    }
  }
  return XmlChA;
}
| bool TXmlLx::IsArgNm | ( | const TStr & | ArgNm | ) |  const [inline] | 
        
Definition at line 163 of file xml.h.
                                        {
    return ArgNmValKdV.IsIn(TStrKd(ArgNm));}
| bool TXmlLx::IsEntityNm | ( | const TStr & | EntityNm, | 
| TStr & | EntityVal | ||
| ) |  const [inline] | 
        
Definition at line 175 of file xml.h.
                                                               {
    return EntityNmToValH.IsKeyGetDat(EntityNm, EntityVal);}
| bool TXmlLx::IsPEntityNm | ( | const TStr & | EntityNm, | 
| TStr & | EntityVal | ||
| ) |  const [inline] | 
        
Definition at line 179 of file xml.h.
                                                                {
    return PEntityNmToValH.IsKeyGetDat(EntityNm, EntityVal);}
| bool TXmlLx::IsTagNm | ( | const TStr & | Str | ) |  [static] | 
        
| void TXmlLx::PutCh | ( | const uchar & | _Ch | ) |  [inline, private] | 
        
| void TXmlLx::PutEntityVal | ( | const TStr & | Nm, | 
| const TStr & | Val | ||
| ) |  [inline] | 
        
Definition at line 177 of file xml.h.
                                                    {
    EntityNmToValH.AddDat(Nm, Val);}
| void TXmlLx::PutPEntityVal | ( | const TStr & | Nm, | 
| const TStr & | Val | ||
| ) |  [inline] | 
        
Definition at line 181 of file xml.h.
                                                     {
    PEntityNmToValH.AddDat(Nm, Val);}
| void TXmlLx::PutStr | ( | const TStr & | Str | ) |  [inline, private] | 
        
| void TXmlLx::SkipWs | ( | ) | 
| void TXmlLx::ToNrSpacing | ( | ) |  [private] | 
        
Definition at line 270 of file xml.cpp.
                        {
  if (Spacing==xspIntact){
  } else
  if (Spacing==xspPreserve){
    int SrcChN=0; int DstChN=0;
    while (SrcChN<TxtChA.Len()){
      if (TxtChA[SrcChN]==TCh::CrCh){
        TxtChA.PutCh(DstChN, TCh::LfCh); SrcChN++; DstChN++;
        if ((SrcChN<TxtChA.Len())&&(TxtChA[SrcChN]==TCh::LfCh)){SrcChN++;}
      } else {
        if (SrcChN!=DstChN){
          TxtChA.PutCh(DstChN, TxtChA[SrcChN]);}
        SrcChN++; DstChN++;
      }
    }
    TxtChA.Trunc(DstChN);
  } else
  if (Spacing==xspSeparate){
    // squeeze series of white-spaces to single space
    int SrcChN=0; int DstChN=0;
    while (SrcChN<TxtChA.Len()){
      if (ChDef.IsWs(TxtChA[SrcChN])){
        if ((DstChN>0)&&(TxtChA[DstChN-1]==' ')){
          SrcChN++;
        } else {
          TxtChA.PutCh(DstChN, ' ');
          SrcChN++; DstChN++;
        }
      } else {
        TxtChA.PutCh(DstChN, TxtChA[SrcChN]);
        SrcChN++; DstChN++;
      }
    }
    TxtChA.Trunc(DstChN);
  } else
  if (Spacing==xspTruncate){
    // cut leading and trailing white-spaces and
    // squeeze series of white-spaces to single space
    int SrcChN=0; int DstChN=0;
    while (SrcChN<TxtChA.Len()){
      if (ChDef.IsWs(TxtChA[SrcChN])){
        if ((DstChN>0)&&(TxtChA[DstChN-1]==' ')){
          SrcChN++;
        } else {
          TxtChA.PutCh(DstChN, ' ');
          SrcChN++; DstChN++;
        }
      } else {
        TxtChA.PutCh(DstChN, TxtChA[SrcChN]);
        SrcChN++; DstChN++;
      }
    }
    TxtChA.Trunc(DstChN);
    // delete trailing white-spaces
    while ((TxtChA.Len()>0)&&(ChDef.IsWs(TxtChA.LastCh()))){
      TxtChA.Pop();}
  } else {
    Fail;
  }
}
uchar TXmlLx::Ch [private] | 
        
TXmlChDef TXmlLx::ChDef [static, private] | 
        
int TXmlLx::ChN [private] | 
        
TChA TXmlLx::ChStack [private] | 
        
TStrStrH TXmlLx::EntityNmToValH [private] | 
        
int TXmlLx::LnChN [private] | 
        
int TXmlLx::LnN [private] | 
        
TStrStrH TXmlLx::PEntityNmToValH [private] | 
        
uchar TXmlLx::PrevCh [private] | 
        
TSIn& TXmlLx::RSIn [private] | 
        
PSIn TXmlLx::SIn [private] | 
        
TXmlSpacing TXmlLx::Spacing [private] |