本文整理汇总了C++中XMLAttributes::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLAttributes::getName方法的具体用法?C++ XMLAttributes::getName怎么用?C++ XMLAttributes::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLAttributes
的用法示例。
在下文中一共展示了XMLAttributes::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startElement
void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
{
string Name(name);
Element *temp_element;
working_string.erase();
if (!first_element_read) {
document = new Element(Name);
current_element = document;
first_element_read = true;
} else {
temp_element = new Element(Name);
temp_element->SetParent(current_element);
current_element->AddChildElement(temp_element);
current_element = temp_element;
}
if (current_element == 0L) {
std::stringstream error;
error << "In file " << getPath() << ": line " << getLine() << endl
<< "No current element read (running out of memory?)" << endl;
throw std::runtime_error(error.str());
}
current_element->SetLineNumber(getLine());
current_element->SetFileName(getPath());
for (int i=0; i<atts.size();i++) {
current_element->AddAttribute(atts.getName(i), atts.getValue(i));
}
}
示例2: startElement
void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
{
string Name(name);
Element *temp_element;
working_string.erase();
if (!first_element_read) {
document = new Element(Name);
current_element = document;
first_element_read = true;
} else {
temp_element = new Element(Name);
temp_element->SetParent(current_element);
current_element->AddChildElement(temp_element);
current_element = temp_element;
}
if (current_element == 0L) {
cerr << "No current element read (no top-level element in XML file?)" << endl;
exit (-1);
}
for (int i=0; i<atts.size();i++) {
current_element->AddAttribute(atts.getName(i), atts.getValue(i));
}
}
示例3: XMLAttributes
END_TEST
START_TEST (test_uncertml_attributes)
{
fail_unless ( node->getNumAttributes() == 0 );
XMLAttributes * attr = new XMLAttributes();
attr->add("definition", "http://");
int i = node->setAttributes(*(attr));
fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
fail_unless ( node->getNumAttributes() == 1 );
const XMLAttributes retrieved = node->getAttributes();
fail_unless ( retrieved.isEmpty() == false );
fail_unless ( retrieved.getLength() == 1 );
fail_unless ( retrieved.getName(0) == "definition" );
fail_unless ( retrieved.getValue(0) == "http://" );
i = node->unsetAttributes();
fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
fail_unless ( node->getNumAttributes() == 0 );
fail_unless ( node->getAttributes().isEmpty() == true );
}
示例4: getLevel
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields. Be sure to call your
* parents implementation of this method as well.
*/
void
Delay::readL3Attributes (const XMLAttributes& attributes)
{
const unsigned int level = getLevel();
const unsigned int version = getVersion();
std::vector<std::string> expectedAttributes;
expectedAttributes.clear();
expectedAttributes.push_back("metaid");
expectedAttributes.push_back("sboTerm");
// check that all attributes are expected
for (int i = 0; i < attributes.getLength(); i++)
{
std::vector<std::string>::const_iterator end = expectedAttributes.end();
std::vector<std::string>::const_iterator begin = expectedAttributes.begin();
std::string name = attributes.getName(i);
std::string prefix = attributes.getPrefix(i);
// only check attributes in the sbml namespace
if (prefix.empty() || prefix == "sbml")
{
if (std::find(begin, end, name) == end)
{
logUnknownAttribute(name, level, version, "<delay>");
}
}
}
//
// sboTerm: SBOTerm { use="optional" } (L2v3 ->)
//
mSBOTerm = SBO::readTerm(attributes, this->getErrorLog(), level, version);
}
示例5:
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields. Be sure to call your
* parents implementation of this method as well.
*/
void
CompositeDescription::readAttributes (const XMLAttributes& attributes)
{
NMBase::readAttributes(attributes);
const unsigned int level = NMBase::getLevel ();
const unsigned int version = NMBase::getVersion();
std::vector<std::string> expectedAttributes;
expectedAttributes.clear();
expectedAttributes.push_back("metaid");
expectedAttributes.push_back("id");
expectedAttributes.push_back("name");
expectedAttributes.push_back("ontologyTerm");
expectedAttributes.push_back("indexType");
// check that all attributes are expected
for (int i = 0; i < attributes.getLength(); i++)
{
std::vector<std::string>::const_iterator end = expectedAttributes.end();
std::vector<std::string>::const_iterator begin = expectedAttributes.begin();
std::string name = attributes.getName(i);
if (std::find(begin, end, name) == end)
{
logUnknownAttribute(name, level, version, "<compositeDescription>");
}
}
attributes.readInto("id", mId);
attributes.readInto("name", mName);
attributes.readInto("ontologyTerm", mOntologyTerm);
attributes.readInto("indexType", mIndexType);
}
示例6: populateDOMAttributes
static void
populateDOMAttributes(const XMLAttributes& src, XERCES_CPP_NAMESPACE::DOMElement* dest)
{
for (size_t i = 0; i < src.getCount(); ++i)
{
dest->setAttribute(XercesHelper::transcode(src.getName(i)).c_str(),
XercesHelper::transcode(src.getValue(i)).c_str());
}
}
示例7: getLevel
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields. Be sure to call your
* parents implementation of this method as well.
*/
void
InitialAssignment::readL2Attributes (const XMLAttributes& attributes)
{
SBase::readAttributes(attributes);
const unsigned int level = getLevel ();
const unsigned int version = getVersion();
if (version == 1)
{
logError(NotSchemaConformant, getLevel(), getVersion(),
"InitialAssignment is not a valid component for this level/version.");
return;
}
std::vector<std::string> expectedAttributes;
expectedAttributes.clear();
expectedAttributes.push_back("metaid");
expectedAttributes.push_back("symbol");
expectedAttributes.push_back("sboTerm");
// check that all attributes are expected
for (int i = 0; i < attributes.getLength(); i++)
{
std::vector<std::string>::const_iterator end = expectedAttributes.end();
std::vector<std::string>::const_iterator begin = expectedAttributes.begin();
std::string name = attributes.getName(i);
std::string prefix = attributes.getPrefix(i);
// only check attributes in the sbml namespace
if (prefix.empty() || prefix == "sbml")
{
if (std::find(begin, end, name) == end)
{
logUnknownAttribute(name, level, version, "<initialAssignment>");
}
}
}
//
// symbol: SId { use="required" } (L2v2 -> )
//
bool assigned = attributes.readInto("symbol", mSymbol, getErrorLog(), true);
if (assigned && mSymbol.size() == 0)
{
logEmptyString("symbol", level, version, "<initialAssignment>");
}
if (!SyntaxChecker::isValidSBMLSId(mSymbol)) logError(InvalidIdSyntax);
//
// sboTerm: SBOTerm { use="optional" } (L2v2 ->)
//
mSBOTerm = SBO::readTerm(attributes, this->getErrorLog(), level, version);
}
示例8:
LIBSBML_CPP_NAMESPACE_USE
/** @endcond */
CK_CPPSTART
START_TEST (test_XMLAttributes_add_get)
{
XMLAttributes attrs;
fail_unless( attrs.getLength() == 0 );
fail_unless( attrs.getNumAttributes() == 0 );
fail_unless( attrs.isEmpty() );
attrs.add("xmlns", "http://foo.org/");
fail_unless( attrs.getLength() == 1 );
fail_unless( attrs.getNumAttributes() == 1 );
fail_unless( attrs.isEmpty() == false );
attrs.add("foo", "bar");
fail_unless( attrs.getLength() == 2 );
fail_unless( attrs.getNumAttributes() == 2 );
fail_unless( attrs.isEmpty() == false );
fail_unless( attrs.getIndex("xmlns") == 0 );
fail_unless( attrs.getIndex("foo" ) == 1 );
fail_unless( attrs.getIndex("bar" ) == -1 );
fail_unless( attrs.getValue("xmlns") == "http://foo.org/" );
fail_unless( attrs.getValue("foo" ) == "bar" );
fail_unless( attrs.getValue("bar" ) == "" );
fail_unless( attrs.getName(0) == "xmlns" );
fail_unless( attrs.getName(1) == "foo" );
fail_unless( attrs.getName(2) == "" );
}
示例9: startElement
void plotXMLVisitor::startElement (const char * name, const XMLAttributes &atts)
{
current_element = name;
for (int i=0; i<atts.size();i++) {
if (string(atts.getName(i)) == string("axis")) {
if (string(atts.getValue(i)) == string("x")) axis = eX;
else if (string(atts.getValue(i)) == string("y2")) axis = eY2;
else axis = eY;
} else {
cerr << "Unknown attribute " << atts.getName(i) << " encountered." << endl;
exit (-1);
}
if (i == 1) {
cerr << "Too many attributes. Offending attribute (item:" << i << ") is " << atts.getName(i) << endl;
exit (-1);
}
}
if (!first_element_read) {
if (current_element != string("plotset")) {
cerr << endl << " This is not a valid plotset description (" << current_element << ")" << endl;
exit (-1);
} else {
first_element_read = true;
}
}
if (current_element == "page") {
vPages.push_back(Page());
inPage = true;
} else if (current_element == "plot") {
if (!inPage) {
vPlots.push_back(Plots());
} else {
vPages.back().vPlots.push_back(Plots());
}
}
}
示例10: tripleCharge
/*
* Read values from the given XMLAttributes set into their specific fields.
*/
void
FbcSpeciesPlugin::readAttributes (const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes)
{
// dont call this as all it does it log unknown attributes
// SBasePlugin::readAttributes(attributes, expectedAttributes);
for (int i = 0; i < attributes.getLength(); i++)
{
std::string name = attributes.getName(i);
std::string uri = attributes.getURI(i);
if (uri != mURI) continue;
if (!expectedAttributes.hasAttribute(name))
{
getErrorLog()->logPackageError("fbc", FbcSpeciesAllowedL3Attributes,
getPackageVersion(), getLevel(), getVersion());
}
}
if (mSBMLExt->getLevel(mURI) > 2)
{
XMLTriple tripleCharge("charge", mURI, mPrefix);
unsigned int numErrs = getErrorLog()->getNumErrors();
mIsSetCharge = attributes.readInto(tripleCharge, mCharge, getErrorLog(),
false, getLine(), getColumn());
if (mIsSetCharge == false)
{
if (getErrorLog()->getNumErrors() == numErrs + 1 &&
getErrorLog()->contains(XMLAttributeTypeMismatch))
{
getErrorLog()->remove(XMLAttributeTypeMismatch);
getErrorLog()->logPackageError("fbc", FbcSpeciesChargeMustBeInteger,
getPackageVersion(), getLevel(), getVersion());
}
}
XMLTriple tripleChemicalFormula("chemicalFormula", mURI, mPrefix);
bool assigned = attributes.readInto(tripleChemicalFormula, mChemicalFormula);
if (assigned == true)
{
parseChemicalFormula(mChemicalFormula, *(getErrorLog()), getPackageVersion(),
getLevel(), getVersion());
}
}
}
示例11: getLevel
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields.
*/
void
SBasePlugin::readAttributes (const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes)
{
if (&attributes == NULL || &expectedAttributes == NULL ) return;
const unsigned int sbmlLevel = getLevel ();
const unsigned int sbmlVersion = getVersion();
const unsigned int pkgVersion = getPackageVersion();
std::string element = (mParent) ? mParent->getElementName() : std::string();
//
// (NOTE)
//
// This function is just used to identify unexpected
// attributes with the prefix of the package.
//
#if 0
std::cout << "[DEBUG] SBasePlugin::readAttributes() " << element << std::endl;
#endif
//
// check that all attributes of this plugin object are expected
//
for (int i = 0; i < attributes.getLength(); i++)
{
std::string name = attributes.getName(i);
std::string uri = attributes.getURI(i);
#if 0
std::cout << "[DEBUG] SBasePlugin::readAttributes() name : " << name
<< " uri " << uri << std::endl;
#endif
if (uri != mURI) continue;
if (!expectedAttributes.hasAttribute(name))
{
logUnknownAttribute(name, sbmlLevel, sbmlVersion, pkgVersion, element);
}
}
}
示例12: getLevel
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields. Be sure to call your
* parents implementation of this method as well.
*/
void
OntologyTerm::readAttributes (const XMLAttributes& attributes)
{
NMBase::readAttributes(attributes);
const unsigned int level = getLevel ();
const unsigned int version = getVersion();
std::vector<std::string> expectedAttributes;
expectedAttributes.clear();
expectedAttributes.push_back("metaid");
expectedAttributes.push_back("id");
expectedAttributes.push_back("term");
expectedAttributes.push_back("sourceTermId");
expectedAttributes.push_back("ontologyURI");
// check that all attributes are expected
for (int i = 0; i < attributes.getLength(); i++)
{
std::vector<std::string>::const_iterator end = expectedAttributes.end();
std::vector<std::string>::const_iterator begin = expectedAttributes.begin();
std::string name = attributes.getName(i);
if (std::find(begin, end, name) == end)
{
logUnknownAttribute(name, level, version, "<ontologyTerm>");
}
}
const string id = "id";
bool assigned = attributes.readInto(id, mId, getErrorLog(), true);
if (assigned && mId.size() == 0)
{
logEmptyString(id, level, version, "<ontologyTerm>");
}
if (!SyntaxChecker::isValidSBMLSId(mId)) logError(NUMLInvalidIdSyntax);
attributes.readInto("term", mTerm);
attributes.readInto("sourceTermId", mSourceTermId);
attributes.readInto("ontologyURI", mOntologyURI);
}
示例13: if
//.........这里部分代码省略.........
for (unsigned int n = 0; n < object->getCVTerms()->getSize(); n++)
{
if (static_cast <CVTerm *> (object->getCVTerms()->get(n))
->getQualifierType() == MODEL_QUALIFIER)
{
prefix = "bqmodel";
uri = "http://biomodels.net/model-qualifiers/";
switch (static_cast <CVTerm *> (object->getCVTerms()->get(n))
->getModelQualifierType())
{
case BQM_IS:
name = "is";
break;
case BQM_IS_DESCRIBED_BY:
name = "isDescribedBy";
break;
case BQM_UNKNOWN:
return NULL;
break;
}
}
else if (static_cast <CVTerm *> (object->getCVTerms()->get(n))
->getQualifierType() == BIOLOGICAL_QUALIFIER)
{
prefix = "bqbiol";
uri = "http://biomodels.net/biological-qualifiers/";
switch (static_cast <CVTerm *> (object->getCVTerms()->get(n))
->getBiologicalQualifierType())
{
case BQB_IS:
name = "is";
break;
case BQB_HAS_PART:
name = "hasPart";
break;
case BQB_IS_PART_OF:
name = "isPartOf";
break;
case BQB_IS_VERSION_OF:
name = "isVersionOf";
break;
case BQB_HAS_VERSION:
name = "hasVersion";
break;
case BQB_IS_HOMOLOG_TO:
name = "isHomologTo";
break;
case BQB_IS_DESCRIBED_BY:
name = "isDescribedBy";
break;
case BQB_IS_ENCODED_BY:
name = "isEncodedBy";
break;
case BQB_ENCODES:
name = "encodes";
break;
case BQB_OCCURS_IN:
name = "occursIn";
break;
case BQB_UNKNOWN:
return NULL;
break;
}
}
else
{
continue;
}
resources = static_cast <CVTerm *> (object->getCVTerms()->get(n))
->getResources();
XMLNode bag(bag_token);
for (int r = 0; r < resources->getLength(); r++)
{
XMLAttributes att;
att.add(resources->getName(r), resources->getValue(r));
XMLToken li_token(li_triple, att);
li_token.setEnd();
XMLNode li(li_token);
bag.addChild(li);
}
XMLTriple type_triple(name, uri, prefix);
XMLToken type_token(type_triple, blank_att);
XMLNode type(type_token);
type.addChild(bag);
description->addChild(type);
}
}
return description;
}
示例14: logUnknownAttribute
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields. Be sure to call your
* parents implementation of this method as well.
*/
void
NUMLDocument::readAttributes (const XMLAttributes& attributes)
{
NMBase::readAttributes(attributes);
std::vector<std::string> expectedAttributes;
expectedAttributes.clear();
expectedAttributes.push_back("level");
expectedAttributes.push_back("version");
expectedAttributes.push_back("metaid");
expectedAttributes.push_back("schemaLocation");
// check that all attributes are expected
for (int i = 0; i < attributes.getLength(); i++)
{
std::vector<std::string>::const_iterator end = expectedAttributes.end();
std::vector<std::string>::const_iterator begin = expectedAttributes.begin();
std::string name = attributes.getName(i);
if (std::find(begin, end, name) == end)
{
logUnknownAttribute(name, getLevel(), getVersion(), "<numl>");
}
}
//
// level: positiveInteger { use="required" fixed="1" } (L1v1)
//
attributes.readInto("level", mLevel, getErrorLog(), true);
//
// version: positiveInteger { use="required" fixed="1" } (L1v1, L2v1)
// version: positiveInteger { use="required" fixed="2" } (L1v2, L2v2)
// version: positiveInteger { use="required" fixed="3" } (L2v3)
//
attributes.readInto("version", mVersion, getErrorLog(), true);
/* check that the level and version are valid */
if (mLevel == 1)
{
if (mVersion > 2)
{
logError(InvalidNUMLLevelVersion);
}
}
else
{
logError(InvalidNUMLLevelVersion);
return;
}
/* check that numl namespace has been set */
unsigned int match = 0;
if (mNUMLNamespaces->getNamespaces() == NULL)
{
logError(NUMLInvalidNamespaceOnNUML);
}
else
{
for (int n = 0; n < mNUMLNamespaces->getNamespaces()->getLength(); n++)
{
if (!strcmp(mNUMLNamespaces->getNamespaces()->getURI(n).c_str(), "http://www.numl.org/numl/level1/version1"))
{
match = 1;
if (mLevel != 1)
{
logError(NUMLMissingOrInconsistentLevel);
}
if (mVersion != 1)
{
logError(NUMLMissingOrInconsistentVersion);
}
break;
}
}
if (match == 0)
{
logError(NUMLInvalidNamespaceOnNUML);
}
else
{
mNUMLNamespaces->setLevel(mLevel);
mNUMLNamespaces->setVersion(mVersion);
}
}
}
示例15: if
bool
ASTBase::readAttributes(const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes,
XMLInputStream& stream, const XMLToken& element)
{
bool read = true;
//
// check that all attributes are expected
//
for (int i = 0; i < attributes.getLength(); i++)
{
std::string name = attributes.getName(i);
std::string uri = attributes.getURI(i);
std::string prefix = attributes.getPrefix(i);
//
// To allow prefixed attribute whose namespace doesn't belong to
// core or extension package.
//
// (e.g. xsi:type attribute in Curve element in layout extension)
//
if (!prefix.empty())
{
if ( expectedAttributes.hasAttribute(prefix + ":" + name) ) continue;
}
if (!expectedAttributes.hasAttribute(name))
{
std::string message = "The attribute '" + name + "' is not permitted" +
" on a <" + element.getName() + "> element.";
if (name == "type")
{
logError(stream, element, DisallowedMathTypeAttributeUse, message);
}
else if (name == "encoding")
{
logError(stream, element, DisallowedMathMLEncodingUse, message);
}
else if (name == "definitionURL")
{
logError(stream, element, DisallowedDefinitionURLUse, message);
}
else if (name == "units")
{
if (stream.getSBMLNamespaces() != NULL
&& stream.getSBMLNamespaces()->getLevel() > 2)
{
logError(stream, element, DisallowedMathUnitsUse, message);
}
else
{
message = "The 'units' attribute was introduced in SBML Level 3.";
logError(stream, element, InvalidMathMLAttribute, message);
}
}
else
{
logError(stream, element, InvalidMathElement, message);
}
// not sufficient to make the read bad
//return false;
}
}
string id;
string className;
string style;
attributes.readInto( "id" , id );
attributes.readInto( "class" , className );
attributes.readInto( "style" , style );
if (!id.empty())
{
if (setId(id) != LIBSBML_OPERATION_SUCCESS)
{
read = false;
}
}
if (!className.empty())
{
if (setClass(className) != LIBSBML_OPERATION_SUCCESS)
{
read = false;
}
}
if (!style.empty())
{
if (setStyle(style) != LIBSBML_OPERATION_SUCCESS)
{
read = false;
}
}
//.........这里部分代码省略.........