#include <CRDFUtilities.h>
Definition at line 19 of file CRDFUtilities.h.
CRDFUtilities::CRDFUtilities |
( |
| ) |
|
CRDFUtilities::~CRDFUtilities |
( |
| ) |
|
|
virtual |
bool CRDFUtilities::findNextElement |
( |
const std::string & |
rdfXml, |
|
|
const std::string & |
elementName, |
|
|
std::string::size_type & |
start, |
|
|
std::string::size_type & |
end |
|
) |
| |
|
static |
Find the the next XML element with the given name (either start or end).
- Parameters
-
const | std::string & rdfXml |
const | std::string & elementName |
std::string::size_type | & start |
std::string::size_type | & end |
- Returns
- bool found
Definition at line 181 of file CRDFUtilities.cpp.
Referenced by fixLocalFileAboutReference(), and fixSBMLRdf().
186 static std::string WhiteSpace =
"\x20\x09\x0D\x0A";
189 bool ignoreDouble =
false;
190 bool ignoreSingle =
false;
192 if (end >= rdfXml.length())
195 std::string::const_iterator it = rdfXml.begin() + end;
196 std::string::const_iterator itEnd = rdfXml.end();
198 if (*it ==
'>' && it < itEnd) ++it;
200 start = std::string::npos;
201 end = std::string::npos;
205 for (; it < itEnd && end == std::string::npos; ++it)
213 ignoreSingle = !ignoreSingle;
221 ignoreDouble = !ignoreDouble;
227 start = it - rdfXml.begin();
231 if (!ignore && start != std::string::npos)
232 end = it - rdfXml.begin();
240 if (end == std::string::npos)
243 if (elementName ==
"")
246 std::string::size_type NameStart = rdfXml.find_first_not_of(WhiteSpace, start + 1);
247 std::string::size_type NameEnd = rdfXml.find_first_of(WhiteSpace +
"/>", NameStart);
249 if (rdfXml.substr(NameStart, NameEnd - NameStart) == elementName)
252 start = std::string::npos;
253 end = std::string::npos;
unsigned C_INT32 CRDFUtilities::fixLocalFileAboutReference |
( |
std::string & |
rdfXml, |
|
|
const std::string & |
newId, |
|
|
const std::string & |
oldId |
|
) |
| |
|
static |
Fix local rdf:about attributes of the rdf:Description element. It returned the number of replacements made.
- Parameters
-
std::string | & rdfXml |
const | std::string & newId |
const | std::string & oldId |
- Returns
- unsigned C_INT32 replacements
Definition at line 21 of file CRDFUtilities.cpp.
References C_INT32, findNextElement(), and getNameSpaceQualifier().
Referenced by CAnnotation::operator==(), CAnnotation::setMiriamAnnotation(), and CSBMLExporter::updateMIRIAMAnnotation().
26 if (newId == oldId || rdfXml ==
"")
30 std::string Qualifier =
35 std::string::size_type start = 0;
36 std::string::size_type end = 0;
43 std::string::size_type pos = start;
46 pos = rdfXml.find(Qualifier +
"about=", start);
47 if (pos < end && pos != std::string::npos)
49 pos += Qualifier.length() + 6;
50 const char Quote = rdfXml[pos];
54 if (rdfXml[pos] ==
'#')
57 std::string::size_type len = rdfXml.find(Quote, pos) - pos;
62 rdfXml.substr(pos, len) == oldId)
64 rdfXml.replace(pos, len, newId);
static bool findNextElement(const std::string &rdfXml, const std::string &elementName, std::string::size_type &start, std::string::size_type &end)
static std::string getNameSpaceQualifier(const std::string &rdfXml, const std::string &nameSpace)
unsigned C_INT32 CRDFUtilities::fixSBMLRdf |
( |
std::string & |
rdfXml | ) |
|
|
static |
Fix broken SBML RDF: <dc:creator rdf:parseType="Resource"> <rdf:Bag> It is not allowed to use the attribute rdf:parseType="Resource" and <rdf:Bag> simultaneously
- Parameters
-
- Returns
- unsigned C_INT32 corrections
Definition at line 75 of file CRDFUtilities.cpp.
References C_INT32, findNextElement(), getNameSpaceQualifier(), and min.
Referenced by CRDFGraphConverter::SBML2Copasi().
82 std::string::size_type start = 0;
83 std::string::size_type end = 0;
84 std::string::size_type pos = 0;
93 std::string RDFQualifier =
99 if ((pos =
std::min(rdfXml.find(RDFQualifier +
"parseType=\"Resource\"", start),
100 rdfXml.find(RDFQualifier +
"parseType='Resource'", start))) > end)
106 std::string::size_type currentStart = start;
107 std::string::size_type currentEnd = end;
109 findNextElement(rdfXml, RDFQualifier +
"Bag", currentStart, currentEnd) &&
110 start == currentStart &&
114 rdfXml.erase(pos, RDFQualifier.length() + 20);
115 end -= RDFQualifier.length() + 20;
132 std::string VCardQualifier =
139 if ((pos =
std::min(rdfXml.find(RDFQualifier +
"parseType=\"Resource\"", start),
140 rdfXml.find(RDFQualifier +
"parseType='Resource'", start))) < end)
144 rdfXml.insert(end,
" " + RDFQualifier +
"parseType=\"Resource\"");
static bool findNextElement(const std::string &rdfXml, const std::string &elementName, std::string::size_type &start, std::string::size_type &end)
static std::string getNameSpaceQualifier(const std::string &rdfXml, const std::string &nameSpace)
std::string CRDFUtilities::getNameSpaceQualifier |
( |
const std::string & |
rdfXml, |
|
|
const std::string & |
nameSpace |
|
) |
| |
|
static |
Find the qualifier for the given name space. Please note the qualifier if found has a ':' already appended.
- Parameters
-
const | std::string & rdfXml |
const | std::string & nameSpace |
- Returns
- std::string qualifier
Definition at line 151 of file CRDFUtilities.cpp.
Referenced by fixLocalFileAboutReference(), and fixSBMLRdf().
154 std::string::size_type start = 0;
155 std::string::size_type end = 0;
160 start = rdfXml.find(
"xmlns:", end);
161 if (start == std::string::npos)
165 end = rdfXml.find(
"=", start);
166 if (end == std::string::npos)
169 if (rdfXml.compare(end + 1, nameSpace.length() + 2,
"\"" + nameSpace +
"\"") &&
170 rdfXml.compare(end + 1, nameSpace.length() + 2,
"'" + nameSpace +
"'"))
174 return rdfXml.substr(start, end - start) +
":";
The documentation for this class was generated from the following files: