本文整理汇总了C++中XMLAttributes::add方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLAttributes::add方法的具体用法?C++ XMLAttributes::add怎么用?C++ XMLAttributes::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLAttributes
的用法示例。
在下文中一共展示了XMLAttributes::add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processElement
void TinyXMLDocument::processElement(const TiXmlElement* element)
{
// build attributes block for the element
XMLAttributes attrs;
const TiXmlAttribute *currAttr = element->FirstAttribute();
while (currAttr)
{
attrs.add((encoded_char*)currAttr->Name(), (encoded_char*)currAttr->Value());
currAttr = currAttr->Next();
}
// start element
d_handler->elementStart((encoded_char*)element->Value(), attrs);
// do children
const TiXmlNode* childNode = element->FirstChild();
while (childNode)
{
switch(childNode->Type())
{
case TiXmlNode::CEGUI_TINYXML_ELEMENT:
processElement(childNode->ToElement());
break;
case TiXmlNode::CEGUI_TINYXML_TEXT:
if (childNode->ToText()->Value() != '\0')
d_handler->text((encoded_char*)childNode->ToText()->Value());
break;
// Silently ignore unhandled node type
};
childNode = childNode->NextSibling();
}
// end element
d_handler->elementEnd((encoded_char*)element->Value());
}
示例2: XMLAttributes
END_TEST
START_TEST (test_MathMLFormatter_semantics_ann)
{
const char* expected = wrapMathML
(
" <semantics>\n"
" <apply>\n"
" <lt/>\n"
" <ci> x </ci>\n"
" <cn type=\"integer\"> 0 </cn>\n"
" </apply>\n"
" <annotation encoding=\"bar\">foo</annotation>\n"
" </semantics>\n"
);
XMLAttributes xa = XMLAttributes();
xa.add("encoding", "bar");
XMLTriple triple = XMLTriple("annotation", "", "");
XMLToken ann_token = XMLToken(triple, xa);
XMLNode *ann = new XMLNode(ann_token);
XMLToken text = XMLToken("foo");
XMLNode textNode = XMLNode(text);
ann->addChild(textNode);
N = SBML_parseFormula("lt(x, 0)");
N->setSemanticsFlag();
N->addSemanticsAnnotation(ann);
S = writeMathMLToString(N);
fail_unless( equals(expected, S) );
}
示例3: XMLAttributes
END_TEST
START_TEST (test_MathMLFromAST_semantics_url)
{
const char* expected = wrapMathML
(
" <semantics definitionURL=\"foobar\">\n"
" <apply>\n"
" <lt/>\n"
" <ci> x </ci>\n"
" <cn type=\"integer\"> 0 </cn>\n"
" </apply>\n"
" </semantics>\n"
);
XMLAttributes *xa = new XMLAttributes();
xa->add("definitionURL", "foobar");
N = new ASTNode(AST_SEMANTICS);
ASTNode *c2 = new ASTNode(AST_RELATIONAL_LT);
ASTNode *c2_1 = new ASTNode(AST_NAME);
c2_1->setName("x");
ASTNode *c2_2 = new ASTNode(AST_INTEGER);
c2_2->setValue(0);
c2->addChild(c2_1);
c2->addChild(c2_2);
N->addChild(c2);
N->setDefinitionURL(*xa);
S = writeMathMLToString(N);
fail_unless( equals(expected, S) );
}
示例4: 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;
}
示例5:
LIBSBML_EXTERN
void
addGraphicalObjectAttributes(const GraphicalObject& object,XMLAttributes& att)
{
att.add("id",object.getId());
}
示例6: addTextAttributes
/*
* Adds the text rendering attributes of the given Text object
* to the given XMLAttributes object.
*/
void Text::addTextAttributes(const Text& text,XMLAttributes& att)
{
if(text.isSetFontFamily())
{
att.add("font-family",text.mFontFamily);
}
if(text.isSetFontSize())
{
std::ostringstream os;
os << text.getFontSize();
att.add("font-size",os.str());
}
switch(text.mFontStyle)
{
// if it has been set to normal, we
// have to write it because otherwise it is assumed to
// be inherited
case Text::STYLE_UNSET:
break;
case Text::STYLE_NORMAL:
att.add("font-style","normal");
break;
case Text::STYLE_ITALIC:
att.add("font-style","italic");
break;
}
switch(text.mFontStyle)
{
case Text::WEIGHT_UNSET:
break;
case Text::WEIGHT_NORMAL:
// if it has been set to normal, we
// have to write it because otherwise it is assumed to
// be inherited
att.add("font-weight","normal");
break;
case Text::WEIGHT_BOLD:
att.add("font-weight","bold");
break;
}
if(text.isSetTextAnchor())
{
switch(text.mTextAnchor)
{
// if it has been set to normal, we
// have to write it because otherwise it is assumed to
// be inherited
case Text::ANCHOR_START:
att.add("text-anchor","start");
break;
case Text::ANCHOR_END:
att.add("text-anchor","end");
break;
case Text::ANCHOR_MIDDLE:
att.add("text-anchor","middle");
break;
case Text::ANCHOR_UNSET:
break;
}
}
if(text.isSetVTextAnchor())
{
switch(text.mVTextAnchor)
{
// if it has been set to normal, we
// have to write it because otherwise it is assumed to
// be inherited
case Text::ANCHOR_TOP:
att.add("vtext-anchor","top");
break;
case Text::ANCHOR_BOTTOM:
att.add("vtext-anchor","bottom");
break;
case Text::ANCHOR_MIDDLE:
att.add("vtext-anchor","middle");
break;
/*
case Text::ANCHOR_BASELINE:
att.add("vtext-anchor","baseline");
break;
*/
case Text::ANCHOR_UNSET:
break;
}
}
}
示例7: if
XMLNode *
RDFAnnotationParser::createCVTerms(const SBase * object)
{
if (object == NULL) return NULL;
/* create the basic triples */
XMLTriple li_triple = XMLTriple("li",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdf");
XMLTriple bag_triple = XMLTriple("Bag",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdf");
/* attributes */
XMLAttributes blank_att = XMLAttributes();
/* tokens */
XMLToken bag_token = XMLToken(bag_triple, blank_att);
std::string prefix;
std::string name;
std::string uri;
XMLAttributes *resources;
XMLNode *description = createRDFDescription(object);
/* loop through the cv terms and add */
/* want to add these in blocks of same qualifier */
if (object->getCVTerms())
{
for (unsigned int n = 0; n < object->getCVTerms()->getSize(); n++)
{
CVTerm* current = static_cast <CVTerm *> (object->getCVTerms()->get(n));
if (current == NULL) continue;
if (current->getQualifierType() == MODEL_QUALIFIER)
{
prefix = "bqmodel";
uri = "http://biomodels.net/model-qualifiers/";
const char* term = ModelQualifierType_toString(
current->getModelQualifierType());
if (term == NULL) return NULL;
name = term;
}
else if (current
->getQualifierType() == BIOLOGICAL_QUALIFIER)
{
prefix = "bqbiol";
uri = "http://biomodels.net/biological-qualifiers/";
const char* term = BiolQualifierType_toString(
current->getBiologicalQualifierType());
if (term == NULL) return NULL;
name = term;
}
else
{
continue;
}
resources = current->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;
}