void SAX_TransAGHandler::AGSetStart
(const XMLCh* const name, AttributeList& attr)
{
	string id = trans(attr.getValue("id")) ;
	string version = trans(attr.getValue("version")) ;

	try  {
		prevId = CreateAGSet(id);
		agIds.clear();    // erase ids of previous load
		agSetIds.push_back(prevId);

		a_version = version ;
		a_agId =  id ;

		StartStack.push(&SAX_TransAGHandler::AGSetSubStart);
		EndStack.push(&SAX_TransAGHandler::dummyEnd);
	}
	catch ( AGException e ) {
		throw agfio::LoadError(e.error());
	}
	catch ( ... ) {
		string msg = "AGSetStart : id '" + id + "'already exists ";
		throw agfio::LoadError(msg);
	}

}
/*
 * Stores the attributes from a name value type element.
 * Parse out the probe array type into its own member.
 */
void SAXArrayHandlers::StoreNameValueAttributes(AttributeList&  attributes)
{
	unsigned int len = attributes.getLength();
	AttributeNameValueType param;
	for (unsigned int index = 0; index < len; index++)
	{
		if (attributes.getName(index) == NAME_ATTRIBUTE)
		{
			param.name = XMLChToString(attributes.getValue(index));
		}
		else if (attributes.getName(index) == VALUE_ATTRIBUTE)
		{
			param.value = XMLChToString(attributes.getValue(index));
		}
		else if (attributes.getName(index) == TYPE_ATTRIBUTE)
		{
			param.type = XMLChToString(attributes.getValue(index));
			if (param.name == PROBE_ARRAY_TYPE_PARAMETER_NAME)
			{
				arrayData->SetArrayType(param.value);
			}
			else
			{
				arrayData->Attributes().push_back(param);
			}
		}
	}
}
Example #3
0
/*
 * start trans
 */
void SAX_TRSHandlers::TransStart(const XMLCh* const name, AttributeList& attr)
{
	O_TRACE("IN TransStart");

	// -- Annotation
	if (!dataModel)
	{
		tag::DataModel::initEnviron("");
		dataModel = new tag::DataModel("TRS");
		dataModel->setConventions("trs_import");
	}

	dataModel->setAGSetProperty("annotations", "transcription") ;

	// -- Version
	ostringstream vers;
	string scribe = trans(attr.getValue("scribe")) ;
	dataModel->initVersionInfo(scribe , trans(attr.getValue("version_date")) ) ;

	// -- Status
	ostringstream status;
	status << "elapsed=" << trans(attr.getValue("elapsed")) << ";";
	dataModel->setAGSetProperty("status", status.str()) ;

	// -- Signal
	signalIds = dataModel->addSignal(trans(attr.getValue("audio_filename")), "audio", "wav", "PCM", dataModel->getNbTracks() + 1, 1);
	signalId = signalIds.back() ;

	// -- Language
	lang = trans(attr.getValue("xml:lang"));
	if ( lang.length() == 2 )
	{
		const char* plang= ISO639::get3LetterCode(lang.c_str());
		if ( *plang )
			lang=plang;
	}

	// -- Keep value of all initialized elements.
	// We'll use them to cut the element timelines each time we want to create an element
	string prevId = dataModel->getAGTrans() ;
	dataModel->initAnnotationGraphs("", lang, scribe);
	m_sectId[0] = dataModel->getByOffset("section", 0.0, 0, "transcription_graph") ;
	m_turnId[0] = dataModel->getByOffset("turn", 0.0, 0, "transcription_graph") ;
	m_segmentId[0] = dataModel->getByOffset("segment", 0.0, 0, "transcription_graph") ;
	m_unitId[0] = dataModel->getByOffset("unit", 0.0, 0, "transcription_graph") ;
	prevBackgroundId  = dataModel->getByOffset("background", 0.0, 0, "background_graph") ;
	if (!prevBackgroundId.empty())
	{
		dataModel->setElementProperty(prevBackgroundId, "type", "none") ;
		dataModel->setElementProperty(prevBackgroundId, "level", "low") ;
	}

	// -- Values used for keeping the creation order
	turnIds.push_back(m_turnId[0]);
	segIds.push_back(m_segmentId[0]);

	StartStack.push(&SAX_TRSHandlers::TransSubStart);
	EndStack.push(&SAX_TRSHandlers::TransEnd);
	O_TRACE("OUT TransStart") ;
}
Example #4
0
/*
 * invoked at the start of a section
 *
 * We can't create the section because the children are not created yet.
 * So we keep the section data and we'll create it as soon as the children are
 * built.
 *
 * Take care:
 * We can create base element (sync tag) only when we arrive at the following
 * element tag (to get the split timestamp). As we need to wait for the base
 * element to be created for creating all parents (like sections), we always create
 * the previous section after encountering a section tag.
 * Therefore, at a section tag, we need to keep data of the previous section and data
 * of the current section.
 */
