예제 #1
0
LIBSBML_CPP_NAMESPACE_BEGIN


/**
 * Creates a new list of XML namespaces declarations from a "raw" Xerces-C++
 * Attributes set.
 */
XercesNamespaces::XercesNamespaces (const xercesc::Attributes& attrs)
{
  unsigned int size = attrs.getLength();
  mNamespaces.reserve(size);


  for (unsigned int n = 0; n < size; ++n)
  {
    const string            name  = XercesTranscode( attrs.getLocalName(n) );
    const string            qname = XercesTranscode( attrs.getQName    (n) );
    const string            value = XercesTranscode( attrs.getValue    (n) );
    const string::size_type pos   = qname.find(":", 0);

    const string prefix = (pos != string::npos) ? qname.substr(0, pos) : "";

         if (prefix == "xmlns") add( value, name );
    else if (name   == "xmlns") add( value );
  }
}
예제 #2
0
void ConfigurationManager::startElement(const XMLCh* const uri, const XMLCh* const localname,
                                        const XMLCh* const qname,
                                        const xercesc::Attributes& attributes)
{
   std::map<std::string, std::string> *currentMapPtr = NULL;

   dtUtil::XMLStringConverter qnameConv(qname);
   std::string sectionStr = qnameConv.ToString();

   if(sectionStr == "General")
   {
      currentMapPtr = &mGeneralVariables;
   }
   else if(sectionStr == "Layout")
   {
      currentMapPtr = &mLayoutVariables;
   }
   else if(sectionStr == "Plugins")
   {
      currentMapPtr = &mPluginVariables;
   }
   else
   {
      //Unrecognized element; can't do much with it
      return;
   }

   for(XMLSize_t i = 0; i < attributes.getLength(); ++i)
   {
      dtUtil::XMLStringConverter varNameConv(attributes.getQName(i));
      dtUtil::XMLStringConverter varValueConv(attributes.getValue(i));

      (*currentMapPtr)[varNameConv.ToString()] = varValueConv.ToString();
   }
}
예제 #3
0
XMLNodeAttributeMap::XMLNodeAttributeMap( const xercesc::Attributes &attributes )
{
    for ( size_t i = 0; i < attributes.getLength(); i++ )
    {
        std::string key   = transcodeString( attributes.getLocalName( i ) );
        std::string value = transcodeString( attributes.getValue( i ) );

        m_attributes.insert( std::make_pair( key, value ) );
    }
}
//-----------------------------------------------------------------------------
smart::data::message_content_handler_base::tag_attributes_collection_type smart::data::message_content_handler_base::get_attribs(const xercesc::Attributes& attrs) const
{
  tag_attributes_collection_type attrs_res;

  for (unsigned int/*size_t*/ i = 0; i < attrs.getLength(); ++i)
  {
    const string attr_name           = xml_to_std_string(xml_string_type(attrs.getQName(i)));
    const xml_string_type attr_value = xml_string_type(attrs.getValue(i));
    attrs_res.insert(make_pair(attr_name, attr_value));
  }

  return attrs_res;
}
예제 #5
0
void XParser::startElement(const XMLCh* const uri, const XMLCh* const local,
		  	   const XMLCh* const raw,
			   const xercesc::Attributes& attrs)
{
	// if text is mixed with elements.
	if (_elementBuffer.length() > 0)
	{
		std::string	text = _trim(_elementBuffer);
		if (text.length() > 0)
		{
			unsigned long long	value = XHash::hash(text);
			int	tid = _xtree->addText(_idStack[_stackTop],
						      _lsidStack[_stackTop],
						      text, value);
			_lsidStack[_stackTop] = tid;
			_currentNodeID = tid;
			_valueStack[_stackTop] += value;
		}
	}

	std::string local_s(xercesc::XMLString::transcode(local));

//cout << "Add element " << _idStack[_stackTop] << "\t" << _lsidStack[_stackTop] << "\t" << local_s << endl;
	int	eid = _xtree->addElement(_idStack[_stackTop],
					 _lsidStack[_stackTop], local_s);
	// Update last sibling info.
	_lsidStack[_stackTop] = eid;

	// Push
	_stackTop++;
	_idStack[_stackTop] = eid;
	_currentNodeID = eid;
	_lsidStack[_stackTop] = XTree::NULL_NODE;
	_valueStack[_stackTop] = XHash::hash(local_s);

	// Take care of attributes
	if (attrs.getLength() > 0)
	{
		for (unsigned int i = 0; i < attrs.getLength(); i++)
		{
			std::string	name(xercesc::XMLString::transcode(attrs.getQName(i)));
			unsigned long long	namehash = XHash::hash(name);
			
			unsigned long long	attrhash = namehash * namehash;
			std::string	value = "";
			char	*valueP = xercesc::XMLString::transcode(attrs.getValue(i));
			if (valueP != NULL)
			{
				value = std::string(valueP);
				unsigned long long valuehash = XHash::hash(value);
				attrhash += valuehash * valuehash;
			}
			int	aid = _xtree->addAttribute(eid, _lsidStack[_stackTop], name, value, namehash, attrhash);

			_lsidStack[_stackTop] = aid;
			_currentNodeID = aid + 1;
			_valueStack[_stackTop] += attrhash * attrhash;
		}
	}
	
	_readElement = true;
	_elementBuffer = std::string("");

}