void dhListText::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& att) { string message1 = XMLString::transcode(qname); if (!message1.compare("text") || !message1.compare("TEXT")) { string message2 = XMLString::transcode(att.getValue(XMLString::transcode("id"))); tempVecTextIDList.push_back(message2); message2 = XMLString::transcode(att.getValue(XMLString::transcode("src"))); tempVecTextFileList.push_back(message2); } }
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 << ">"; }
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 << ">"; } };
void MySAX2Handler::inTrackSegment::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs) { char* message = XMLString::transcode(localname); if(!strcmp(message, "trkpt")) { XMLCh* latStr = XMLString::transcode("lat"); XMLCh* lonStr = XMLString::transcode("lon"); const XMLCh* xmlLat = attrs.getValue(latStr); const XMLCh* xmlLon = attrs.getValue(lonStr); XMLString::release(&latStr); XMLString::release(&lonStr); if(xmlLat && xmlLon) { char* slat = XMLString::transcode(xmlLat); char* slon = XMLString::transcode(xmlLon); double lat = strtod(slat, (char **)NULL); double lon = strtod(slon, (char **)NULL); Track::TrackPoint *tp = new Track::TrackPoint(lat, lon); mSegment->addPoint(tp); //std::cout << "New point: (" << lat << ", " << lon << ") : " << *tp << std::endl; setState(new inTrackPoint(getHandler(), this, mTrack, *tp)); XMLString::release(&slat); XMLString::release(&slon); } else { std::cout << "Can't find lat " << xmlLat << " and " << xmlLon << std::endl; } } else { std::cout << "Unknown tag:"<< message << ":" << ": in track segment"<< std::endl; } XMLString::release(&message); }
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); }
void XMLTreeGenerator::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs) { string name = XMLUtil::trim(XMLUtil::WideCharToString(localname )); if (name.empty() ) return; XMLTree* pTree = NULL; if (m_pBuffer == NULL ) { m_pRoot->SetName(name); pTree = m_pRoot; } else { pTree = m_pBuffer->AddChild(name); } for (unsigned int i = 0; i < attrs.getLength(); i++ ) { pTree->AddAttribute( XMLUtil::trim(XMLUtil::WideCharToString(attrs.getLocalName(i ) ) ), XMLUtil::trim(XMLUtil::WideCharToString(attrs.getValue(i ) ) )); } m_pBuffer = pTree; }
void NASReader::CheckForRelations( const char *pszElement, const Attributes &attrs, char **ppszCurField ) { GMLFeature *poFeature = GetState()->m_poFeature; CPLAssert( poFeature != NULL ); int nIndex; XMLCh Name[100]; tr_strcpy( Name, "xlink:href" ); nIndex = attrs.getIndex( Name ); if( nIndex != -1 ) { char *pszHRef = tr_strdup( attrs.getValue( nIndex ) ); if( EQUALN(pszHRef,"urn:adv:oid:", 12 ) ) { poFeature->AddOBProperty( pszElement, pszHRef ); CPLFree( *ppszCurField ); *ppszCurField = CPLStrdup( pszHRef + 12 ); } CPLFree( pszHRef ); } }
void MySAX2Handler::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs) { char* message = XMLString::transcode(localname); if (strcmp(message, "TIME_SLOT") == 0) { string label; int value; for (int i=0; i<attrs.getLength(); i++) { char *localname = XMLString::transcode(attrs.getLocalName(i)); char *atvalue = XMLString::transcode(attrs.getValue(i)); if (strcmp(localname, "TIME_SLOT_ID") == 0) { label = atvalue; } else if (strcmp(localname, "TIME_VALUE") == 0) { value = atoi(atvalue); } //cout << localname << " " << value << endl; time_slots[label] = value; XMLString::release(&localname); XMLString::release(&atvalue); } cout << label << " " << value << endl; } else { cout << "I saw element: "<< message << endl; } XMLString::release(&message); }
void NASReader::PushFeature( const char *pszElement, const Attributes &attrs ) { int iClass; /* -------------------------------------------------------------------- */ /* Find the class of this element. */ /* -------------------------------------------------------------------- */ for( iClass = 0; iClass < GetClassCount(); iClass++ ) { if( EQUAL(pszElement,GetClass(iClass)->GetElementName()) ) break; } /* -------------------------------------------------------------------- */ /* Create a new feature class for this element, if there is no */ /* existing class for it. */ /* -------------------------------------------------------------------- */ if( iClass == GetClassCount() ) { CPLAssert( !IsClassListLocked() ); GMLFeatureClass *poNewClass = new GMLFeatureClass( pszElement ); AddClass( poNewClass ); } /* -------------------------------------------------------------------- */ /* Create a feature of this feature class. */ /* -------------------------------------------------------------------- */ GMLFeature *poFeature = new GMLFeature( GetClass( iClass ) ); /* -------------------------------------------------------------------- */ /* Create and push a new read state. */ /* -------------------------------------------------------------------- */ GMLReadState *poState; poState = new GMLReadState(); poState->m_poFeature = poFeature; PushState( poState ); /* -------------------------------------------------------------------- */ /* Check for gml:id, and if found push it as an attribute named */ /* gml_id. */ /* -------------------------------------------------------------------- */ int nFIDIndex; XMLCh anFID[100]; tr_strcpy( anFID, "gml:id" ); nFIDIndex = attrs.getIndex( anFID ); if( nFIDIndex != -1 ) { char *pszFID = tr_strdup( attrs.getValue( nFIDIndex ) ); SetFeatureProperty( "gml_id", pszFID ); CPLFree( pszFID ); } }
//--------------------------------------------------------------------------- // @function: // CParseHandlerPhysicalSplit::StartElement // // @doc: // Invoked by Xerces to process an opening tag // //--------------------------------------------------------------------------- void CParseHandlerPhysicalSplit::StartElement ( const XMLCh* const, // xmlszUri, const XMLCh* const xmlszLocalname, const XMLCh* const, // xmlszQname const Attributes &attrs ) { if (0 != XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenPhysicalSplit), xmlszLocalname)) { CWStringDynamic *pstr = CDXLUtils::PstrFromXMLCh(m_pphm->Pmm(), xmlszLocalname); GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag, pstr->Wsz()); } const XMLCh *xmlszDeleteColIds = CDXLOperatorFactory::XmlstrFromAttrs(attrs, EdxltokenDeleteCols, EdxltokenPhysicalSplit); m_pdrgpulDelete = CDXLOperatorFactory::PdrgpulFromXMLCh(m_pphm->Pmm(), xmlszDeleteColIds, EdxltokenDeleteCols, EdxltokenPhysicalSplit); const XMLCh *xmlszInsertColIds = CDXLOperatorFactory::XmlstrFromAttrs(attrs, EdxltokenInsertCols, EdxltokenPhysicalSplit); m_pdrgpulInsert = CDXLOperatorFactory::PdrgpulFromXMLCh(m_pphm->Pmm(), xmlszInsertColIds, EdxltokenInsertCols, EdxltokenPhysicalSplit); m_ulAction = CDXLOperatorFactory::UlValueFromAttrs(m_pphm->Pmm(), attrs, EdxltokenActionColId, EdxltokenPhysicalSplit); m_ulCtid = CDXLOperatorFactory::UlValueFromAttrs(m_pphm->Pmm(), attrs, EdxltokenCtidColId, EdxltokenPhysicalSplit); m_ulSegmentId = CDXLOperatorFactory::UlValueFromAttrs(m_pphm->Pmm(), attrs, EdxltokenGpSegmentIdColId, EdxltokenPhysicalSplit); const XMLCh *xmlszPreserveOids = attrs.getValue(CDXLTokens::XmlstrToken(EdxltokenUpdatePreservesOids)); if (NULL != xmlszPreserveOids) { m_fPreserveOids = CDXLOperatorFactory::FValueFromXmlstr ( m_pphm->Pmm(), xmlszPreserveOids, EdxltokenUpdatePreservesOids, EdxltokenPhysicalSplit ); } if (m_fPreserveOids) { m_ulTupleOidColId = CDXLOperatorFactory::UlValueFromAttrs(m_pphm->Pmm(), attrs, EdxltokenTupleOidColId, EdxltokenPhysicalSplit); } // parse handler for physical operator CParseHandlerBase *pphChild = CParseHandlerFactory::Pph(m_pmp, CDXLTokens::XmlstrToken(EdxltokenPhysical), m_pphm, this); m_pphm->ActivateParseHandler(pphChild); // parse handler for the proj list CParseHandlerBase *pphPrL = CParseHandlerFactory::Pph(m_pmp, CDXLTokens::XmlstrToken(EdxltokenScalarProjList), m_pphm, this); m_pphm->ActivateParseHandler(pphPrL); //parse handler for the properties of the operator CParseHandlerBase *pphProp = CParseHandlerFactory::Pph(m_pmp, CDXLTokens::XmlstrToken(EdxltokenProperties), m_pphm, this); m_pphm->ActivateParseHandler(pphProp); // store child parse handlers in array this->Append(pphProp); this->Append(pphPrL); this->Append(pphChild); }
//--------------------------------------------------------------------------- // @function: // CParseHandlerLogicalLimit::StartElement // // @doc: // Invoked by Xerces to process an opening tag // //--------------------------------------------------------------------------- void CParseHandlerLogicalLimit::StartElement ( const XMLCh* const, // element_uri, const XMLCh* const element_local_name, const XMLCh* const, // element_qname const Attributes& attrs ) { if (0 == XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenLogicalLimit), element_local_name)) { const XMLCh *non_removable_limit_str = attrs.getValue(CDXLTokens::XmlstrToken(EdxltokenTopLimitUnderDML)); BOOL keep_limit = false; if (non_removable_limit_str) { keep_limit = CDXLOperatorFactory::ConvertAttrValueToBool ( m_parse_handler_mgr->GetDXLMemoryManager(), non_removable_limit_str, EdxltokenTopLimitUnderDML, EdxltokenLogicalLimit ); } m_dxl_node = GPOS_NEW(m_mp) CDXLNode(m_mp, GPOS_NEW(m_mp) CDXLLogicalLimit(m_mp, keep_limit)); // create child node parsers // parse handler for logical operator CParseHandlerBase *child_parse_handler = CParseHandlerFactory::GetParseHandler(m_mp, CDXLTokens::XmlstrToken(EdxltokenLogical), m_parse_handler_mgr, this); m_parse_handler_mgr->ActivateParseHandler(child_parse_handler); CParseHandlerBase *offset_parse_handler = CParseHandlerFactory::GetParseHandler(m_mp, CDXLTokens::XmlstrToken(EdxltokenScalarLimitOffset), m_parse_handler_mgr, this); m_parse_handler_mgr->ActivateParseHandler(offset_parse_handler); CParseHandlerBase *count_parse_handler = CParseHandlerFactory::GetParseHandler(m_mp, CDXLTokens::XmlstrToken(EdxltokenScalarLimitCount), m_parse_handler_mgr, this); m_parse_handler_mgr->ActivateParseHandler(count_parse_handler); // parse handler for the sorting column list CParseHandlerBase *sort_col_list_parse_handler = CParseHandlerFactory::GetParseHandler(m_mp, CDXLTokens::XmlstrToken(EdxltokenScalarSortColList), m_parse_handler_mgr, this); m_parse_handler_mgr->ActivateParseHandler(sort_col_list_parse_handler); // store child parse handler in array this->Append(sort_col_list_parse_handler); this->Append(count_parse_handler); this->Append(offset_parse_handler); this->Append(child_parse_handler); } else { CWStringDynamic *str = CDXLUtils::CreateDynamicStringFromXMLChArray(m_parse_handler_mgr->GetDXLMemoryManager(), element_local_name); GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag, str->GetBuffer()); } }
//--------------------------------------------------------------------------- // @function: // CParseHandlerStatsDerivedRelation::StartElement // // @doc: // Invoked by Xerces to process an opening tag // //--------------------------------------------------------------------------- void CParseHandlerStatsDerivedRelation::StartElement ( const XMLCh* const xmlszUri, const XMLCh* const xmlszLocalname, const XMLCh* const xmlszQname, const Attributes& attrs ) { if (0 == XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsDerivedColumn), xmlszLocalname)) { // start new derived column element CParseHandlerBase *pph = CParseHandlerFactory::Pph(m_pmp, CDXLTokens::XmlstrToken(EdxltokenStatsDerivedColumn), m_pphm, this); m_pphm->ActivateParseHandler(pph); // store parse handler this->Append(pph); pph->startElement(xmlszUri, xmlszLocalname, xmlszQname, attrs); } else { GPOS_ASSERT(0 == this->UlLength()); // parse rows const XMLCh *xmlszRows = CDXLOperatorFactory::XmlstrFromAttrs ( attrs, EdxltokenRows, EdxltokenStatsDerivedRelation ); m_dRows = CDouble(CDXLOperatorFactory::DValueFromXmlstr ( m_pphm->Pmm(), xmlszRows, EdxltokenRows, EdxltokenStatsDerivedRelation )); m_fEmpty = false; const XMLCh *xmlszEmpty = attrs.getValue(CDXLTokens::XmlstrToken(EdxltokenEmptyRelation)); if (NULL != xmlszEmpty) { m_fEmpty = CDXLOperatorFactory::FValueFromXmlstr ( m_pphm->Pmm(), xmlszEmpty, EdxltokenEmptyRelation, EdxltokenStatsDerivedRelation ); } } }
void GpXmlStateMachine::SetAttributes(GpType* target, const Attributes& attrs) { XMLSize_t numAtts = attrs.getLength(); string retValue; map<string, string> attributes; DEBOUT("GpXmlStateMachine::SetAttributes - Type"); if (numAtts > 0) { for (XMLSize_t i = 0; i < numAtts; i++) { string local(XMLString::transcode(attrs.getLocalName(i) ) ); string value(XMLString::transcode(attrs.getValue(i) ) ); attributes[local] = value; DEBOUT(i); DEBOUT(local); DEBOUT(value); } // Checking the member for constness if (FindAttribute(attributes, ConstStr, retValue) ) { if (retValue.compare(TrueStr) == 0) { target->Const(true); } } // Checking the member for staticness if (FindAttribute(attributes, StaticStr, retValue) ) { if (retValue.compare(TrueStr) == 0) { target->Static(true); } } // Checking if the member is a pointer or reference if (FindAttribute(attributes, DirecStr, retValue) ) { if (retValue.compare(PtrStr) == 0) { target->Direc(POINTER); DEBOUT("Pointer"); } else { if (retValue.compare(RefStr) == 0) { target->Direc(REFERENCE); DEBOUT("Reference"); } } } } }
//--------------------------------------------------------------------------- // @function: // CParseHandlerStatsDerivedRelation::StartElement // // @doc: // Invoked by Xerces to process an opening tag // //--------------------------------------------------------------------------- void CParseHandlerStatsDerivedRelation::StartElement ( const XMLCh* const element_uri, const XMLCh* const element_local_name, const XMLCh* const element_qname, const Attributes& attrs ) { if (0 == XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsDerivedColumn), element_local_name)) { // start new derived column element CParseHandlerBase *parse_handler_base = CParseHandlerFactory::GetParseHandler(m_mp, CDXLTokens::XmlstrToken(EdxltokenStatsDerivedColumn), m_parse_handler_mgr, this); m_parse_handler_mgr->ActivateParseHandler(parse_handler_base); // store parse handler this->Append(parse_handler_base); parse_handler_base->startElement(element_uri, element_local_name, element_qname, attrs); } else { GPOS_ASSERT(0 == this->Length()); // parse rows const XMLCh *xml_rows = CDXLOperatorFactory::ExtractAttrValue ( attrs, EdxltokenRows, EdxltokenStatsDerivedRelation ); m_rows = CDouble(CDXLOperatorFactory::ConvertAttrValueToDouble ( m_parse_handler_mgr->GetDXLMemoryManager(), xml_rows, EdxltokenRows, EdxltokenStatsDerivedRelation )); m_empty = false; const XMLCh *xml_is_empty = attrs.getValue(CDXLTokens::XmlstrToken(EdxltokenEmptyRelation)); if (NULL != xml_is_empty) { m_empty = CDXLOperatorFactory::ConvertAttrValueToBool ( m_parse_handler_mgr->GetDXLMemoryManager(), xml_is_empty, EdxltokenEmptyRelation, EdxltokenStatsDerivedRelation ); } } }
void XTandemInfileXMLHandler::startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const Attributes & attributes) { tag_.push_back(String(sm_.convert(qname))); if (tag_.back() == "note") { int type_idx = attributes.getIndex(sm_.convert("type")); int label_idx = attributes.getIndex(sm_.convert("label")); if (type_idx != -1) { actual_note_.note_type = String(sm_.convert(attributes.getValue(type_idx))); } if (label_idx != -1) { actual_note_.note_label = String(sm_.convert(attributes.getValue(label_idx))); } } }
void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes) { where("startElement"); std::cout << "uri: " << uri << std::endl << "localName: " << localName << std::endl << "qname: " << qname << std::endl; std::cout << "Attributes: " << std::endl; for (int i = 0; i < attributes.getLength(); ++i) { std::cout << attributes.getLocalName(i) << "=" << attributes.getValue(i) << std::endl; } }
//--------------------------------------------------------------------------- // @function: // CParseHandlerLogicalUpdate::StartElement // // @doc: // Invoked by Xerces to process an opening tag // //--------------------------------------------------------------------------- void CParseHandlerLogicalUpdate::StartElement ( const XMLCh* const, // element_uri, const XMLCh* const element_local_name, const XMLCh* const, // element_qname const Attributes &attrs ) { if (0 != XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenLogicalUpdate), element_local_name)) { CWStringDynamic *str = CDXLUtils::CreateDynamicStringFromXMLChArray(m_parse_handler_mgr->GetDXLMemoryManager(), element_local_name); GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag, str->GetBuffer()); } m_ctid_colid = CDXLOperatorFactory::ExtractConvertAttrValueToUlong(m_parse_handler_mgr->GetDXLMemoryManager(), attrs, EdxltokenCtidColId, EdxltokenLogicalUpdate); m_segid_colid = CDXLOperatorFactory::ExtractConvertAttrValueToUlong(m_parse_handler_mgr->GetDXLMemoryManager(), attrs, EdxltokenGpSegmentIdColId, EdxltokenLogicalUpdate); const XMLCh *delete_colids_xml = CDXLOperatorFactory::ExtractAttrValue(attrs, EdxltokenDeleteCols, EdxltokenLogicalUpdate); m_deletion_colid_array = CDXLOperatorFactory::ExtractIntsToUlongArray(m_parse_handler_mgr->GetDXLMemoryManager(), delete_colids_xml, EdxltokenDeleteCols, EdxltokenLogicalUpdate); const XMLCh *insert_colids_xml = CDXLOperatorFactory::ExtractAttrValue(attrs, EdxltokenInsertCols, EdxltokenLogicalUpdate); m_insert_colid_array = CDXLOperatorFactory::ExtractIntsToUlongArray(m_parse_handler_mgr->GetDXLMemoryManager(), insert_colids_xml, EdxltokenInsertCols, EdxltokenLogicalUpdate); const XMLCh *preserve_oids_xml = attrs.getValue(CDXLTokens::XmlstrToken(EdxltokenUpdatePreservesOids)); if (NULL != preserve_oids_xml) { m_preserve_oids = CDXLOperatorFactory::ConvertAttrValueToBool ( m_parse_handler_mgr->GetDXLMemoryManager(), preserve_oids_xml, EdxltokenUpdatePreservesOids, EdxltokenLogicalUpdate ); } if (m_preserve_oids) { m_tuple_oid_col_oid = CDXLOperatorFactory::ExtractConvertAttrValueToUlong(m_parse_handler_mgr->GetDXLMemoryManager(), attrs, EdxltokenTupleOidColId, EdxltokenLogicalUpdate); } // parse handler for logical operator CParseHandlerBase *child_parse_handler = CParseHandlerFactory::GetParseHandler(m_mp, CDXLTokens::XmlstrToken(EdxltokenLogical), m_parse_handler_mgr, this); m_parse_handler_mgr->ActivateParseHandler(child_parse_handler); //parse handler for the table descriptor CParseHandlerBase *table_descr_parse_handler = CParseHandlerFactory::GetParseHandler(m_mp, CDXLTokens::XmlstrToken(EdxltokenTableDescr), m_parse_handler_mgr, this); m_parse_handler_mgr->ActivateParseHandler(table_descr_parse_handler); // store child parse handler in array this->Append(table_descr_parse_handler); this->Append(child_parse_handler); }
void currencyHandler::startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes) { // where("startElement"); std::cout << "start element uri: " << uri << std::endl << "localName: " << localName << std::endl << "qname: " << qname << std::endl; if (localName.compare("resource") == 0) { std::cout << " Quote starting here.." << std::endl; inQuote = true; } else if (localName.compare("field") == 0) { std::cout << " field starting here.." << std::endl; // std::cout<<" field value is "<<attributes.getValue(i)<<std::endl; } std::cout << "Attributes: " << std::endl; for (int i = 0; i < attributes.getLength(); ++i) { std::cout << " attributes.getValue(i) : " << attributes.getValue(i) << std::endl; if (attributes.getValue(i).compare("symbol") == 0) { currentFieldReading = symbolType; } else if (attributes.getValue(i).compare("ts") == 0) { currentFieldReading = tsType; } else if (attributes.getValue(i).compare("utctime") == 0) { currentFieldReading = utctimelType; } else if (attributes.getValue(i).compare("volume") == 0) { currentFieldReading = volumeType; } else if (attributes.getValue(i).compare("price") == 0) { currentFieldReading = priceType; } else if (attributes.getValue(i).compare("name") == 0) { currentFieldReading = nameType; } else if (attributes.getValue(i).compare("type") == 0) { currentFieldReading = typeType; } } }
void LeakDiagLogStatisticTool::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs) { const XMLCh* pAttributeValue = NULL; if (wcscmp(qname, L"STACK") == 0) { m_pLeakData = new LeakData; // 获取Stack的内存泄露次数 pAttributeValue = attrs.getValue(L"numallocs"); if (!pAttributeValue) { Log("Error: Failed to get XML node attribute \"numallocs\"."); } m_sstreamBuffer.clear(); m_sstreamBuffer << XMLString::transcode(pAttributeValue); m_sstreamBuffer >> m_pLeakData->uAllocNum; // 获取Stack的平均内存泄露大小 pAttributeValue = attrs.getValue(L"size"); if (!pAttributeValue) { Log("Error: Failed to get XML node attribute \"size\"."); } m_sstreamBuffer.clear(); m_sstreamBuffer << XMLString::transcode(pAttributeValue); m_sstreamBuffer >> m_pLeakData->uSize; // 获取Stack的总内存泄露大小 pAttributeValue = attrs.getValue(L"totalsize"); if (!pAttributeValue) { Log("Error: Failed to get XML node attribute \"totalsize\"."); } m_sstreamBuffer.clear(); m_sstreamBuffer << XMLString::transcode(pAttributeValue); m_sstreamBuffer >> m_pLeakData->uTotalSize; // 统计程序总内存泄露大小 m_uTotalLeakSize += m_pLeakData->uTotalSize; }
bool qm::AutoPilotContentHandler::startElement(const WCHAR* pwszNamespaceURI, const WCHAR* pwszLocalName, const WCHAR* pwszQName, const Attributes& attributes) { if (wcscmp(pwszLocalName, L"entry") == 0) { if (state_ != STATE_AUTOPILOT) return false; bEnabled_ = true; for (int n = 0; n < attributes.getLength(); ++n) { const WCHAR* pwszAttrName = attributes.getLocalName(n); if (wcscmp(pwszAttrName, L"enabled") == 0) bEnabled_ = wcscmp(attributes.getValue(n), L"false") != 0; else return false; } state_ = STATE_ENTRY; } else { struct { const WCHAR* pwszName_; State stateBefore_; State stateAfter_; } states[] = { { L"autoPilot", STATE_ROOT, STATE_AUTOPILOT }, { L"course", STATE_ENTRY, STATE_COURSE }, { L"interval", STATE_ENTRY, STATE_INTERVAL } }; int n = 0; for (n = 0; n < countof(states); ++n) { if (wcscmp(pwszLocalName, states[n].pwszName_) == 0) { if (state_ != states[n].stateBefore_) return false; if (attributes.getLength() != 0) return false; state_ = states[n].stateAfter_; break; } } if (n == countof(states)) return false; } return true; }
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); } }
// Read tag with name *theTag and return its value as a double // If not found, return the supplied default value // Main use is for command with a single numeric tag double CommonReadHandler::ReadNumericAttribute(const char *theTag,const Attributes& attrs,double defaultValue) { int i,numAttr=(int)attrs.getLength(); char *aName,*value; double attrValue=defaultValue; for(i=0; i<numAttr; i++) { aName=XMLString::transcode(attrs.getLocalName(i)); if(strcmp(aName,theTag)==0) { value=XMLString::transcode(attrs.getValue(i)); sscanf(value,"%lf",&attrValue); delete [] aName; delete [] value; break; } delete [] aName; } return attrValue; }
// Read first 'units' attribute and return a scaling factor an input quantity // to convert to standard analysis units // The options are for time, length, and velocity units // If no 'units' found or invalid one found, return 1. double CommonReadHandler::ReadUnits(const Attributes& attrs,int type) { int i,numAttr=(int)attrs.getLength(); char *aName,*value; double attrScale=1.; for(i=0; i<numAttr; i++) { aName=XMLString::transcode(attrs.getLocalName(i)); if(strcmp(aName,"units")==0) { value=XMLString::transcode(attrs.getValue(i)); attrScale = UnitsController::UnitsAttribute(value,type); delete [] aName; delete [] value; break; } delete [] aName; } return attrScale; }
void CVxmlSAXHandler::startElement( const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs ){ TTagAttributes iAttributes char* pTagName; TTagAttribute iAttr; //get Tag's name and Attributes pTagName = XMLString::transcode(localname); // cout<<"attrs:"<<endl; for(int i=0;i<attrs.getLength();i++) { //get the Attribute's infomation iAttr.pName = XMLString::transcode(attrs.getLocalName(i)); iAttr.pType = XMLString::transcode(attrs.getType(i)); iAttr.pValue = XMLString::transcode(attrs.getValue(i)); // add to attributes's vector in order to send to Vxml Builder iAttributes.push_back(iAttr); // cout<<"\tLocalName="<<XMLString::transcode(attrs.getLocalName(i)); // cout<<"\tType="<<XMLString::transcode(attrs.getType(i)); // cout<<"\tVaule="<<XMLString::transcode(attrs.getValue(i))<<endl; } // build the Module by pass the infomation to Vxml Builder m_iBuilder->StartModule(pTagName,iAttributes); // release the resource XMLString::release(&pTagName); for(int i=0;i<iAttributes.size();i++) { iAttr = iAttributes.at(i); XMLString::release(&iAttr.pName); XMLString::release(&iAttr.pAttrType); XMLString::release(&iAttr.pAttrValue); } return; }
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; }
// read the 'number' attribute in current tag, ignore other attributes void CommonReadHandler::ReadTagNumber(int *myval,const Attributes& attrs) { int i,aval; char *aName,*value; int numAttr=(int)attrs.getLength(); *myval=0; for(i=0; i<numAttr; i++) { aName=XMLString::transcode(attrs.getLocalName(i)); if(strcmp(aName,"number")==0) { value=XMLString::transcode(attrs.getValue(i)); sscanf(value,"%i",&aval); *myval=aval; delete [] value; delete [] aName; break; } delete [] aName; } }
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 (); } } } } }
//--------------------------------------------------------------------------- // @function: // CParseHandlerMDRelation::ParseRelationAttributes // // @doc: // Helper function to parse relation attributes: name, id, // distribution policy and keys // //--------------------------------------------------------------------------- void CParseHandlerMDRelation::ParseRelationAttributes ( const Attributes& attrs, Edxltoken edxltokenElement ) { // parse table name const XMLCh *xmlszTableName = CDXLOperatorFactory::XmlstrFromAttrs(attrs, EdxltokenName, edxltokenElement); CWStringDynamic *pstrTableName = CDXLUtils::PstrFromXMLCh(m_pphm->Pmm(), xmlszTableName); m_pmdname = GPOS_NEW(m_pmp) CMDName(m_pmp, pstrTableName); GPOS_DELETE(pstrTableName); // parse metadata id info m_pmdid = CDXLOperatorFactory::PmdidFromAttrs(m_pphm->Pmm(), attrs, EdxltokenMdid, edxltokenElement); // parse distribution policy const XMLCh *xmlszDistrPolicy = CDXLOperatorFactory::XmlstrFromAttrs(attrs, EdxltokenRelDistrPolicy, edxltokenElement); m_ereldistrpolicy = CDXLOperatorFactory::EreldistrpolicyFromXmlstr(xmlszDistrPolicy); if (m_ereldistrpolicy == IMDRelation::EreldistrHash) { // parse distribution columns const XMLCh *xmlszDistrColumns = CDXLOperatorFactory::XmlstrFromAttrs(attrs, EdxltokenDistrColumns, edxltokenElement); m_pdrgpulDistrColumns = CDXLOperatorFactory::PdrgpulFromXMLCh(m_pphm->Pmm(), xmlszDistrColumns, EdxltokenDistrColumns, edxltokenElement); } // parse keys const XMLCh *xmlszKeys = attrs.getValue(CDXLTokens::XmlstrToken(EdxltokenKeys)); if (NULL != xmlszKeys) { m_pdrgpdrgpulKeys = CDXLOperatorFactory::PdrgpdrgpulFromXMLCh(m_pphm->Pmm(), xmlszKeys, EdxltokenKeys, edxltokenElement); } else { // construct an empty keyset m_pdrgpdrgpulKeys = GPOS_NEW(m_pmp) DrgPdrgPul(m_pmp); } }
void NASReader::CheckForFID( const Attributes &attrs, char **ppszCurField ) { int nIndex; XMLCh Name[100]; tr_strcpy( Name, "fid" ); nIndex = attrs.getIndex( Name ); if( nIndex != -1 ) { char *pszFID = tr_strdup( attrs.getValue( nIndex ) ); CPLString osCurField = *ppszCurField; osCurField += pszFID; CPLFree( pszFID ); CPLFree( *ppszCurField ); *ppszCurField = CPLStrdup(osCurField); } }
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); } }