void SAX_TRSHandlers::SectionStart (const XMLCh* const name, AttributeList& attr)
{
	O_TRACE("IN SectionStart ");

	nbSections++ ;

	// -- As soon as we are at the 2nd section, we can indicates that we'll need
	//	  to create the previous one as soon as the children are built.
	if (nbSections > 1)
		sectionNeeded = true ;


	//>  keep data for the turn that will be created
	lastSectionType = currentSectionType ;
	lastSectionTopic = currentSectionTopic ;

	//>  Keep current data
	const string& topicId = trans(attr.getValue("topic")) ;
	currentSectionType = trans(attr.getValue("type")) ;
	currentSectionTopic = topics[topicId] ;

	if (nbSections==1)
	{
		dataModel->setElementProperty(m_sectId[0], "type", currentSectionType, false) ;
		dataModel->setElementProperty(m_sectId[0], "desc", currentSectionTopic, false) ;

		lastSectionType = currentSectionType ;
		lastSectionTopic = currentSectionTopic ;
	}

	StartStack.push(&SAX_TRSHandlers::TurnStart);
	EndStack.push(&SAX_TRSHandlers::dummyEnd);
	O_TRACE("OUT SectionStart ");
}
// invoked at the start of a subelement of AGSet
void SAX_TransAGHandler::AGSetSubStart
(const XMLCh* const name, AttributeList& attr)
{
  string tag = trans(name);

  if (!a_agId.empty() && !a_version.empty())
  	SetFeature(a_agId, "version", a_version) ;

  // if Metadata element is found
  if (tag == "Metadata") {
    StartStack.push(&SAX_TransAGHandler::MetadataSubStart);
    EndStack.push(&SAX_TransAGHandler::dummyEnd);
  }
  // if Timeline element is found
  else if (tag == "Timeline") {
    prevId = CreateTimeline(trans(attr.getValue("id")));
    StartStack.push(&SAX_TransAGHandler::TimelineSubStart);
    EndStack.push(&SAX_TransAGHandler::dummyEnd);
  }
  // if AG element is found
  else if (tag == "AG") {
    prevId = CreateAG(trans(attr.getValue("id")),
                      trans(attr.getValue("timeline")));

    agIds.push_back(prevId);
    StartStack.push(&SAX_TransAGHandler::AGSubStart);
    EndStack.push(&SAX_TransAGHandler::dummyEnd);
  }
}
Example #6
0
// deal with "event" items
void SAX_TRSHandlers::EventStart(const XMLCh* const name, AttributeList& attr)
{
	string type = trans(attr.getValue("type"));
	string extent = trans(attr.getValue("extent"));
	string desc = trans(attr.getValue("desc"));

	bool is_entity = false ;
	SyncContent::SyncContentMode mode ;

	//> type empty ? let's consider it as a noise
	if ( type.empty() )
		type = "noise";
	//> type is entities ? we have an entity type too
	else if ( type == "entities" )
		is_entity = true ;

	//> Format it
	formatAGqualifier(is_entity, type, desc) ;

	//> Event has not specific extent ? let's say it's instantaneous
	//  --> Instantaneous = foreground event
	if ( extent.empty() || extent == "instantaneous" )
		mode = SyncContent::EVENT_INSTANT ;
	else if ( extent == "begin" )
		mode = SyncContent::EVENT_BEGIN ;
	else if (extent == "end")
		mode = SyncContent::EVENT_END ;
	else if (extent == "next")
		mode = SyncContent::EVENT_NEXT ;
	else if (extent == "previous")
		mode = SyncContent::EVENT_PREVIOUS ;

	syncStack[who].push_back( new SyncContent(who, mode, type, desc) ) ;
}
void BulletMLParserXercesSAXHandler::startElement(const XMLCh* const name,
												  AttributeList& attributes)
{
	BulletMLNode* node = parser_->addContent(parser_->uc2string(name));

	if (node->getName() == BulletMLNode::bulletml) {
		for (unsigned int i = 0; i < attributes.getLength(); i++) {
			if (parser_->uc2string(attributes.getName(i)) == "type" &&
				parser_->uc2string(attributes.getValue(i)) == "horizontal")
			{
				parser_->setHorizontal();
			}
		}
	}
	else {
		BulletMLParserXerces::MyAttributes mattr;
		for (unsigned int i = 0; i < attributes.getLength(); i++) {
			mattr.push_back(parser_->uc2string(attributes.getName(i)));
			mattr.push_back(parser_->uc2string(attributes.getValue(i)));
		}
		parser_->addAttribute(mattr, node);
	}

	if (curNode_ != 0) curNode_->addChild(node);
	curNode_ = node;
}
Example #8
0
// deal with "background" items
void SAX_TRSHandlers::BackgroundStart(const XMLCh* const name, AttributeList& attr)
{
	nbBackground ++ ;

	string startTime = trans(attr.getValue("time"));
	float start = atof(startTime.c_str());

	//> Create background if not at 0 time
	//  if 0 time, will be created at next background border
	float lastTime = atof(lastBackgroundTime.c_str());
	if (lastTime!=0)
	{
//		prevBackgroundId = dataModel->addBackgroundSegment(0, lastTime, -1, formatBackgrounds(lastBackgroundType), lastBackgroundLevel, tag::DataModel::ADJUST_PREVIOUS, false) ;
		prevBackgroundId = dataModel->insertMainstreamBaseElement(prevBackgroundId, lastTime);
		dataModel->setElementProperty(prevBackgroundId, "type", formatBackgrounds(lastBackgroundType), false);
		dataModel->setElementProperty(prevBackgroundId, "level", lastBackgroundLevel, false);
	}

	lastBackgroundTime = startTime ;
	string level = trans(attr.getValue("level"));
	string type = trans(attr.getValue("type"));

	if (level!="off")
	{
		lastBackgroundLevel = level ;
		lastBackgroundType = type ;
	}
	else
	{
		lastBackgroundLevel = "low" ;
		lastBackgroundType = "none" ;
	}
}
Example #9
0
// deal with "Lang" items
void SAX_TRSHandlers::LangStart(const XMLCh* const name, AttributeList& attr)
{
	float score = atof(trans(attr.getValue("score")).c_str());
	if ( score > 0.0 && score > prevScore )
	{
		dataModel->setElementProperty(turnIds[who-1], "lang", trans(attr.getValue("name")), false) ;
		prevScore = score;
	}
}
// invoked at the start of a subelement of AG
void SAX_TransAGHandler::AGSubStart
(const XMLCh* const name, AttributeList& attr)
{
  string tag = trans(name);

  if (tag == "Metadata") {
    StartStack.push(&SAX_TransAGHandler::MetadataSubStart);
    EndStack.push(&SAX_TransAGHandler::dummyEnd);
  }
  else if (tag == "Anchor") {
    string unit = trans(attr.getValue("unit"));
    string off_str = trans(attr.getValue("offset"));
    set<SignalId> sigset;
    Utilities::string2set(trans(attr.getValue("signals")), sigset);
    if (off_str.empty())
      CreateAnchor(trans(attr.getValue("id")), sigset);
    else
      CreateAnchor(trans(attr.getValue("id")),
		   atof(off_str.c_str()),
		   unit,
		   sigset);

    StartStack.push(&SAX_TransAGHandler::dummyStart);
    EndStack.push(&SAX_TransAGHandler::dummyEnd);
  }
  else if (tag == "Annotation") {
    prevId =
      CreateAnnotation(trans(attr.getValue("id")),
                       trans(attr.getValue("start")),
                       trans(attr.getValue("end")),
                       trans(attr.getValue("type")));
    StartStack.push(&SAX_TransAGHandler::AnnotationSubStart);
    EndStack.push(&SAX_TransAGHandler::dummyEnd);
  }
}
Example #11
0
// invoked at the start of a topic definition
void SAX_TRSHandlers::TopicStart(const XMLCh* const name, AttributeList& attr)
{
	O_TRACE("IN TopicStart ");

	topics[trans(attr.getValue("id"))] = trans(attr.getValue("desc"));

	O_TRACE("OUT TopicStart ") ;

	StartStack.push(&SAX_TRSHandlers::dummyStart) ;
	EndStack.push(&SAX_TRSHandlers::dummyEnd) ;
}
Example #12
0
void SAX_SGMLHandler::SpeakerStart(const XMLCh* const name, AttributeList& attr)
{
	const string& tag = trans(name);
	TRACE(string("IN SpeakerStart ") + tag);

	if (tag == "PATH") {

		string id, word_cnt, labels, file, chanel, sequence, r_t1, r_t2, word_aux ;
		id = trans(attr.getValue("id")) ;
		word_cnt = trans(attr.getValue("word_cnt")) ;
		labels = trans(attr.getValue("labels")) ;
		file = trans(attr.getValue("file")) ;
		chanel = trans(attr.getValue("chanel")) ;
		sequence = trans(attr.getValue("sequence")) ;
		r_t1 = trans(attr.getValue("R_T1")) ;
		r_t2 = trans(attr.getValue("R_T2")) ;
		word_aux = trans(attr.getValue("word_aux")) ;

		if (current_SGMLspeaker) {
			current_SGMLpath = current_SGMLspeaker->addPath(id, word_cnt, labels, file, chanel, sequence, r_t1, r_t2, word_aux) ;
			sgmlModel->addPath(current_SGMLpath) ;
		}

		StartStack.push(&SAX_SGMLHandler::PathStart) ;
		EndStack.push(&SAX_SGMLHandler::PathEnd) ;
	}
	else {
		TRACE("UNKNOWN TAG: " + tag);
		StartStack.push(&SAX_SGMLHandler::SpeakerStart) ;
		EndStack.push(&SAX_SGMLHandler::dummyEnd) ;
	}
}
Example #13
0
void SAX_SGMLHandler::SGMLSubStart(const XMLCh* const name, AttributeList& attr)
{
	const string& tag = trans(name);
	TRACE(string("IN SGMLSubStart ") + tag);

	if (tag == "SYSTEM") {
		string title, ref_fname, hyp_fname, creation_date, format, frag_corr, opt_del, weight_ali, weight_filename ;

		title = trans(attr.getValue("id")) ;
		ref_fname = trans(attr.getValue("ref_fname")) ;
		hyp_fname = trans(attr.getValue("hyp_fname")) ;
		creation_date = trans(attr.getValue("creation_date")) ;
		format = trans(attr.getValue("format")) ;
		frag_corr = trans(attr.getValue("frag_corr")) ;
		opt_del = trans(attr.getValue("opt_del")) ;
		weight_ali = trans(attr.getValue("weight_ali")) ;
		weight_filename = trans(attr.getValue("weight_filename")) ;

		if (sgmlModel)
			sgmlModel->setData(title, ref_fname, hyp_fname, creation_date, format, frag_corr, opt_del, weight_ali, weight_filename) ;
		else
			Log::err() << "SGML: no model handler... Error" << std::endl ;

		StartStack.push(&SAX_SGMLHandler::SystemStart) ;
		EndStack.push(&SAX_SGMLHandler::dummyEnd) ;
	}
	else {
		TRACE("UNKNOWN TAG: " + tag);
		StartStack.push(&SAX_SGMLHandler::SGMLSubStart);
		EndStack.push(&SAX_SGMLHandler::dummyEnd);
	}
	TRACE("OUT SGMLSubStart");
}
void SAXPrintHandlers::startElement(const   XMLCh* const    name
                                    ,       AttributeList&  attributes)
{
    // The name has to be representable without any escapes
    fFormatter  << XMLFormatter::NoEscapes
                << chOpenAngle << name;

    unsigned int len = attributes.getLength();
    for (unsigned int index = 0; index < len; index++)
    {
        //
        //  Again the name has to be completely representable. But the
        //  attribute can have refs and requires the attribute style
        //  escaping.
        //
        fFormatter  << XMLFormatter::NoEscapes
                    << chSpace << attributes.getName(index)
                    << chEqual << chDoubleQuote
                    << XMLFormatter::AttrEscapes
		            << attributes.getValue(index)
                    << XMLFormatter::NoEscapes
                    << chDoubleQuote;
    }
    fFormatter << chCloseAngle;
}
void SAX_TransAGHandler::structuredMetaStart
(const XMLCh* const name, AttributeList& attr)
{
  string s;
  // if start-of-element is reported,
  // store structured element as XML string in feature value
  // and push structuredMetaEnd handler
  //  storeMetaValueStart(name, attr);
  if ( ! prevValue.empty() ) prevValue += " ";
  prevValue += "<";
  prevValue += set_string(s, name);
  for ( int i = 0; i < attr.getLength(); ++i ) {
    prevValue += " ";
    prevValue += set_string(s, attr.getName(i));
    prevValue += "=\"";
    prevValue += set_string(s, attr.getValue(i));
    prevValue += "\"";
  }

  prevValue += ">";
  prevPos = prevValue.length();

  StartStack.push(&SAX_TransAGHandler::structuredMetaStart);
  EndStack.push(&SAX_TransAGHandler::structuredMetaEnd);
}
Example #16
0
// deal with "comment" items
void SAX_TRSHandlers::CommentStart
(const XMLCh* const name, AttributeList& attr)
{
	string type = "comment";
	string desc = trans(attr.getValue("desc"));

	syncStack[who].push_back( new SyncContent(who, SyncContent::EVENT_INSTANT, type, desc) ) ;
}
Example #17
0
 void startElement(const XMLCh* const name, AttributeList& attrList)
 {
   string label=XMLString::transcode(name);
   map<string,string> attrs;
   for (unsigned int i=0;i<attrList.getLength();i++)
     attrs[XMLString::transcode(attrList.getName(i))] = XMLString::transcode(attrList.getValue(i));
   myStream.onElement(label, attrs);
 }
