コード例 #1
0
ファイル: stdin_parser.cpp プロジェクト: PeterWang9/code
	void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs )      {
		theOStream << "<" << qname;
		for ( unsigned int i = 0; i < attrs.getLength(); i++ ) {
			theOStream  <<  " " << attrs.getQName( i ) << "=\"" << attrs.getValue( i ) << "\"";
		}
		theOStream << ">";
	}     
コード例 #2
0
ファイル: xmlextract.C プロジェクト: xorJane/qball
 void startElement(const XMLCh* const uri,const XMLCh* const localname,
   const XMLCh* const qname, const Attributes& attributes)
 { 
   //cout << "TestHandler::startElement: " << StrX(qname) << endl;
   char* buf = XMLString::transcode(qname);
   string sbuf(buf);
   if ( sbuf == tag )
   {
     read = true;
   }
   XMLString::release(&buf);
   
   if ( read )
   {
     // copy start element tag with attributes
     cout << "<" << StrX(qname).localForm();
     unsigned int len = attributes.getLength();
     for (unsigned int index = 0; index < len; index++)
     {
       cout << " " << attributes.getQName(index)
            << "=\"" 
            << attributes.getValue(index)
            << "\"";
     }
     cout << ">";
   }
 };
コード例 #3
0
ファイル: ili2handler.cpp プロジェクト: garnertb/gdal
void ILI2Handler::startElement(
    CPL_UNUSED const XMLCh* const uri,
    CPL_UNUSED const XMLCh* const localname,
    const XMLCh* const qname,
    const Attributes& attrs
    ) {
  // start to add the layers, features with the DATASECTION
  char *tmpC = NULL;
  m_nEntityCounter = 0;
  if ((level >= 0) || (cmpStr(ILI2_DATASECTION, tmpC = XMLString::transcode(qname)) == 0)) {
    level++;

    if (level >= 2) {

      // create the dom tree
      DOMElement *elem = (DOMElement*)dom_doc->createElement(qname);
      
      // add all attributes
      unsigned int len = attrs.getLength();
      for (unsigned int index = 0; index < len; index++)
        elem->setAttribute(attrs.getQName(index), attrs.getValue(index));
      dom_elem->appendChild(elem);
      dom_elem = elem;
    }
  }
  XMLString::release(&tmpC);
}
コード例 #4
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::declareAttributeNamespaces(const Attributes& attributes)
{
	for (int i = 0; i < attributes.getLength(); i++)
	{
		XMLString namespaceURI = attributes.getURI(i);
		XMLString localName    = attributes.getLocalName(i);
		XMLString qname        = attributes.getQName(i);
		if (!localName.empty())
		{
			XMLString prefix;
			XMLString splitLocalName;
			Name::split(qname, prefix, splitLocalName);
			if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI);
			if (prefix.empty() && !namespaceURI.empty() && !_namespaces.isMapped(namespaceURI))
			{
				prefix = newPrefix();
				_namespaces.declarePrefix(prefix, namespaceURI);
			}

			const XMLString& uri = _namespaces.getURI(prefix);
			if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty())
			{
				_namespaces.declarePrefix(prefix, namespaceURI);
			}
		}
	}
}
コード例 #5
0
void AttributesImpl::setAttributes(const Attributes& attributes)
{
	if (&attributes != this)
	{
		int count = attributes.getLength();
		_attributes.clear();
		_attributes.reserve(count);
		for (int i = 0; i < count; i++)
		{
			addAttribute(attributes.getURI(i), attributes.getLocalName(i), attributes.getQName(i), attributes.getType(i), attributes.getValue(i));
		}
	}
}
コード例 #6
0
// ---------------------------------------------------------------------------
//  SAX2SortAttributesFilter: Overrides of the SAX2XMLFilter interface
// ---------------------------------------------------------------------------
void SAX2SortAttributesFilter::startElement(const   XMLCh* const    uri,
                                            const   XMLCh* const    localname,
                                            const   XMLCh* const    qname,
                                            const   Attributes&		attributes)
{
    AttrList sortedList(attributes.getLength());
    for(XMLSize_t i=0;i<attributes.getLength();i++)
    {
        XMLSize_t j;
        for(j=0;j<sortedList.getLength();j++)
        {
            if(XMLString::compareString(sortedList.elementAt(j)->qName,attributes.getQName(i))>=0)
                break;
        }
        Attr* pClone=new Attr;
        pClone->qName       = attributes.getQName(i);
        pClone->uri         = attributes.getURI(i);
        pClone->localPart   = attributes.getLocalName(i);
        pClone->value       = attributes.getValue(i);
        pClone->attrType    = attributes.getType(i);
        sortedList.insertElementAt(pClone, j);
    }
    SAX2XMLFilterImpl::startElement(uri, localname, qname, sortedList);
}
コード例 #7
0
void ThreadParser::SAX2Handler::startElement(const XMLCh *const /*uri*/,
                              const XMLCh *const localname,
                              const XMLCh *const /*qname*/,
                              const Attributes& attributes)
{
    SAX2Instance->addToCheckSum(localname);

    XMLSize_t n = attributes.getLength();
    XMLSize_t i;
    for (i=0; i<n; i++)
    {
        const XMLCh *attNam = attributes.getQName(i);
        SAX2Instance->addToCheckSum(attNam);
        const XMLCh *attVal = attributes.getValue(i);
        SAX2Instance->addToCheckSum(attVal);
    }
}
コード例 #8
0
void SAX2PrintHandlers::startElement(const   XMLCh* const    uri,
                                     const   XMLCh* const    localname,
                                     const   XMLCh* const    qname,
                                     const   Attributes&		attributes)
{
    // The name has to be representable without any escapes
    fFormatter  << XMLFormatter::NoEscapes << chOpenAngle ;
    if ( fExpandNS )
    {
        if (XMLString::compareIString(uri,XMLUni::fgZeroLenString) != 0)
            fFormatter  << uri << chColon;
        fFormatter << localname ;
    }
    else
        fFormatter << qname ;

    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 ;
        if ( fExpandNS )
        {
            if (XMLString::compareIString(attributes.getURI(index),XMLUni::fgZeroLenString) != 0)
                fFormatter  << attributes.getURI(index) << chColon;
            fFormatter  << attributes.getLocalName(index) ;
        }
        else
            fFormatter  << attributes.getQName(index) ;

        fFormatter  << chEqual << chDoubleQuote
                    << XMLFormatter::AttrEscapes
                    << attributes.getValue(index)
                    << XMLFormatter::NoEscapes
                    << chDoubleQuote;
    }
    fFormatter << chCloseAngle;
}
コード例 #9
0
void SAX2Handler::startElement(const   XMLCh* const    ,
									const   XMLCh* const    localname,
									const   XMLCh* const    ,
                                    const   Attributes&		attributes)
{
	if(!XMLString::compareString(localname,s_transUnitXMLCh))
	{
		unsigned int len = attributes.getLength();
		
		++m_numberOfRecords;
		
		for (unsigned int index = 0; index < len; index++)
		{
			const XMLCh* name = attributes.getQName(index) ;
			
			if (name != NULL && !XMLString::compareString(name,s_idXMLCh)	)
			{
				const XMLCh* val = attributes.getValue(index);
				if ( val != NULL )
				{
					if ( m_numberOfRecords != 1)
						printBeginOfIndexLine();
										
					m_fIndexOutputStream.writeAsASCII(val,XMLString::stringLen(val));
					
					char buff[100];
					
					sprintf( buff, "		 = %d \n",(m_numberOfRecords - 1));
					
					m_fIndexOutputStream.writeAsASCII(buff,XMLString::stringLen(buff));
					
					printEndOfIndexLine ();
				}
			}
			
			
		}
		
	}
}
コード例 #10
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::addAttributes(AttributeMap& attributeMap, const Attributes& attributes, const XMLString& elementNamespaceURI)
{
	for (int i = 0; i < attributes.getLength(); i++)
	{
		XMLString namespaceURI = attributes.getURI(i);
		XMLString localName    = attributes.getLocalName(i);
		XMLString qname        = attributes.getQName(i);
		if (!localName.empty())
		{
			XMLString prefix;
			if (namespaceURI != elementNamespaceURI)
				prefix = _namespaces.getPrefix(namespaceURI);
			if (!prefix.empty())
			{
				qname = prefix;
				qname.append(toXMLString(MARKUP_COLON));
			}
			else qname.clear();
			qname.append(localName);
		}
		attributeMap[qname] = attributes.getValue(i);
	}
}
コード例 #11
0
ファイル: AttributesImpl.cpp プロジェクト: twangjie/quickcpp
//==============================================================================
void AttributesImpl::setAttributes(const Attributes& atts)
{
	//
	// First, remove all entries from this collection
	//
	clear();

	//
	// Then iterate through the passed Attributes collection, creating
	// a new Attribute for each one and adding it to our collection
	//
	for(size_t i = 0; i < atts.getLength(); ++i)
	{
		AutoPtr<Attribute> rpAttr = new Attribute(atts.getQName(i),
		                                         atts.getValue(i),
		                                         atts.getType(i));

		if(!m_attributes.addAttribute(rpAttr.get()))
		{
			throw IllegalArgumentException(QC_T("attribute already exists"));
		}
	}
}
コード例 #12
0
void ManifestXML_Handler::startElement(const   XMLCh* const    uri,
									    const   XMLCh* const    localname,
										const   XMLCh* const    qname,
										const   Attributes&     attrs)
{
	char* element = XMLString::transcode(qname);
	CString elementString = element;
	XMLString::release(&element);
	
    /* variables used to extact attibute strings */
    unsigned int len = attrs.getLength();
    char* QName;
	char* Value;

	Debug(elementString);

	switch (ManifestXML_State)
	{
		case FINDING_FILE :
			if (elementString.Compare("file") == 0)
			{	
				ManifestXML_State = FOUND_FILE;
				Debug("FOUND file");
                
                for (unsigned int attrCount = 0; attrCount < len; attrCount++)
	            {
		            QName = XMLString::transcode(attrs.getQName((short) attrCount));
					CString QNameString = QName;
		            XMLString::release(&QName);
	            
		            Value = XMLString::transcode(attrs.getValue((short) attrCount));

                    if (QNameString.Compare("method") == 0)
				    {
					    currentManifest.manifMethod = Value;
					    gotFileMethod = true;
				    }
                    				
				    if (QNameString.Compare("date_required") == 0)
				    {
					    currentManifest.manifDateRequired = Value;
					    gotDateRequired = true;
				    }
					QNameString.Empty();
	            }
			}
		break;

		case FOUND_FILE :
			if (elementString.Compare("image_file") == 0)
			{
				Debug("FOUND image_file");
				XML_CharState = MANIFEST_IMAGE;
				gotImageFile = true;

                for (unsigned int attrCount = 0; attrCount < len; attrCount++)
	            {
		            QName = XMLString::transcode(attrs.getQName((short) attrCount));
		            CString QNameString = QName;
		            XMLString::release(&QName);
	            
		            Value = XMLString::transcode(attrs.getValue((short) attrCount));

                    if (QNameString.Compare("type") == 0)
				    {
					    currentManifest.manifImageFileType = Value;
					    gotImageFileType = true;
				    }  
					QNameString.Empty();
	            }
			}
			
			if (elementString.Compare("multimedia_file") == 0)
			{
				Debug("FOUND multimedia_file");
				XML_CharState = MANIFEST_MULTIMEDIA;
				gotMultimediaFile = true;

                for (unsigned int attrCount = 0; attrCount < len; attrCount++)
	            {
		            QName = XMLString::transcode(attrs.getQName((short) attrCount));
		            CString QNameString = QName;
		            XMLString::release(&QName);
	            
		            Value = XMLString::transcode(attrs.getValue((short) attrCount));

                    if (QNameString.Compare("type") == 0)
				    {
					    currentManifest.manifMultimediaFileType = Value;
					    gotMultimediaFileType = true;
				    }
					QNameString.Empty();
	            }
			}

			if (elementString.Compare("print_file") == 0)
			{
				Debug("FOUND print_file");
				XML_CharState = MANIFEST_PRINT;
				gotPrintFile = true;

                for (unsigned int attrCount = 0; attrCount < len; attrCount++)
	            {
		            QName = XMLString::transcode(attrs.getQName((short) attrCount));
		            CString QNameString = QName;
		            XMLString::release(&QName);
	            
		            Value = XMLString::transcode(attrs.getValue((short) attrCount));

                    if (QNameString.Compare("type") == 0)
				    {
					    currentManifest.manifPrintFileType = Value;
					    gotPrintFileType = true;
				    }
					QNameString.Empty();
	            }
			}
		break;
	}
	elementString.Empty();
}
コード例 #13
0
//}}}1 DXG DOC
void Deception::ConfigHandler::startElement(const XMLCh* const uri,
									const XMLCh* const localName,
									const XMLCh* const qName,
									const Attributes& attribs)
{
	Deception::ModuleRegistry store;
	int port;
	std::string logMsg;
	// xml element <modulelist>?
	if (std::string(XMLString::transcode(qName)).compare(OPTION_MODULE) == 0) {
		// then say so and get the hell outta here
		this->inModule = true;
	} else if ((std::string(XMLString::transcode(qName)).compare(OPTION_LOGFILE) == 0)
			&& (this->logFile.length() == 0)) {
		this->inLogFile = true;
	} else if (std::string(XMLString::transcode(qName)).compare(OPTION_MODULEDIR) == 0) {
		this->inModuleDir = true;
	} else if (std::string(XMLString::transcode(qName)).compare(OPTION_HOST) == 0) {
		this->inHostList = true;
	} else if (std::string(XMLString::transcode(qName)).compare(OPTION_USER) == 0) {
		this->inUser = true;
	} else if (std::string(XMLString::transcode(qName)).compare(OPTION_GROUP) == 0) {
		this->inGroup = true;
	} else if (std::string(XMLString::transcode(qName)).compare(OPTION_CAPTURE) == 0) {
		this->inCapture = true;
	}
	// fetch attributes
	for (unsigned int i = 0; i < attribs.getLength(); i++) {

		if ((std::string(XMLString::transcode(qName)).compare(OPTION_HOST) == 0)) {
			if (std::string(XMLString::transcode(attribs.getQName(i))).compare(OPTION_IP) == 0) {
				// get ipaddr
				this->ipaddr = XMLString::transcode(attribs.getValue(i));
			}
		// are we in element <module>?
		} else if ((std::string(XMLString::transcode(qName)).compare(OPTION_MODULE) == 0) && this->inHostList) {

			// if yes then get modulefilename,
			if (std::string(XMLString::transcode(attribs.getQName(i))).compare(OPTION_FILENAME) == 0) {
				// save modulefilename in class
				this->curModFileName = XMLString::transcode(attribs.getValue(i));
			} else // the modulename
			if (std::string(XMLString::transcode(attribs.getQName(i))).compare(OPTION_NAME) == 0) {
				// save modulefilename in class
				this->curModName = XMLString::transcode(attribs.getValue(i));
			} else // and the moduleoption
			if (std::string(XMLString::transcode(attribs.getQName(i))).compare(OPTION_OPTION) == 0) {
				// save modulefilename in class
				this->curModOption = XMLString::transcode(attribs.getValue(i));
			}
		// is it element <port>?
		} else if ((std::string(XMLString::transcode(qName)).compare(OPTION_PORT) == 0)
				&& this->inHostList && this->inModule) {

			// then let's check if there is an attribute called 'no'
			// specifying or nice port number
			if (std::string(XMLString::transcode(attribs.getQName(i))).compare(OPTION_PORTNO) == 0) {
				// is there currently a module defined?
				if (this->curModFileName.empty())
					continue;

				// get port
				try {
					port = XMLString::parseInt(attribs.getValue(i));
				} catch (NumberFormatException &e) {
					continue;
				}

				if (this->socketCount >= OPEN_MAX) {
					logMsg = "maximum number of open file descriptors reached.";
					logMsg.append(" dropping configuration for " + ipaddr + ":").append(intToString(port));
					globLog.toLog(this->className, Deception::Error, logMsg);
					logMsg.erase();
					continue;
				}				
				// is this port in any way legal?
				if ((port < 0) || (port > 65536)) {
					// otherwise we'll just ignore the crap
					logMsg.erase();
					logMsg.append("ignoring configuration port ").append(intToString(port))
						.append(" from module ").append(this->curModFileName)
						.append(": out of range");
					globLog.toLog(this->className, Deception::Debug, logMsg);
					continue;
				}

#ifdef DEBUG
				logMsg = "adding data for " + this->ipaddr + ":" + intToString(port)
					+ " with module " + this->curModName;
				globLog.toLog(this->className, Deception::Debug, logMsg);
#endif
				// add module data to store
				store.addModule(this->ipaddr, port, this->curModFileName, this->curModName, this->curModOption);
				this->socketCount++;
			}
		} else if (this->inCapture && (std::string(XMLString::transcode(attribs.getQName(i))).compare(OPTION_CAP_ENABLE) == 0)) {
			if (std::string(XMLString::transcode(attribs.getValue(i))).compare("yes") == 0) {
				enableCapture = true;
			}
		}
	} // end for

	return;
}