本文整理汇总了C++中Attributes::getLocalName方法的典型用法代码示例。如果您正苦于以下问题:C++ Attributes::getLocalName方法的具体用法?C++ Attributes::getLocalName怎么用?C++ Attributes::getLocalName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attributes
的用法示例。
在下文中一共展示了Attributes::getLocalName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
示例2: declareAttributeNamespaces
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);
}
}
}
}
示例3: if
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);
}
示例4: SetAttributes
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");
}
}
}
}
}
示例5: startElement
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;
}
}
示例6: setAttributes
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));
}
}
}
示例7: wcscmp
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;
}
示例8: startElement
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;
}
示例9: ReadUnits
// 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;
}
示例10: ReadNumericAttribute
// 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;
}
示例11:
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;
}
示例12: ReadTagNumber
// 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;
}
}
示例13: errMsg
vector<string> DAGXMLParser::attributesToStrings(const int nattr, const char* attrNames[], const Attributes& attrs) {
vector<string> ret(nattr);
XMLSize_t i;
int j;
for(i=0;i<attrs.getLength();i++) {
char* lname = XMLString::transcode(attrs.getLocalName(i));
char* val = XMLString::transcode(attrs.getValue(i));
for(j=0;j<nattr;j++) {
if(strcmp(lname,attrNames[j])==0) {
ret[j] = val;
break;
}
}
if(j==nattr) {
stringstream errMsg("DAGXMLParser::attributesToStrings(): Attribute not recognised: ");
errMsg << lname;
error(errMsg.str().c_str());
}
XMLString::release(&lname);
XMLString::release(&val);
}
return ret;
}
示例14: addAttributes
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);
}
}
示例15: sortedList
// ---------------------------------------------------------------------------
// 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);
}