当前位置: 首页>>代码示例>>C++>>正文


C++ DOMLSSerializer类代码示例

本文整理汇总了C++中DOMLSSerializer的典型用法代码示例。如果您正苦于以下问题:C++ DOMLSSerializer类的具体用法?C++ DOMLSSerializer怎么用?C++ DOMLSSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DOMLSSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: catch

/* Write the file. */
bool GQCFileData::Write(const std::string &fileName)
{    
	// Initialize the XML4C2 system.
	try
	{
		XMLPlatformUtils::Initialize();
	}
	catch (const XMLException&)
	{
		return false;
	}

	// Create a DOM implementation object and create the document type for it.
	DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(ToXMLCh(L"LS"));
	DOMDocument* doc = impl->createDocument();
	//doc->setStandalone(true);

	// Create the serializer.
	DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
	DOMLSOutput     *theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
	//theSerializer->setEncoding(ToXMLCh(GENERIC_REPORT_FILE_ENCODING));
	theOutputDesc->setEncoding(ToXMLCh(GENERIC_REPORT_FILE_ENCODING));

    // Create the root element
    DOMElement *rootElement = CreateGenericReportElement(doc);

	// store the parameters
	AddNameValuePairs(ANALYSIS_PARAMETERS, analysisParameters, doc, rootElement);
	AddNameValuePairs(QC_RESULTS, qcResults, doc, rootElement);
	AddNameValuePairs(SAMPLE_SIGNATURE, sampleSignature, doc, rootElement);

    // Add an empty table (required by the DTD)
    AddBlankReportTable(doc, rootElement);

    // Store the element to the document.
    doc->appendChild(rootElement);

	// Write the file.
	bool status = false;
	XMLFormatTarget *myFormTarget = new LocalFileFormatTarget(fileName.c_str());
	theOutputDesc->setByteStream(myFormTarget);
	try
	{
		theSerializer->write(doc, theOutputDesc);
		status = true;
	}
	catch (...)
	{
		status = false;
	}

	// Clean up
	doc->release();
	theOutputDesc->release();
	theSerializer->release();
	delete myFormTarget;
	XMLPlatformUtils::Terminate();

	return status;
}
开发者ID:HenrikBengtsson,项目名称:Affx-Fusion-SDK,代码行数:61,代码来源:GQCFileData.cpp

示例2: printf

//
// domPrint  -  Dump the contents of a DOM node.
//              For debugging failures, when all else fails.
//                 Works recursively - initially called with a document node.
//
void ThreadParser::domPrint()
{
    printf("Begin DOMPrint ...\n");
    if (gRunInfo.dom)
    {
        try
        {
            XMLCh tempStr[100];
            XMLString::transcode("LS", tempStr, 99);
            DOMImplementation *impl          = DOMImplementationRegistry::getDOMImplementation(tempStr);
            DOMLSSerializer   *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
            DOMLSOutput       *theOutput     = ((DOMImplementationLS*)impl)->createLSOutput();
            XMLFormatTarget   *myFormTarget  = new StdOutFormatTarget();
            theOutput->setByteStream(myFormTarget);
            DOMNode           *doc           = fXercesDOMParser->getDocument();
            theSerializer->write(doc,theOutput);
            delete myFormTarget;
            theSerializer->release();
            theOutput->release();
        }
        catch (...)
        {
            // do nothing
        }
    }
    printf("End DOMPrint\n");
}
开发者ID:ideasiii,项目名称:ControllerPlatform,代码行数:32,代码来源:ThreadTest.cpp

示例3: X

void serializer::serialize(EObject_ptr obj)
{
    m_root_obj = obj;

    m_impl = DOMImplementationRegistry::getDOMImplementation(X("Core"));

    if (m_impl)
    {
        EClass_ptr cl = obj->eClass();
        EPackage_ptr pkg = cl->getEPackage();

        ::ecorecpp::mapping::type_traits::string_t const& ns_uri = pkg->getNsURI();

        m_doc = m_impl->createDocument(
                (ns_uri.empty()) ? X("NULL") : W(ns_uri), // root element namespace URI.
                W(get_type(obj)), // root element name
                0); // document type object (DTD)

        m_root = m_doc->getDocumentElement();

        // common attributes
        // xmlns:xmi="http://www.omg.org/XMI"
        m_root->setAttribute(X("xmlns:xmi"), X("http://www.omg.org/XMI"));
        // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        m_root->setAttribute(X("xmlns:xsi"),
                X("http://www.w3.org/2001/XMLSchema-instance"));
        // xmi:version="2.0"
        m_root->setAttribute(X("xmi:version"), X("2.0"));

        serialize_node(m_root, obj);

        // write
        // TODO: outta here

        DOMLSSerializer *theSerializer =
                ((DOMImplementationLS*) m_impl)->createLSSerializer();
        DOMLSOutput *theOutputDesc =
                ((DOMImplementationLS*) m_impl)->createLSOutput();

        DOMConfiguration* serializerConfig = theSerializer->getDomConfig();

        // TODO: set as option
        if (serializerConfig->canSetParameter(
                XMLUni::fgDOMWRTFormatPrettyPrint, true))
            serializerConfig->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
                    true);

        XMLFormatTarget *myFormTarget;
        myFormTarget = new LocalFileFormatTarget(X(m_file));
        theOutputDesc->setByteStream(myFormTarget);

        theSerializer->write(m_doc, theOutputDesc);

        theOutputDesc->release();
        theSerializer->release();
        delete myFormTarget;
    }
    else
        throw "Error";
}
开发者ID:Ecapo,项目名称:vishnu,代码行数:60,代码来源:serializer-xerces.cpp

