Beispiel #1
0
void
check_svg_pssm_logo()
{
    cout << "******* check_svg_pssm_logo()" << endl;

    XMLPlatformUtils::Initialize();

    DOMImplementation* impl
        = DOMImplementation::getImplementation();

    if (impl != NULL)
    {
        DOMDocumentType* doc_type
            = impl->createDocumentType(	XStr("svg"),
                                        NULL,
                                        XStr("svg-20000303-stylable.dtd") );
        XERCES_CPP_NAMESPACE::DOMDocument * doc = impl->createDocument(
                    0,        // root element namespace URI.
                    XStr("svg"),		// root element name
                    doc_type);			// document type object (DTD).
        doc->setEncoding(XStr("UTF-8"));

        add_logo_defs(doc);

        TableLinkVec links;
        links.push_back(TableLink(MATRIX_DATA, 37));
        links.push_back(TableLink(MATRIX_DATA, 104));
        links.push_back(TableLink(MATRIX_DATA, 236));
        links.push_back(TableLink(MATRIX_DATA, 457));

        for (TableLinkVec::const_iterator i = links.begin();
                links.end() != i;
                ++i)
        {
            const Matrix * matrix = BiobaseDb::singleton().get_matrices()[*i].get();
            const Pssm pssm = make_pssm(matrix);
            const seq_t sequence =
                (matrix->align_descs.begin() != matrix->align_descs.end())
                ? matrix->align_descs.begin()->get()->sequence
                : "";
            DOMElement * pssm_logo =
                create_svg_pssm_logo(
                    pssm,
                    doc,
                    sequence);
            set_attribute(pssm_logo, "x", 0);
            set_attribute(pssm_logo, "y", BIO_NS::float_t(200 * (i - links.begin())));
            set_attribute(pssm_logo, "height", 200);
            set_attribute(pssm_logo, "width", BIO_NS::float_t(pssm.size() * 100));
            doc->getDocumentElement()->appendChild(pssm_logo);
        }

        dom_print(doc->getDocumentElement(), "logo_test.svg");
    }

    XMLPlatformUtils::Terminate();
}
int _tmain(int argc, _TCHAR* argv[])
{
	try
	{
		XMLPlatformUtils::Initialize();
	}
	catch(...)
	{
		return 1;
	}

	XMLCh* Path  = NULL;
	DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(L"Core");
	XERCES_CPP_NAMESPACE::DOMDocument* doc = impl->createDocument( 0, L"directory", 0);
	
	if( argc >= 2)
		Path = argv[1];
	else
		Path = L".\\";
	SaveFileTreeToXML(Path, doc->getDocumentElement() ,doc);

	PrintXMLdoc( doc );

	doc->release();

	XMLPlatformUtils::Terminate();
	return 0;
}
Beispiel #3
0
int CApp::loadXercesDataFamille( dlgAmonSoft &amon )
{    
    try {
        XERCES_CPP_NAMESPACE::DOMDocument *pDoc = g_ParserFamille->getDocument();
        XERCES_CPP_NAMESPACE::DOMElement  *pElem = pDoc->getDocumentElement();

        CheckDataFileVersion( pElem, amon );

        DOMNodeList *pNodeList = pElem->getChildNodes ();

        uint size = pNodeList->getLength();

        for( uint i = 0; i < size; i++ )
        {            
            DOMNode *pNode = pNodeList->item( i );

            if( XMLString::equals( XMLString::transcode( pNode->getNodeName() ), "Famille" ) )
            {
                Datas::CFamille *pFamille = new Datas::CFamille( 0 );
                DOMElement *elmt = static_cast< DOMElement* >( pNode );
                mAssert( elmt != 0, "elmt != 0" );
                // loadFromXML has to link with correct CPersonne, this means
                // that all CPersonne *must* be loaded before !
                int iRet = pFamille->loadFromXML( elmt );
                if( iRet == -1 )
                    delete pFamille;
            }                        
        }
    }
    catch( DOMException &e )
    {
        qDebug( XMLString::transcode( e.getMessage() ) );
    }
    return 0;
}
Beispiel #4
0
//----------------------------------------------------------------------------
// Export One Personne to XML file
//----------------------------------------------------------------------------
void Datas::exportPersonne( QString filename, QString filenameF, const CPersonnes &p )
{
    qDebug( "CDatas::exportPersonne" );

    CParser *Parser = new CParser( filename );
    CParser *ParserFamille = new CParser( filenameF );    

    Parser->initWrite( "Exportation" );
    ParserFamille->initWrite( "Exportation" );

    XERCES_CPP_NAMESPACE::DOMDocument *pDoc = Parser->getDocument();

    QString strdir = QDir::currentDirPath();
    QString path = "href=\"";
    path += strdir + "\\xml\\personnes.xsl\" type=\"text/xsl\"";

    // Add directive xsl
    XERCES_CPP_NAMESPACE::DOMProcessingInstruction *pi
        = pDoc->createProcessingInstruction( XERCES_CPP_NAMESPACE::XMLString::transcode( "xml-stylesheet" ),
            XERCES_CPP_NAMESPACE::XMLString::transcode( path ) );

    XERCES_CPP_NAMESPACE::DOMNode* docRootNode = pDoc->getDocumentElement();
	pDoc->replaceChild( pi, docRootNode );
    pDoc->appendChild( docRootNode );

    p.saveToXML( pDoc, ParserFamille->getDocument() );

    ParserFamille->writeFile();
    Parser->writeFile();

    delete Parser;
    delete ParserFamille;
}
Beispiel #5
0
void XMLRuntime::read(const string& filename, FreeAX25::Runtime::Configuration& config) {
    XercesDOMParser parser;
    parser.setValidationScheme(XercesDOMParser::Val_Always);
    parser.setDoNamespaces(true);
    parser.setDoSchema(true);
    parser.setDoXInclude(true);
    parser.setHandleMultipleImports(true);
    parser.setValidationSchemaFullChecking(true);
    parser.setCreateEntityReferenceNodes(false);
    parser.setIncludeIgnorableWhitespace(false);

    DOMTreeErrorReporter errReporter;
    parser.setErrorHandler(&errReporter);

    parser.parse(filename.c_str());

    if (errReporter.getSawErrors())
    	throw exception();

    // Now read configuration from the DOM Tree:
    XERCES_CPP_NAMESPACE::DOMDocument* doc = parser.getDocument();
    assert(doc != nullptr);

    auto rootElement = doc->getDocumentElement();
    auto configName = rootElement->getAttribute(toX("name"));
    config.setId(fmX(configName));

    { // Get settings:
		auto nodeList = rootElement->getElementsByTagName(toX("Settings"));
		if (nodeList->getLength() > 0)
			readSettings(
					"",
					static_cast<DOMElement*>(nodeList->item(0)),
					config.settings);
    }

    { // Get plugins:
		auto nodeList = rootElement->getElementsByTagName(toX("Plugins"));
		if (nodeList->getLength() > 0)
			readPlugins(
					"",
					static_cast<DOMElement*>(nodeList->item(0)),
					config.plugins);
    }
}
Beispiel #6
0
/*
 * Load datas
 */
