本文整理汇总了C++中DOMElement::setPrefix方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMElement::setPrefix方法的具体用法?C++ DOMElement::setPrefix怎么用?C++ DOMElement::setPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::setPrefix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startElementEvent
void XercesSequenceBuilder::startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)
{
if(document_ == 0) {
document_ = new (context_->getMemoryManager()) XPathDocumentImpl(XQillaImplementation::getDOMImplementationImpl(), context_->getMemoryManager());
}
DOMElement *elem = document_->createElementNS(uri, localname);
if(prefix != 0)
elem->setPrefix(prefix);
if(currentParent_ != 0)
currentParent_->appendChild(elem);
currentParent_ = elem;
currentNode_ = elem;
}
示例2: createElementNS
DOMElement* EppUtil::createElementNS( DOMDocument& doc, const DOMString ns, const DOMString tag, bool flag , char *_version)
{
DOMElement* elm;
DOMString prefix(EPP_NAME_SPACE);
char *use_version = version;
if( NULL != _version ) /*param provided*/
use_version = _version;
if( tag.isNull() )
{
elm = doc.createElementNS(prefix + ns + use_version , ns);
elm->setAttribute(XS("xmlns"), XS(EPP_NAME_SPACE) + ns + use_version );
if( use_version[0] == 0 )
{
// old EPP-02 schema
elm->setAttribute(XS("xmlns:xsi"), XS("http://www.w3.org/2000/10/XMLSchema-instance"));
}
else
{
elm->setAttribute(XS("xmlns:xsi"), XS("http://www.w3.org/2001/XMLSchema-instance"));
}
}
else
{
elm = doc.createElementNS(prefix + ns + use_version, tag);
elm->setPrefix(ns);
if( flag )
{
elm->setAttribute(XS("xmlns"), prefix + ns + use_version);
}
elm->setAttribute(XS("xmlns:") + ns, prefix + ns + use_version);
}
elm->setAttribute(XS("xsi:schemaLocation"), prefix + ns + use_version + " " + ns + use_version + ".xsd");
return elm;
}
示例3: main
int main(int /*argc*/, char ** /*argv*/) {
Normalizer *normalizer = new Normalizer();
DOMDocument *doc = normalizer->createDocument();
bool *tmpTrue = new bool(true);
bool *tmpFalse = new bool(false);
DOMElement* docFirstElement = doc->createElementNS(X("http://www.test.com"),X("docEle"));
doc->appendChild(docFirstElement);
DOMElement* docFirstElementChild = doc->createElementNS(X("http://www.test2.com"),X("docEleChild"));
docFirstElement->appendChild(docFirstElementChild);
//create default ns
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//add in binding
docFirstElement->setPrefix(X("po"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//use default
DOMElement* docFirstElementChildChild = doc->createElementNS(X("http://www.test2.com"),X("docEleChildChild"));
docFirstElementChild->appendChild(docFirstElementChildChild);
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
// this block is needed to destroy the XMLBuffer
{
//use a binding
XMLBuffer buf;
buf.set(XMLUni::fgXMLNSString);
buf.append(chColon);
buf.append(X("po2"));
docFirstElementChild->removeAttributeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString);
docFirstElement->removeAttributeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString);
docFirstElement->setAttributeNS(XMLUni::fgXMLNSURIName, buf.getRawBuffer(), X("http://www.test2.com"));
docFirstElementChild->setPrefix(X("po2"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
}
//some siblngs to ensure the scope stacks are working
docFirstElementChildChild = doc->createElementNS(X("http://www.test3.com"),X("docEleChildChild2"));
docFirstElementChild->appendChild(docFirstElementChildChild);
docFirstElementChildChild = doc->createElementNS(X("http://www.test4.com"),X("po4:docEleChildChild3"));
docFirstElementChild->appendChild(docFirstElementChildChild);
docFirstElementChildChild = doc->createElementNS(X("http://www.test4.com"),X("po4:docEleChildChild4"));
docFirstElementChild->appendChild(docFirstElementChildChild);
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//conflicting prefix
docFirstElementChildChild->setAttributeNS(XMLUni::fgXMLNSURIName, X("po4"), X("conflict"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//conflicting default
docFirstElementChildChild = doc->createElementNS(X("http://www.test4.com"),X("docEleChildChild5"));
docFirstElementChild->appendChild(docFirstElementChildChild);
docFirstElementChildChild->setAttributeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString, X("conflict"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//set the xmlns to ""
DOMElement *noNamespaceEle = doc->createElementNS(X(""),X("noNamespace"));
docFirstElementChildChild->appendChild(noNamespaceEle);
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//now lets do a bit off attribute testing on the doc ele
docFirstElement->setAttributeNS(X("http://testattr.com"), X("attr1"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr.com"), X("attr2"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr2.com"), X("attr3"), X("value"));
docFirstElement->setAttributeNS(X("http://www.test.com"), X("attr4"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr2.com"), X("po:attr5"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr2.com"), X("poFake:attr6"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr3.com"), X("po3:attr7"), X("value"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//and now on one of its children
docFirstElementChildChild->setAttributeNS(X("http://testattr.com"), X("attr1"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr.com"), X("attr2"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr2.com"), X("attr3"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://www.test.com"), X("attr4"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr2.com"), X("po:attr5"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr2.com"), X("poFake:attr6"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr3.com"), X("po3:attr7"), X("value"));
//.........这里部分代码省略.........
示例4: createElementNSUnspec
DOMElement* EppUtil::createElementNSUnspec( DOMDocument& doc, const DOMString unspec, const DOMString tag, bool flag )
{
unsigned int len = unspec.length();
unsigned int index_ns;
unsigned int index_uri;
unsigned int index;
DOMString ns;
DOMString uri;
DOMString loc;
for( index = 0; index < len; index++ )
{
if( unspec.charAt(index) == ' ' )
{
ns = unspec.substringData(0, index);
index_ns = index;
break;
}
}
for( index = index_ns + 1; index < len; index++ )
{
if( unspec.charAt(index) == ' ' )
{
uri = unspec.substringData(index_ns + 1, index - index_ns - 1);
index_uri = index;
break;
}
}
if( index < len )
{
loc = unspec.substringData(index_uri + 1, len - index_uri - 1);
}
if( (ns.isNull()) || (uri.isNull()) || (loc.isNull()) )
{
return NULL;
//return DOMElement();
}
loc = uri + " " + loc;
DOMElement* elm;
if( tag.isNull() )
{
elm = doc.createElementNS(uri, ns);
elm->setAttribute(XS("xmlns"), uri);
if( version[0] == 0 )
{
// old EPP-02 schema
elm->setAttribute(XS("xmlns:xsi"), XS("http://www.w3.org/2000/10/XMLSchema-instance"));
}
else
{
elm->setAttribute(XS("xmlns:xsi"), XS("http://www.w3.org/2001/XMLSchema-instance"));
}
}
else
{
elm = doc.createElementNS(uri, tag);
elm->setPrefix(ns);
if( flag )
{
elm->setAttribute(XS("xmlns"), uri);
}
elm->setAttribute(XS("xmlns:") + ns, uri);
}
elm->setAttribute(XS("xsi:schemaLocation"), loc);
return elm;
}