// invoked at the start of a subelement of Timeline
void SAX_TransAGHandler::TimelineSubStart
(const XMLCh* const name, AttributeList& attr)
{
  string tag = trans(name);

  if (tag == "Metadata") {
    StartStack.push(&SAX_TransAGHandler::MetadataSubStart);
    EndStack.push(&SAX_TransAGHandler::dummyEnd);
  }
  else if (tag == "Signal") {
    string href, mimeClass, mimeType, unit, track;
    set_string(href, attr.getValue("xlink:href"));
    set_string(mimeClass, attr.getValue("mimeClass"));
    set_string(mimeType, attr.getValue("mimeType"));
    set_string(unit, attr.getValue("unit"));
    set_string(track, attr.getValue("track"));

    prevId =
      CreateSignal(trans(attr.getValue("id")),
                   href, mimeClass, mimeType,
                   trans(attr.getValue("encoding")),
                   unit, track);
    StartStack.push(&SAX_TransAGHandler::SignalSubStart);
    EndStack.push(&SAX_TransAGHandler::dummyEnd);
  }
}
void 
SBlogErrorMapper::MySAXHandler::startElement(const XMLCh* const name,
					     AttributeList& attributes)
{
  // 1. parse module name from the root
  XMLCh2VXIchar(name, tempString, 4096); 
  if(wcscmp(tempString, L"ErrorMessages") == 0)
  {
    for(unsigned int i = 0; i < attributes.getLength(); i++)
    {
      XMLCh2VXIchar(attributes.getName(i), tempString, 4096); 
      if(wcscmp(tempString, L"moduleName") == 0)
      {
        XMLCh2VXIchar(attributes.getValue(i), tempString, 4096);
        moduleName = tempString;
      }
    }
  }
  // 2. only care about <error> elements
  else if(wcscmp(tempString, L"error") == 0) {
    isProcessing = 1;
    errorMessage = L"";

    // Find the error number and severity (tag attributes)
    for (unsigned int i = 0; i < attributes.getLength(); i++) {
      XMLCh2VXIchar(attributes.getName(i), tempString, 4096); 
      if(wcscmp(tempString, L"num") == 0) {
        XMLCh2VXIchar(attributes.getValue(i), tempString, 4096); 
        errorNumber = wtoint(tempString);
      }
      else if(wcscmp(tempString, L"severity") == 0) {
        XMLCh2VXIchar(attributes.getValue(i), tempString, 4096); 
        errorSeverity = wtoint(tempString);
      }
    }
  }
  else if(wcscmp(tempString, L"advice") == 0) {
    // ignore the advice tag, just concate the advice's message    
  }
  else if(isProcessing)
    errorMessage += L"???"; // Runtime-determined value, unknown
}
Example #20
0
/*
 *  Deals with "sync" items
 *
 *  We can't create a base element before we know the timestamp where the
 *  following element begins. Moreover, after graphe initialization a default
 *  base element is created over all the timeline.
 *
 *  Therefore, at a sync tag we split the existing base element at the time
 *  given by the tag. After that, we can create all parents that needed to be
 *  created over PREVIOUS base element(s).
 */