int CApp::loadXercesData( dlgAmonSoft &amon )
{    
    try {
        XERCES_CPP_NAMESPACE::DOMDocument *pDoc = g_Parser->getDocument();
        XERCES_CPP_NAMESPACE::DOMElement  *pElem = pDoc->getDocumentElement();

        CheckDataFileVersion( pElem, amon );

        DOMNodeList *pNodeList = pElem->getChildNodes ();

        uint size = pNodeList->getLength();

        for( uint i = 0; i < size; i++ )
        {            
            DOMNode *pNode = pNodeList->item( i );

            if( XMLString::equals( XMLString::transcode( pNode->getNodeName() ), "Personne" ) )
            {
                QString string;
                Datas::CPersonnes *pPersonne = new Datas::CPersonnes;
                DOMElement *elmt = static_cast< DOMElement* >( pNode );
                mAssert( elmt != 0, "elmt != 0" );
                pPersonne->loadFromXML( elmt );
                QListView *listView = amon.getListViewPersonnes();
                QListViewItem *item = new QListViewItem( listView,
                    pPersonne->getNom(),
                    pPersonne->getPrenom(),
                    pPersonne->getTelephone(),
                    pPersonne->getEmail(),
                    string.setNum( pPersonne->getID() ) );

                Datas::g_listPersonnes.push_back( pPersonne );
            }                        
        }
    }
    catch( DOMException &e )
    {
        qDebug( XMLString::transcode( e.getMessage() ) );
    }
    return 0;
}
void XmlPropertyReader::parseGameObjectFile(Ogre::DataStreamPtr &stream, const Ogre::String &groupName)
{
    initializeXml();

    XERCES_CPP_NAMESPACE::DOMDocument* doc = loadDocument(stream);

    DOMNodeList* godefsXml = doc->getDocumentElement()->getElementsByTagName(AutoXMLCh("gameobjectclass").data());
    for (unsigned int idx = 0; idx < godefsXml->getLength(); idx++)
    {
		PropertyRecordPtr ps(new PropertyRecord());
		DOMElement* curNode = static_cast<DOMElement*>(godefsXml->item(idx));
		
		const DOMNamedNodeMap* godefAttrs = curNode->getAttributes();
		for (XMLSize_t attrIdx = 0; attrIdx < godefAttrs->getLength(); attrIdx++)
		{
			PropertyEntry entry = processProperty(static_cast<DOMAttr*>(godefAttrs->item(attrIdx)));
            if (entry.first != "")
            {
                ps->setProperty(entry.first, entry.second);
            }
		}

        DOMNodeList* godefChildren = curNode->getChildNodes();
        for (XMLSize_t childIdx = 0; childIdx < godefChildren->getLength(); childIdx++)
        {
            DOMNode* curChild = godefChildren->item(childIdx);
            if (curChild->getNodeType() == DOMNode::ELEMENT_NODE)
            {
                PropertyEntry entry = processProperty(static_cast<DOMElement*>(curChild));
                if (entry.first != "")
                {
                    ps->setProperty(entry.first, entry.second);
                }
            }
        }
        mPropertyRecords.push_back(ps);
    }
	
    shutdownXml();
}
Beispiel #8
0
    bool
    XML_File_Intf::read_process_plan (const ACE_TCHAR *file)
    {
      DANCE_TRACE("XML_File_Intf::read_process_plan");

      try
        {
          if (!XML_Helper_type::XML_HELPER.is_initialized ())
            return false;

          DANCE_DEBUG (DANCE_LOG_EVENT_TRACE,
            (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
                       ACE_TEXT ("Constructing DOM\n")));
          XERCES_CPP_NAMESPACE::DOMDocument *dom =
            XML_Helper_type::XML_HELPER.create_dom ((file));

          if (dom == 0)
            {
              DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
                           ACE_TEXT ("Failed to open file %s\n"), file));
              return false;
            }

          XERCES_CPP_NAMESPACE::DOMElement *foo = dom->getDocumentElement ();
          DANCE_DEBUG (DANCE_LOG_EVENT_TRACE,
            (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
                       ACE_TEXT ("DOMElement pointer: %u\n"), foo));

          ID_Map::TSS_ID_Map* TSS_ID_Map (ACE_Singleton<ID_Map::TSS_ID_Map, ACE_Null_Mutex>::instance());
          (*TSS_ID_Map)->reset ();

          DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE,
            DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
            ACE_TEXT ("Parsing XML file with XSC\n")));
          deploymentPlan dp =
            DAnCE::Config_Handlers::reader::DeploymentPlan (dom);

          DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE,
            DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ")
            ACE_TEXT ("Processing using config handlers\n")));
          DP_Handler dp_handler (dp);

          this->idl_dp_.reset (dp_handler.plan ());

          if (this->idl_dp_.get ())
            return true;
        }
      catch (const CORBA::Exception &ex)
        {
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::caught - ")
            ACE_TEXT ("CORBA Exception whilst parsing XML into IDL\n"),
            ex._info ().c_str ()));
          throw Config_Error (this->file_,
                              ex._info ().c_str ());
        }
      catch (const Config_Error &ex)
        {
          throw ex;
        }
      catch (...)
        {
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::caught - ")
            ACE_TEXT ("Unexpected exception whilst parsing XML into IDL.\n")));
          throw Config_Error (this->file_,
            ACE_TEXT ("Unexpected C++ exception whilst parsing XML"));
        }

      return false;
    }