本文整理汇总了C++中DOMDocument::setStandalone方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMDocument::setStandalone方法的具体用法?C++ DOMDocument::setStandalone怎么用?C++ DOMDocument::setStandalone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::setStandalone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
XMLPlatformUtils::Initialize();
// Populate vector of items
vector<Item> items;
items.push_back(Item(Product("Toaster", 29.95), 3));
items.push_back(Item(Product("Hair dryer", 24.95), 1));
// Build the DOM document
DOMImplementation* implementation
= DOMImplementation::getImplementation();
DOMDocument* doc = implementation->createDocument();
doc->setStandalone(true);
DOMElement* root = create_item_list(doc, items);
doc->appendChild(root);
// Print the DOM document
DOMWriter* writer = implementation->createDOMWriter();
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
XMLFormatTarget* out = new StdOutFormatTarget();
writer->writeNode(out, *doc);
writer->release();
doc->release();
return 0;
}
示例2: buildParameterSetXML
/**
* This method converts the entries in the map (created from the command-line arguments)
* into XML which will then be fed as input into the parameter handling code (i.e. ParameterSet class).
*/
string parameterTask::buildParameterSetXML(const string & xmlFileNamePrefix)
{
string retVal;
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
ACS_LOG(LM_ERROR, "parameterTask::buildParameterSetXML",
(LM_ERROR, "Error - XMLException - info: %s\n", StrX(toCatch.getMessage()).localForm()))
}
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(StrX("XML 2.0").unicodeForm());
if (impl != NULL)
{
try
{
// create a new DOMDocument which we will populate with
// entries from the command-line parameters, in order to
// make an xml version of the parameter set for use internally
string qualifiedName(PARAMETERSET_NAMESPACE_PREFIX);
qualifiedName.append(":").append(PARAMETERSET_STRING);
DOMDocument* doc = impl->createDocument(
StrX(PSET_NAMESPACE_URI).unicodeForm(), // root element namespace URI.
StrX(qualifiedName.c_str()).unicodeForm(), // root element name
0); // document type object (DTD).
doc->setStandalone(true);
// set our internal auto_ptr to point to the new document
this->domDocument.reset(doc);
string schemaHint(PSET_NAMESPACE_URI);
schemaHint.append(" ").append(PARAMETERSET_SCHEMA_NAME);
DOMElement* rootElem = doc->getDocumentElement();
rootElem->setAttribute(StrX("xmlns:xsi").unicodeForm(), StrX("http://www.w3.org/2001/XMLSchema-instance").unicodeForm());
rootElem->setAttribute(StrX("xsi:schemaLocation").unicodeForm(),
StrX(schemaHint.c_str()).unicodeForm());
DOMElement* psetdefElem = doc->createElement(StrX(PSETDEF_STRING).unicodeForm());
rootElem->appendChild(psetdefElem);
string xmlFileName = xmlFileNamePrefix + ".xml";
DOMText* psetdefValTextNode = doc->createTextNode(StrX(xmlFileName.c_str()).unicodeForm());
psetdefElem->appendChild(psetdefValTextNode);
DOMElement* nameElem = doc->createElement(StrX(NAME_STRING).unicodeForm());
rootElem->appendChild(nameElem);
DOMText* nameValTextNode = doc->createTextNode(StrX("command-line values").unicodeForm());
nameElem->appendChild(nameValTextNode);
map<string, vector<string> >::iterator position;
// for each parameter in the parameterMap
for(position = parameterMap.begin(); position != parameterMap.end(); ++position) {
// determine the type by looking it up in our parameter set definition, i.e. psetdef
// (which we have obtained by parsing the task's psetdef xml file containing the task's metadata)
// and add an element of the proper type to the XML document being constructed, with name equal to the
// key portion of the current map entry, value equal to the value portion of the current map entry.
ParamSetDef::paramTypesEnum paramType = paramSetDef->getParamTypeForName(position->first);
switch(paramType) {
case ParamSetDef::BOOL: {
DOMElement *boolElem = createBoolElement(position->first, position->second, doc);
rootElem->appendChild(boolElem);
break;
}
case ParamSetDef::INT: {
DOMElement *intElem = createIntElement(position->first, position->second, doc);
rootElem->appendChild(intElem);
break;
}
case ParamSetDef::INT_ARRAY: {
DOMElement *intArrayElem = createIntArrayElement(position->first, position->second, doc);
rootElem->appendChild(intArrayElem);
break;
}
case ParamSetDef::DOUBLE: {
DOMElement *doubleElem = createDoubleElement(position->first, position->second, doc);
rootElem->appendChild(doubleElem);
break;
}
case ParamSetDef::DOUBLE_ARRAY: {
DOMElement * doubleArrayElem =
createDoubleArrayElement(position->first, position->second, doc);
rootElem->appendChild(doubleArrayElem);
break;
}
case ParamSetDef::STRING: {
DOMElement *stringElem = createStringElement(position->first, position->second, doc);
rootElem->appendChild(stringElem);
break;
}
case ParamSetDef::STRING_ARRAY: {
DOMElement * stringArrayElem = createStringArrayElement(position->first, position->second, doc);
rootElem->appendChild(stringArrayElem);
break;
}
//.........这里部分代码省略.........