43 #define NCBI_USE_ERRCODE_X Serial_Parsers
102 ParseError(
"Unexpected end-of-file",
"keyword");
146 string str1, str2, data2;
161 ParseError(
"Unexpected data",
"attribute (name=\"value\")");
176 string::size_type
first = 0,
last = data2.length()-1;
177 if (data2.length() < 2 ||
178 (data2[
first] !=
'\"' && data2[
first] !=
'\'') ||
179 (data2[
last] !=
'\"' && data2[
last] !=
'\'') ) {
180 ParseError(
"Unexpected data",
"attribute (name=\"value\")");
231 if (ns ==
"http://www.w3.org/2001/XMLSchema") {
233 }
else if (ns ==
"http://schemas.xmlsoap.org/wsdl/") {
235 }
else if (ns ==
"http://schemas.xmlsoap.org/wsdl/soap/") {
268 }
else if (
IsValue(
"boolean")) {
279 }
else if (
IsValue(
"hexBinary")) {
281 }
else if (
IsValue(
"base64Binary")) {
303 }
else if (
IsValue(
"IDREFS")) {
305 }
else if (
IsValue(
"NMTOKEN")) {
307 }
else if (
IsValue(
"NMTOKENS")) {
309 }
else if (
IsValue(
"ENTITY")) {
311 }
else if (
IsValue(
"ENTITIES")) {
314 }
else if (
IsValue(
"boolean")) {
327 }
else if (
IsValue(
"base64Binary")) {
401 if (
IsValue(
"http://www.w3.org/XML/1998/namespace") ||
403 string name =
"xml:lang";
505 for ( tok = l.
Skip(); ; tok = l.
Skip()) {
551 if (m == -1 || m > 1) {
570 string name,
value, name_space;
571 bool ref=
false, named_type=
false;
579 ParseError(
"ref attribute not allowed for root elements",
"");
618 qualified =
IsValue(
"qualified");
626 if (owner && !name.empty()) {
635 bool hasContents =
false;
640 if (!ref && !named_type) {
704 bool hasContents=
false;
773 if (emb != 0 && extended) {
1025 ParseError(
"enum restriction not supported",
"string or integer type");
1046 bool ref=
false, named_type=
false;
1070 }
else if (
IsValue(
"optional")) {
1072 }
else if (
IsValue(
"prohibited")) {
1080 qualified =
IsValue(
"qualified");
1086 if (!ref && !named_type) {
1150 <<
"Unsupported element type: union; in node "
1165 <<
"Unsupported element type: list; in node "
1307 <<
"Unsupported attribute type: union; in attribute "
1321 <<
"Unsupported attribute type: list; in attribute "
1333 string emb_name(name);
1334 emb_name +=
"__emb#__";
1349 id =
string(
"type:") + name;
1352 id =
string(
"group:") + name;
1355 id =
string(
"attgroup:") + name;
1358 id =
string(
"interface:") + name;
1361 id =
string(
"binding:") + name;
1369 string msg(
"Namespace prefix not defined: ");
1371 ParseError(msg.c_str(),
"namespace declaration");
1382 string id, name, data;
1384 data +=
"<" +
m_Raw;
1386 data +=
" " +
m_Raw;
1414 bool doctag_open =
false;
1422 if (!comm.
Empty()) {
1429 if (!closing.empty()) {
1430 if (!comments.
Empty()) {
1438 doctag_open =
false;
1443 data +=
"<" +
m_Raw;
1448 if (
m_Raw ==
"/>") {
1461 data +=
"<" +
m_Raw;
1463 data +=
" " +
m_Raw;
1473 if (!comments.
Empty()) {
1503 if (j->second.GetName() == node.
GetName() &&
1569 if (!k->second.IsEmbedded() && k->second.IsNamed() &&
1570 k->second.GetName() == node.
GetName() &&
1620 else if (processed.
find(
i->second.GetName() +
i->second.GetNamespaceName())
1621 == processed.
end()) {
1627 processed.
insert(
i->second.GetName() +
i->second.GetNamespaceName());
1642 list<DTDAttribute>::iterator
a;
1643 for (
a = atts.begin();
a != atts.end(); ++
a) {
1645 if (!
a->GetTypeName().empty()) {
1674 list<DTDAttribute>::iterator
a;
1675 for (
a = atts.begin();
a != atts.end(); ++
a) {
1677 a->GetTypeName().empty() &&
1690 i->second.MergeAttributes();
1746 #if defined(NCBI_DTDPARSER_TRACE)
1747 void XSDParser::PrintDocumentTree(
void)
1749 cout <<
" === Namespaces ===" << endl;
1752 cout <<
i->first <<
": " <<
i->second << endl;
1755 cout <<
" === Target namespace ===" << endl;
1758 cout <<
" === Element form default ===" << endl;
1760 cout <<
" === Attribute form default ===" << endl;
1764 DTDParser::PrintDocumentTree();
1767 cout <<
" === Standalone Attribute definitions ===" << endl;
1770 PrintAttribute(
a->second,
false);
void FlushCommentsTo(CComments &comments)
int CurrentLine(void) const
const AbstractToken & NextToken(void) const
AbstractLexer & Lexer(void)
virtual void ParseError(const char *error, const char *expected, const AbstractToken &token)
void CopyComments(CComments &comments)
string GetText(void) const
CComments & Comments(void)
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
void AddEnumValue(const string &value, int line, int id=0)
void SetName(const string &name)
void SetQualified(bool qualified)
void SetValueType(EValueType valueType)
void SetTypeIfUnknown(EType type)
void SetValue(const string &value)
void SetTypeName(const string &name)
const string & GetName(void) const
void SetSourceLine(int line)
CComments & Comments(void)
void SetName(const string &name)
const string & GetTypeName(void) const
void AddContent(const string &ref_name)
void SetTypeIfUnknown(EType type)
void SetTypeName(const string &name)
void AddFacet(const CMemberFacet &c)
bool IsEmbedded(void) const
void ResetType(EType type)
const list< CMemberFacet > & GetRestrictions(void) const
void SetSourceLine(int line)
void SetOccurrence(const string &ref_name, EOccurrence occ)
void SetGlobalType(bool def)
list< DTDAttribute > & GetNonconstAttributes(void)
EOccurrence GetOccurrence(const string &ref_name) const
CComments & AttribComments(void)
bool IsQualified(void) const
void SetQualified(bool qualified)
CComments & Comments(void)
void SetNamed(bool named=true)
bool HasAttributes(void) const
const string & GetName(void) const
const string & GetNamespaceName(void) const
void SetGlobalGroup(bool def)
const list< string > & GetContent(void) const
void AddAttribute(DTDAttribute &attrib)
void SetEmbedded(bool set=true)
void SetNamespaceName(const string &name)
EType GetType(void) const
const string & GetData(void) const
void GetParseAttributes(string &namespaceName, bool &elementForm, bool &attributeForm, map< string, string > &prefixToNamespace) const
const string & GetName(void) const
EType GetType(void) const
void SetData(const string &data)
void SetName(const string &name)
virtual void EndCommentBlock(void) override
map< string, DTDEntity > m_MapEntity
void FixEmbeddedNames(DTDElement &node)
map< string, DTDElement > m_MapElement
virtual bool PopEntityLexer(void)
list< string > m_StackLexerName
stack< AbstractLexer * > m_StackLexer
virtual string GetLocation(void) override
void SetCommentsIfEmpty(CComments *comments)
virtual DTDEntity * PushEntityLexer(const string &name)
static const string & s_SpecialName
TToken GetNextToken(void)
void AddElementContent(DTDElement &node, string &id_name, char separator=0)
bool ProcessDocumentation(void)
string ParseAttributeContent(void)
bool DefineAttributeType(DTDAttribute &att)
void ProcessNamedTypes(void)
stack< bool > m_StackAttributeFormDefault
stack< string > m_StackTargetNamespace
map< string, pair< string, string > > m_RawAttributes
virtual void BuildDocumentTree(CDataTypeModule &module) override
EElementNamespace GetElementNamespace(const string &prefix)
void ParseGroupRef(DTDElement &node)
void ParseSimpleType(DTDElement &node)
virtual bool PopEntityLexer(void) override
void ParseComplexType(DTDElement &node)
bool m_ElementFormDefault
map< string, string > m_PrefixToNamespace
void ParseUnion(DTDElement &node)
DTDElement::EOccurrence ParseMinOccurs(DTDElement &node, DTDElement::EOccurrence occNow)
TToken GetNextToken(void)
string ParseElementContent(DTDElement *owner, int emb)
string CreateTmpEmbeddedName(const string &name, int emb)
bool GetAttribute(const string &att)
bool DefineElementType(DTDElement &node)
void ParseAnnotation(void)
stack< bool > m_StackElementFormDefault
DTDElement::EOccurrence ParseMaxOccurs(DTDElement &node, DTDElement::EOccurrence occNow)
stack< map< string, string > > m_StackPrefixToNamespace
void ParseDocumentation(void)
void ParseAttribute(DTDElement &node)
void ParseSimpleContent(DTDElement &node)
XSDParser(XSDLexer &lexer)
virtual DTDEntity * PushEntityLexer(const string &name) override
stack< map< string, string > > m_StackNamespaceToPrefix
void ParseExtension(DTDElement &node)
void ParseAttributeGroup(DTDElement &node)
void ParseTypeDefinition(DTDEntity &ent)
bool IsAttribute(const char *att) const
void CreateTypeDefinition(DTDEntity::EType type)
map< string, string > m_NamespaceToPrefix
bool m_EnableNamespaceRedefinition
void ParseAny(DTDElement &node)
string ParseGroup(DTDElement *owner, int emb)
string CreateEntityId(const string &name, DTDEntity::EType type, const string *prefix=NULL)
void BeginScope(DTDEntity *ent)
void ParseList(DTDElement &node)
void ParseAttributeGroupRef(DTDElement &node)
virtual AbstractLexer * CreateEntityLexer(CNcbiIstream &in, const string &name, bool autoDelete=true) override
map< string, DTDAttribute > m_MapAttribute
virtual void BeginDocumentTree(void) override
TToken GetRawAttributeSet(void)
bool IsValue(const char *value) const
bool m_AttributeFormDefault
set< string > m_EmbeddedNames
void ParseFacet(DTDElement &node, TToken tok)
void ParseContainer(DTDElement &node)
void ParseRestriction(DTDElement &node)
void ParseEnumeration(DTDElement &node)
bool ParseContent(DTDElement &node, bool extended=false)
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
void Warning(CExceptionArgs_Base &args)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static int strcmp(const char *s1, const char *s2)
String compare.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
unsigned int
A callback function used to compare two keys in a database.
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
constexpr bool empty(list< Ts... >) noexcept
std::istream & in(std::istream &in_, double &x_)
double f(double x_, const double &y_)
static const char * prefix[]
static pcre_uint8 * buffer