本文整理汇总了C++中DOMDocumentImpl::isXMLName方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMDocumentImpl::isXMLName方法的具体用法?C++ DOMDocumentImpl::isXMLName怎么用?C++ DOMDocumentImpl::isXMLName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocumentImpl
的用法示例。
在下文中一共展示了DOMDocumentImpl::isXMLName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPrefix
void DOMElementNSImpl::setPrefix(const XMLCh *prefix)
{
if (fNode.isReadOnly())
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNodeMemoryManager);
if (fNamespaceURI == 0 || fNamespaceURI[0] == chNull)
throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);
if (prefix == 0 || *prefix == 0) {
fPrefix = 0;
fName = fLocalName;
return;
}
DOMDocumentImpl* doc = (DOMDocumentImpl*) fParent.fOwnerDocument;
if(!doc->isXMLName(prefix))
throw DOMException(DOMException::INVALID_CHARACTER_ERR,0, GetDOMNodeMemoryManager);
const XMLCh * xml = DOMNodeImpl::getXmlString();
const XMLCh * xmlURI = DOMNodeImpl::getXmlURIString();
if (XMLString::equals(prefix, xml) &&
!XMLString::equals(fNamespaceURI, xmlURI))
throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);
if (XMLString::indexOf(prefix, chColon) != -1) {
throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);
}
this-> fPrefix = doc->getPooledString(prefix);
XMLSize_t prefixLen = XMLString::stringLen(prefix);
XMLSize_t newQualifiedNameLen = prefixLen+1+XMLString::stringLen(fLocalName);
XMLCh *newName;
XMLCh temp[256];
if (newQualifiedNameLen >= 255)
newName = (XMLCh*) doc->getMemoryManager()->allocate
(
newQualifiedNameLen * sizeof(XMLCh)
);//new XMLCh[newQualifiedNameLen];
else
newName = temp;
// newName = prefix + chColon + fLocalName;
XMLString::copyString(newName, prefix);
newName[prefixLen] = chColon;
XMLString::copyString(&newName[prefixLen+1], fLocalName);
fName = doc->getPooledString(newName);
if (newQualifiedNameLen >= 255)
doc->getMemoryManager()->deallocate(newName);//delete[] newName;
}
示例2: setName
void DOMElementNSImpl::setName(const XMLCh *namespaceURI,
const XMLCh *qualifiedName)
{
DOMDocumentImpl* ownerDoc = (DOMDocumentImpl *) fParent.fOwnerDocument;
this->fName = ownerDoc->getPooledString(qualifiedName);
int index = DOMDocumentImpl::indexofQualifiedName(qualifiedName);
if (index < 0)
throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);
if (index == 0)
{
//qualifiedName contains no ':'
//
fPrefix = 0;
fLocalName = fName;
}
else
{ //0 < index < this->name.length()-1
//
fPrefix = ownerDoc->getPooledNString(qualifiedName, index);
fLocalName = ownerDoc->getPooledString(fName+index+1);
// Before we carry on, we should check if the prefix or localName are valid XMLName
if (!ownerDoc->isXMLName(fPrefix) || !ownerDoc->isXMLName(fLocalName))
throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);
}
// DOM Level 3: namespace URI is never empty string.
//
const XMLCh * URI = DOMNodeImpl::mapPrefix (
fPrefix,
(!namespaceURI || !*namespaceURI) ? 0 : namespaceURI,
DOMNode::ELEMENT_NODE);
fNamespaceURI = (URI == 0) ? 0 : ownerDoc->getPooledString(URI);
}