示例4: DomNodeToString

CStdString DomSerializer::DomNodeToString(DOMNode* node)
{
	CStdString output;

    DOMImplementation *impl          = DOMImplementationRegistry::getDOMImplementation(XStr("LS").unicodeForm());
    DOMLSSerializer   *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
		DOMConfiguration	* dc 					 = theSerializer->getDomConfig();
    // set user specified output encoding
    //dc->setEncoding(gOutputEncoding);
		dc->setParameter(XStr("format-pretty-print").unicodeForm(), true);

    XMLFormatTarget *myFormTarget;
		myFormTarget = new MemBufFormatTarget ();

		DOMLSOutput *outputStream = ((DOMImplementationLS*)impl)->createLSOutput();
		outputStream->setByteStream(myFormTarget);

    theSerializer->write(node, outputStream);

		output = (char *)((MemBufFormatTarget*)myFormTarget)->getRawBuffer();

	// Clean up
    delete theSerializer;
    //
    // Filter, formatTarget and error handler
    // are NOT owned by the serializer.
    delete myFormTarget;

	return output;
}
开发者ID:havoc83,项目名称:oreka,代码行数:30,代码来源:DomSerializer.cpp

示例5:

void SYSTEM::CXMLConfiguration::Save()
{
    DOMLSSerializer *ss = ((DOMImplementationLS*)impl)->createLSSerializer();
    if(xmlFile.length() == 0)
    {
        //InfoLog("Cann't save file. The file name is null");
        return;
    }
    XMLCh *t = XMLString::transcode(xmlFile.c_str());
    ss->writeToURI((XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument*)doc,t);
    XMLString::release(&m_curValue);
}
开发者ID:lozpeng,项目名称:applesales,代码行数:12,代码来源:Configer.cpp

示例6: serialise

static void
serialise (DOMDocument const *doc, std::string const &output)
{
  XMLCh const LS[] = { chLatin_L, chLatin_S, chNull };

  DOMImplementationLS &impl = dynamic_cast<DOMImplementationLS &> (*DOMImplementationRegistry::getDOMImplementation (LS));
  DOMLSSerializer *writer = impl.createLSSerializer ();
  DOMLSOutput *desc = impl.createLSOutput ();

  LocalFileFormatTarget target (output.c_str ());
  desc->setByteStream (&target);

  writer->write (doc, desc);
}
开发者ID:pippijn,项目名称:xul,代码行数:14,代码来源:xsdproc.cpp

示例7: serializeDOM

    bool serializeDOM(std::ostream& output, bool)
    {
	XMLCh tempStr[100];
	XMLString::transcode("LS", tempStr, 99);
	DOMImplementationLS *impl = dynamic_cast<DOMImplementationLS *>(DOMImplementationRegistry::getDOMImplementation(tempStr));
	DOMLSSerializer   *theSerializer = impl->createLSSerializer();
	DOMLSOutput       *theOutputDesc = impl->createLSOutput();

	bool rc = false;

	try
	{
	    MemBufFormatTarget *myFormTarget = new MemBufFormatTarget();

	    /* do the serialization through DOMLSSerializer::write(); */

	    theOutputDesc->setByteStream(myFormTarget);
	    theSerializer->write(inputFileDOM, theOutputDesc);

	    const XMLByte * data = myFormTarget->getRawBuffer();
	    XMLSize_t len = myFormTarget->getLen();

	    output.write( reinterpret_cast<const char *>(data), len );

	    delete myFormTarget;
	    rc = true;
	}
	catch (IOException& e ) {
	    cerr << StrX(e.getMessage());
	    cerr << "  Code is " << e.getCode();

	    if ( errno != 0 ) {
		cerr << ": " << strerror( errno );
	    }
	}
	catch (XMLException& e)
	{
	    cerr << "An error occurred during creation of output transcoder. Msg is:"
		 << endl
		 << StrX(e.getMessage());
	    if ( errno != 0 ) {
		cerr << ": " << strerror( errno );
	    }
	    cerr << endl;
	    rc = false;
	}
	delete theSerializer;
	return rc;
    }
