void OptionsLoader::startElement(const XMLCh* const name,
                                 XERCES_CPP_NAMESPACE::AttributeList& attributes) {
    myItem = TplConvert::_2str(name);
    for (int i = 0; i < (int) attributes.getLength(); i++) {
        std::string key = TplConvert::_2str(attributes.getName(i));
        std::string value = TplConvert::_2str(attributes.getValue(i));
        if (key == "value" || key == "v") {
            setValue(myItem, value);
        }
        // could give a hint here about unsupported attributes in configuration files
    }
    myValue = "";
}
	/*! Called at the start of each element.
	 * @param name The name of the element.
	 * @param attributes The attributes of the element.
	 */
	void startElement(const XMLCh* const name, XERCES_CPP_NAMESPACE::AttributeList& attributes)
    {
	    if (MoveCurrentElementForward(name) == false)
		    return;

        // Get the attributes.
	    map<string, string> atts;
	    unsigned int len = attributes.getLength();
	    for (unsigned int index = 0; index < len; index++)
	    {
		    atts[XMLChToString(attributes.getName(index))] = XMLChToString(attributes.getValue(index));
	    }

        // Store the results
	    switch (currentElement)
	    {
            case GENERIC_REPORT:
                break;

            case NAME_VALUE_PAIRS:
                if (atts[NAME_ATTRIBUTE] == ANALYSIS_PARAMETERS)
                    currentParameters = &fileData->AnalysisParameters();
                else if (atts[NAME_ATTRIBUTE] == QC_RESULTS)
                    currentParameters = &fileData->QCResults();
                else if (atts[NAME_ATTRIBUTE] == SAMPLE_SIGNATURE)
                    currentParameters = &fileData->SampleSignature();
                else
                    currentParameters = NULL;
                break;

            case NAME_VALUE_PAIR:
                if (currentParameters != NULL)
                {
                    ParameterNameValuePair param;
                    param.Name = StringUtils::ConvertMBSToWCS(atts[NAME_ATTRIBUTE]);
                    param.Value = StringUtils::ConvertMBSToWCS(atts[VALUE_ATTRIBUTE]);
                    currentParameters->push_back(param);
                }
                break;

	        default:
		        break;
        }
    }
Beispiel #3
0
  void startElement(const XMLCh* const x_name,
		    XERCES_CPP_NAMESPACE::AttributeList& attributes)
  {
    assert(x_name);
    std::string tx_name;

    if ( ! XercesString_to_UTF_8(x_name, tx_name) )
      m_HasEncodeErrors = true;

    const char* name = tx_name.c_str();
    XMLElement* Element;
    const char* ns_root = name;
    const char* local_name = strchr(name, ':');

    if ( local_name != 0 )
      name = local_name + 1;

    if ( m_Scope.empty() )
      {
	m_Scope.push(m_Root);
      }
    else
      {
	Element = m_Scope.top();
	m_Scope.push(Element->AddChild(name));
      }

    Element = m_Scope.top();
    Element->SetName(name);

    // set attributes
    ui32_t a_len = attributes.getLength();

    for ( ui32_t i = 0; i < a_len; i++)
      {
	std::string aname, value;
	if ( ! XercesString_to_UTF_8(attributes.getName(i), aname) )
	  m_HasEncodeErrors = true;

	if ( ! XercesString_to_UTF_8(attributes.getValue(i), value) )
	  m_HasEncodeErrors = true;

	const char* x_aname = aname.c_str();
	const char* x_value = value.c_str();

	if ( strncmp(x_aname, "xmlns", 5) == 0 )
	  AddNamespace(x_aname+5, x_value);

	if ( ( local_name = strchr(x_aname, ':') ) == 0 )
	  local_name = x_aname;
	else
	  local_name++;

	Element->SetAttr(local_name, x_value);
      }

    // map the namespace
    std::string key;
    if ( ns_root != name )
      key.assign(ns_root, name - ns_root - 1);
  
    ns_map::iterator ni = m_Namespaces->find(key);
    if ( ni != m_Namespaces->end() )
      Element->SetNamespace(ni->second);
  }