void SAX_TRSHandlers::SyncStart(const XMLCh* const name, AttributeList& attr)
{
	nbSyncs ++ ;

	segStartTime = trans(attr.getValue("time"));
	segEndTime = "";

	float start = atof(segStartTime.c_str()) ;
	string prevUnit = m_unitId[0] ;
	string prevSeg = m_segmentId[0] ;

	if (nbSyncs > 1)
	{
		string prev = m_unitId[0] ;

		// -- Keep last segment for adding text and event
		std::vector<string> prevUnits ;
		prevUnits.push_back(m_unitId[0]) ;

		// -- Split existing segment to inserting new
		m_unitId[0] = dataModel->insertMainstreamBaseElement(m_unitId[0], start, true, false) ;
		dataModel->setElementProperty(m_unitId[0] , "subtype", "unit_text", false) ;

		m_segmentId[0] = dataModel->insertMainstreamElement("segment", m_unitId[0], start, true, false) ;

		// We've just added the new segment of order 0, reset the storing list
		segIds.clear() ;
		segIds.push_back(m_segmentId[0]) ;

		//2 -Add eventual overlapping elements at previous position
		addOverlapSegments(prevUnit, prevUnits) ;
		nbSyncOverlap = 0 ;

		//3 - Add eventual terminated section
		if (sectionNeeded)
			addSection(prevUnit, lastSectionType, lastSectionTopic) ;

		//4 - Add eventual terminated turn
		if (turnNeeded)
			addTurns(prevUnit, lastTurnSpeakersStr, lastTurnAttribute) ;

		//5- Deals with text and events
		addSyncContent(prevUnits) ;

		//6- Deals with background links
		// Keep all unit anchors and we'll see after all the matching background
		const string& startAnchor = dataModel->getAnchor(prev, true) ;
		const string& endAnchor = dataModel->getAnchor(prev, false) ;
		anchorsToLink.insert(startAnchor) ;
		anchorsToLink.insert(endAnchor) ;
	}
	else
		dataModel->setElementProperty(m_unitId[0] , "subtype", "unit_text", false);
}
Example #21
0
// deal with "who" items
void SAX_TRSHandlers::WhoStart
(const XMLCh* const name, AttributeList& attr)
{

	who = atoi(trans(attr.getValue("nb")).c_str());

	// -- For all overlapping speeches, let's count number of level
	//    It will be used for creating turn
	if (who>1)
		nbSyncOverlap++ ;
}
// invoked at the start of a subelement of Annotation
void SAX_TransAGHandler::AnnotationSubStart
(const XMLCh* const name, AttributeList& attr)
{
  string tag = trans(name);

  if (tag == "Feature") {
    set_string(prevFeature, attr.getValue("name"));
    prevValue.erase();
    StartStack.push(&SAX_TransAGHandler::structuredMetaStart);
    EndStack.push(&SAX_TransAGHandler::FeatureEnd);
  }
}
/*
 * Stores the experiment name attribute from the experiment element.
 */