开发者ID:layeredqueuing,项目名称:V5,代码行数:49,代码来源:xerces_common.cpp

示例8: dumpTree

 /// Dump DOM tree using XercesC handles
 void dumpTree(DOMNode* doc, ostream& os) {
   if ( doc )  {
     DOMImplementation  *imp = DOMImplementationRegistry::getDOMImplementation(Strng_t("LS"));
     MemBufFormatTarget *tar = new MemBufFormatTarget();
     DOMLSOutput        *out = imp->createLSOutput();
     DOMLSSerializer    *wrt = imp->createLSSerializer();
     out->setByteStream(tar);
     wrt->getDomConfig()->setParameter(Strng_t("format-pretty-print"), true);
     wrt->write(doc, out);
     os << tar->getRawBuffer() << endl << flush;
     out->release();
     wrt->release();
     return;
   }
   printout(ERROR,"dumpTree","+++ Cannot dump invalid document.");
 }
开发者ID:vvolkl,项目名称:DD4hep,代码行数:17,代码来源:DocumentHandler.cpp

示例9: serializeNode

void Normalizer::serializeNode(const DOMNode * const node) {
    XMLCh tempStr[100];
    XMLString::transcode("LS", tempStr, 99);
    DOMImplementation *impl          = DOMImplementationRegistry::getDOMImplementation(tempStr);
    DOMLSSerializer   *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
    DOMLSOutput       *theOutput     = ((DOMImplementationLS*)impl)->createLSOutput();
    theSerializer->getDomConfig()->setParameter(X("format-pretty-print"), true);
    XMLFormatTarget *myFormTarget;
    myFormTarget = new StdOutFormatTarget();

    theOutput->setByteStream(myFormTarget);
    theSerializer->write(node,theOutput);
    delete myFormTarget;
    theSerializer->release();
    theOutput->release();
}
开发者ID:kanbang,项目名称:Colt,代码行数:16,代码来源:Normalizer.cpp

示例10: SerializeXercesDocument

void SerializeXercesDocument(xercesc::DOMDocument& document, xercesc::XMLFormatTarget& target) {

	// call into xerces for serialization
	// cf. http://xerces.apache.org/xerces-c/program-dom-3.html#DOMLSSerializer

	static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
	DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS);

	// construct the DOMWriter
	DOMLSSerializer *writer = ((DOMImplementationLS*)impl)->createLSSerializer();

    // optionally you can set some features on this serializer
    if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTDiscardDefaultContent, true))
        writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent, true);

    if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
            writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);

	// prepare output
	DOMLSOutput *outp = ((DOMImplementationLS*)impl)->createLSOutput();
	outp->setByteStream(&target);

	// serialize the DOMNode to a UTF-16 string
	writer->write(&document, outp);

	// release the memory
	outp->release();
	writer->release();

}
开发者ID:Limecraft,项目名称:ebu-mxfsdk,代码行数:30,代码来源:XercesUtils.cpp

示例11: throw