void SAXArrayHandlers::StoreExperimentNameAttribute(AttributeList&  attributes)
{
	unsigned int len = attributes.getLength();
	for (unsigned int index = 0; index < len; index++)
	{
		if (attributes.getName(index) == NAME_ATTRIBUTE)
		{
			arrayData->SetExperimentName(XMLChToString(attributes.getValue(index)));
			break;
		}
	}
}
//
// startElement - our SAX handler callback function for startElement.
//                Update the document checksum with the element name
//                and any attribute names and values.
//
 void ThreadParser::SAXHandler::startElement(const XMLCh *const name, AttributeList &attributes)
{
    SAXInstance->addToCheckSum(name);
    XMLSize_t n = attributes.getLength();
    XMLSize_t i;
    for (i=0; i<n; i++)
    {
        const XMLCh *attNam = attributes.getName(i);
        SAXInstance->addToCheckSum(attNam);
        const XMLCh *attVal = attributes.getValue(i);
        SAXInstance->addToCheckSum(attVal);
    }
}
Example #25
0
void OptionsLoader::startElement(const XMLCh* const name,
                                 AttributeList& attributes) {
    myItem = TplConvert<XMLCh>::_2str(name);
    for (int i = 0; i < (int) attributes.getLength(); i++) {
        std::string key = TplConvert<XMLCh>::_2str(attributes.getName(i));
        std::string value = TplConvert<XMLCh>::_2str(attributes.getValue(i));
        if (key == "value" || key == "v") {
            key = myItem;
        }
        setValue(key, value);
    }
    myValue = "";
}
Example #26
0
/*
 * invoked at the start of a turn
 *
 * We can't create the turn because the children are not created yet.
 * So we keep the turn data and we'll create it as soon as the children are
 * built.
 *
 * Take care:
 * We can create base element (sync tag) only when we arrive at the following
 * element tag (to get the split timestamp). As we need to wait for the base
 * element to be created for creating all parents (like turns), we always create
 * the previous turn after encountering a turn tag.
 * Therefore, at a turn tag, we need to keep data of the previous turn and data
 * of the current turn.
 */