int XmlParser::commit(const char* xmlFile) {
   try {
      // Obtain DOM implementation supporting Load/Save
      DOMImplementationLS* pImplementation = dynamic_cast<DOMImplementationLS *>(DOMImplementationRegistry::getDOMImplementation(DualString("LS").asXMLString()));
      if (pImplementation == NULL){
         throw( std::runtime_error( "Unable to obtain suitable DOMImplementation!" ) ) ;
      }

      DOMLSSerializer *pSerializer = pImplementation->createLSSerializer();

      DOMLSOutput *pOutput = pImplementation->createLSOutput();
#if 1
      // Change output format to be pretty (but it isn't)
      DOMConfiguration *pConfiguration = pSerializer->getDomConfig();
      if (pConfiguration->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
         pConfiguration->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
#if 0
      // Overrides above but seems to have little effect!
      if (pConfiguration->canSetParameter(XMLUni::fgDOMWRTCanonicalForm, true))
         pConfiguration->setParameter(XMLUni::fgDOMWRTCanonicalForm, true);
#endif
#if 1
      //
      if (pConfiguration->canSetParameter(XMLUni::fgDOMWRTEntities, true))
         pConfiguration->setParameter(XMLUni::fgDOMWRTEntities, true);
#endif
#endif
      LocalFileFormatTarget *pTarget = new LocalFileFormatTarget(DualString( xmlFile ).asXMLString());
      pOutput->setByteStream(pTarget);

//      mergeDocument->normalizeDocument(); // Needed?
      pSerializer->write(mergeDocument, pOutput);

      delete pTarget;
      pOutput->release();
      pSerializer->release();

   } catch( const xercesc::XMLException& e ){
      return -1;
   }

   return 0;
}
开发者ID:CoffeeHacker,项目名称:usbdm-eclipse-makefiles-build,代码行数:43,代码来源:xmlParser.cpp

示例12: PrintXMLdoc

void PrintXMLdoc(const XERCES_CPP_NAMESPACE::DOMDocument* doc)
{
	DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(L"Core");
	DOMLSSerializer   *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
    DOMLSOutput       *theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
	
	DOMConfiguration* serializerConfig=theSerializer->getDomConfig();
	if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
		serializerConfig->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);

	XMLFormatTarget *outputStream = new StdOutFormatTarget();
	theOutputDesc->setByteStream(outputStream);

	theSerializer->write(doc, theOutputDesc);

    theOutputDesc->release();
    theSerializer->release();

	delete outputStream;
}
开发者ID:Letractively,项目名称:koritools,代码行数:20,代码来源:filetree2xml.cpp

示例13: convertDomToString

string XmlUtil::convertDomToString() {
    if(!doc)
        throw "DOM is empty"; // FIXME add an exception type for this

    DOMImplementationLS* implLS = dynamic_cast<DOMImplementationLS*>(impl);
    DOMLSSerializer*	theSerializer = implLS->createLSSerializer();
    DOMConfiguration* 	serializerConfig = theSerializer->getDomConfig();

    if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
        serializerConfig->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);

    string stringTemp = XMLString::transcode (theSerializer->writeToString(doc));
    theSerializer->release();

    /*string stringDump;
    for (string::iterator it = stringTemp.begin() ; it < stringTemp.end(); ++it) {
    	if (!isspace (*it))
    		stringDump += *it;
    }
    return stringDump;*/
    return stringTemp;
}
开发者ID:8l,项目名称:insieme,代码行数:22,代码来源:xml_utils.cpp

示例14: transcode

string tsp::Tool::xmlNode2String(const DOMNode* node) {
	if (!initXmlEngine())
		return NULL;

	DOMImplementation *implementation =
			DOMImplementationRegistry::getDOMImplementation(
					XMLString::transcode("LS"));

	// Create a DOMLSSerializer which is used to serialize a DOM tree into an XML document.
	DOMLSSerializer *serializer =
			((DOMImplementationLS*) implementation)->createLSSerializer();
	// Make the output more human readable by inserting line feeds.
	if (serializer->getDomConfig()->canSetParameter(
			XMLUni::fgDOMWRTFormatPrettyPrint, true))
		serializer->getDomConfig()->setParameter(
				XMLUni::fgDOMWRTFormatPrettyPrint, true);

	// The end-of-line sequence of characters to be used in the XML being written out.
	serializer->setNewLine(XMLString::transcode("\r\n"));

	return XMLString::transcode(serializer->writeToString(node));

}
开发者ID:nhnghia,项目名称:TestGen-IFx,代码行数:23,代码来源:Tool.cpp

示例15: save

//save the document to an external file
void ResultXML::save()
{
    //create the serializer for saving the document
    DOMLSSerializer *serializer = (DOMLSSerializer*)imp->createLSSerializer();

    //configure for saving it in a well presented human readable format
    if(serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true)){
       serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
    }

    //set the output for serializing as a stream
    DOMLSOutput *output = ((DOMImplementationLS*)imp)->createLSOutput();
    output->setByteStream(ftarget);

    //use the serializer to save the document and catch any errors encountered
    try{
        serializer->write(root, output);
    }
    catch (const XMLException& e) {
        char* msg = XMLString::transcode(e.getMessage());
        cout << "Error Exception Encountered: " << endl << msg << endl;
        XMLString::release(&msg);
    }
    catch (const DOMException& e) {
        char* msg = XMLString::transcode(e.getMessage());
        cout << "Error Exception Encountered: " << endl << msg << endl;
        XMLString::release(&msg);
    }
    catch (...) {
        cout << "Error Unknown Exception" << endl;
    }

    //force the release of resources held by the serializer and output manager
    output->release();
    serializer->release();
}
开发者ID:iq-dot,项目名称:performer,代码行数:37,代码来源:resultxml.cpp


注:本文中的DOMLSSerializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。