void SAX_TRSHandlers::TurnStart(const XMLCh* const name, AttributeList& attr)
{
	O_TRACE("IN TurnStart ");
	nbTurns++ ;

	turnIds.clear();
	segIds.clear();

	// -- Keep the end time because next tags won't have this information
	string endTime = trans(attr.getValue("endTime")) ;
	lastOffset =  atof(endTime.c_str()) ;

	// -- As soon as we are at the 2nd turn, we can indicate that we'll need
	//	  to create the previous one as soon as the children are built.
	if (nbTurns > 1)
		turnNeeded = true ;

	//>  Keep data for the turn(s) that will be created
	lastTurnSpeakersStr = currentTurnSpeakerStr ;
	lastTurnAttribute = currentTurnAttribute ;

	//>  Keep the current turn data
	currentTurnSpeakerStr = trans(attr.getValue("speaker")) ;
	saveElementFeatures(attr, currentTurnAttribute) ;

	//>  Update global values
//	prevValue.erase();
	segStartTime = "";
	segEndTime = "";
	who = 1 ;
	nbwords = 0;
	prevScore=0.0;

	StartStack.push(&SAX_TRSHandlers::TurnSubStart);
	EndStack.push(&SAX_TRSHandlers::TurnEnd);
	O_TRACE("OUT TurnStart ");
}
// invoked at the start of a subelement of Metadata
void
SAX_TransAGHandler::MetadataSubStart
(const XMLCh* const name, AttributeList& attr)
{
  string tag = trans(name);

  if (tag == "MetadataElement" || tag == "OtherMetadata")
    set_string(prevFeature, attr.getValue("name"));
  else
    set_string(prevFeature, name);

  prevValue.erase();
  StartStack.push(&SAX_TransAGHandler::structuredMetaStart);
  EndStack.push(&SAX_TransAGHandler::MetadataSubEnd);
}
/*
 * Stores the sample project attribute from the biosource/characteristics element.
 */
void SAXArrayHandlers::StoreSampleProjectAttribute(AttributeList&  attributes)
{
	unsigned int len = attributes.getLength();
	for (unsigned int index = 0; index < len; index++)
	{
		if (attributes.getName(index) == ONTOLOGY_VALUE_ATTRIBUTE)
		{
			AttributeNameValueType param;
			param.name = GCOS_SAMPLE_PROJECT_PARAMETER_NAME;
			param.value = XMLChToString(attributes.getValue(index));
			param.type = STRING_TYPE;
			arrayData->Attributes().push_back(param);
			break;
		}
	}
}
Example #29
0
// invoked at the start of a speaker definition
void
SAX_TRSHandlers::SpeakerStart
(const XMLCh* const name, AttributeList& attr)
{
	O_TRACE("IN SpeakerStart ");
	string scope =trans(attr.getValue("scope"));
	if ( scope.empty() )
		scope = "local";

	speakers << "<Speaker id=\"" << trans(attr.getValue("id"))
	<< "\" name.last=\"" << trans(attr.getValue("name"))
	<< "\" gender=\"" << trans(attr.getValue("type"))
	<< "\" scope=\"" << scope ;

	string slang = trans(attr.getValue("lang"));
	if ( slang == "" )
		slang = lang;

	string dialect = trans(attr.getValue("dialect"));
	int isNative =0;
	if ( dialect == "native" )
	{
		isNative=1;
		dialect = "";
	}
	else if ( dialect == "nonnative" )
	{
		isNative=0;
		dialect = "";
	}

	if ( slang != "" )
	{
		speakers  << "\">" << endl;
		speakers << "<SpokenLanguage code=\"" << slang
		<< "\" dialect=\"" << dialect
		<< "\" isnative=\"" << isNative << "\" isusual=\"" << 1
		<< "\" accent=\"" << trans(attr.getValue("accent"))
		<< "\" />" << endl;
		speakers << "</Speaker>" << endl;
	}
	else
		speakers  << "\"/>" << endl;

	StartStack.push(&SAX_TRSHandlers::dummyStart) ;
	EndStack.push(&SAX_TRSHandlers::dummyEnd) ;

	O_TRACE("OUT SpeakerStart ") ;
}
Example #30
0
    const std::string jsonize(AttributeList &attrs) {
        StringBuffer s;
        Writer<StringBuffer> w(s);

        w.StartObject();
        for (int i = 0; i < attrs.getLength(); ++i) {
            const XMLCh* name = attrs.getName(i);
            char *tmpName = XMLString::transcode(name),
                 *tmpValue = XMLString::transcode(attrs.getValue(name));
            w.String(tmpName);
            w.String(tmpValue);
            XMLString::release(&tmpName);
            XMLString::release(&tmpValue);
        }
        w.EndObject();

        return s.GetString();
    }