本文整理汇总了C++中DOMElement::getAttributeNodeNS方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMElement::getAttributeNodeNS方法的具体用法?C++ DOMElement::getAttributeNodeNS怎么用?C++ DOMElement::getAttributeNodeNS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::getAttributeNodeNS方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setMGF
void XENCEncryptionMethodImpl::setMGF(const XMLCh * mgf) {
if (mp_mgfAlgorithmAttr == NULL) {
// Need to create
if (mp_oaepParamsTextNode == NULL && mp_digestAlgorithmAttr == NULL && mp_keySizeTextNode == NULL) {
mp_env->doPrettyPrint(mp_encryptionMethodElement);
}
// Get some setup values
safeBuffer str;
DOMDocument *doc = mp_env->getParentDocument();
const XMLCh * prefix = mp_env->getXENC11NSPrefix();
makeQName(str, prefix, s_MGF);
DOMElement *e = doc->createElementNS(DSIGConstants::s_unicodeStrURIXENC11, str.rawXMLChBuffer());
mp_encryptionMethodElement->appendChild(e);
mp_env->doPrettyPrint(mp_encryptionMethodElement);
e->setAttributeNS(NULL,
DSIGConstants::s_unicodeStrAlgorithm,
mgf);
// Set namespace
if (prefix[0] == XERCES_CPP_NAMESPACE_QUALIFIER chNull) {
str.sbTranscodeIn("xmlns");
}
else {
str.sbTranscodeIn("xmlns:");
str.sbXMLChCat(prefix);
}
e->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS,
str.rawXMLChBuffer(),
DSIGConstants::s_unicodeStrURIXENC11);
// Now retrieve for later use
mp_mgfAlgorithmAttr =
e->getAttributeNodeNS(NULL,
DSIGConstants::s_unicodeStrAlgorithm);
if (mp_mgfAlgorithmAttr == NULL) {
throw XSECException(XSECException::EncryptionMethodError,
"XENCEncryptionMethod::setMGF - Error creating Algorithm Attribute");
}
}
else {
mp_mgfAlgorithmAttr->setNodeValue(mgf);
}
}
示例2: isDefaultNamespace
bool DOMNodeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const{
DOMNode *thisNode = castToNode(this);
short type = thisNode->getNodeType();
switch (type) {
case DOMNode::ELEMENT_NODE: {
const XMLCh *prefix = thisNode->getPrefix();
// REVISIT: is it possible that prefix is empty string?
if (prefix == 0 || !*prefix) {
return XMLString::equals(namespaceURI, thisNode->getNamespaceURI());
}
if (thisNode->hasAttributes()) {
DOMElement *elem = (DOMElement *)thisNode;
DOMNode *attr = elem->getAttributeNodeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString);
if (attr != 0) {
const XMLCh *value = attr->getNodeValue();
return XMLString::equals(namespaceURI, value);
}
}
DOMNode *ancestor = getElementAncestor(thisNode);
if (ancestor != 0) {
return ancestor->isDefaultNamespace(namespaceURI);
}
return false;
}
case DOMNode::DOCUMENT_NODE:{
return ((DOMDocument*)thisNode)->getDocumentElement()->isDefaultNamespace(namespaceURI);
}
case DOMNode::ENTITY_NODE :
case DOMNode::NOTATION_NODE:
case DOMNode::DOCUMENT_FRAGMENT_NODE:
case DOMNode::DOCUMENT_TYPE_NODE:
// type is unknown
return false;
case DOMNode::ATTRIBUTE_NODE:{
if (fOwnerNode->getNodeType() == DOMNode::ELEMENT_NODE) {
return fOwnerNode->isDefaultNamespace(namespaceURI);
}
return false;
}
default:{
DOMNode *ancestor = getElementAncestor(thisNode);
if (ancestor != 0) {
return ancestor->isDefaultNamespace(namespaceURI);
}
return false;
}
}
}
示例3: setXPathNS
XERCES_CPP_NAMESPACE_USE
#if !defined(XSEC_NO_XPATH)
#include <iostream>
#define KLUDGE_PREFIX "berindsig"
// Helper function
void setXPathNS(DOMDocument *d,
DOMNamedNodeMap *xAtts,
XSECXPathNodeList &addedNodes,
XSECSafeBufferFormatter *formatter,
XSECNameSpaceExpander * nse) {
// if set then set the name spaces in the attribute list else clear them
DOMElement * e = d->getDocumentElement();
if (e == NULL) {
throw XSECException(XSECException::XPathError, "Element node not found in Document");
}
if (xAtts != 0) {
int xAttsCount = xAtts->getLength();
// Check all is OK with the Xalan Document and first element
if (d == NULL) {
throw XSECException(XSECException::XPathError, "Attempt to define XPath Name Space before setInput called");
}
// Run through each attribute looking for name spaces
const XMLCh *xpName;
safeBuffer xpNameSB;
const XMLCh *xpLocalName;
const XMLCh *xpValue;
for (int xCounter = 0; xCounter < xAttsCount; ++xCounter) {
if (nse == NULL || !nse->nodeWasAdded(xAtts->item(xCounter))) {
xpName = xAtts->item(xCounter)->getNodeName();
xpNameSB << (*formatter << xpName);
if (xpNameSB.sbStrncmp("xmlns", 5) == 0) {
// Check whether a node of this name already exists
xpLocalName = xAtts->item(xCounter)->getLocalName();
xpValue = xAtts->item(xCounter)->getNodeValue();
if (e->hasAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS, xpLocalName) == false) {
// Nope
e->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS, xpName, xpValue);
addedNodes.addNode(e->getAttributeNodeNS(DSIGConstants::s_unicodeStrURIXMLNS, xpLocalName));
}
}
}
}
}
// Insert the kludge namespace
safeBuffer k("xmlns:");
k.sbStrcatIn(KLUDGE_PREFIX);
e->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS,
MAKE_UNICODE_STRING(k.rawCharBuffer()),
DSIGConstants::s_unicodeStrURIDSIG);
}
示例4: load
void XENCEncryptionMethodImpl::load() {
if (mp_encryptionMethodElement == NULL) {
// Attempt to load an empty encryptedType element
throw XSECException(XSECException::EncryptionMethodError,
"XENCEncryptionMethod::load - called on empty DOM");
}
if (!strEquals(getXENCLocalName(mp_encryptionMethodElement), s_EncryptionMethod)) {
// Attempt to load an empty encryptedData element
throw XSECException(XSECException::EncryptionMethodError,
"XENCEncryptionMethod::load - called on non EncryptionMethod node");
}
// Find the type
mp_algorithmAttr =
mp_encryptionMethodElement->getAttributeNodeNS(NULL,
DSIGConstants::s_unicodeStrAlgorithm);
// Check for known children
DOMElement * c = findFirstElementChild(mp_encryptionMethodElement);
while (c != NULL) {
if (strEquals(getDSIGLocalName(c), s_DigestMethod)) {
mp_digestAlgorithmAttr = c->getAttributeNodeNS(NULL,
DSIGConstants::s_unicodeStrAlgorithm);
if (mp_digestAlgorithmAttr == NULL) {
throw XSECException(XSECException::EncryptionMethodError,
"XENCEncryptionMethod::load - Cannot find Algorithm Attribute in DigestMethod element");
}
}
else if (strEquals(getXENC11LocalName(c), s_MGF)) {
mp_mgfAlgorithmAttr = c->getAttributeNodeNS(NULL,
DSIGConstants::s_unicodeStrAlgorithm);
if (mp_mgfAlgorithmAttr == NULL) {
throw XSECException(XSECException::EncryptionMethodError,
"XENCEncryptionMethod::load - Cannot find Algorithm Attribute in xenc11:MGF element");
}
}
else if (strEquals(getXENCLocalName(c), s_OAEPparams)) {
mp_oaepParamsTextNode = NULL;
mp_oaepParamsTextNode = findFirstChildOfType(c, DOMNode::TEXT_NODE);
if (mp_oaepParamsTextNode == NULL) {
throw XSECException(XSECException::EncryptionMethodError,
"XENCEncryptionMethod::load - Cannot find text value of xenc:OAEPparams element");
}
}
else if (strEquals(getXENCLocalName(c), s_KeySize)) {
mp_keySizeTextNode = NULL;
mp_keySizeTextNode = findFirstChildOfType(c, DOMNode::TEXT_NODE);
if (mp_keySizeTextNode == NULL) {
throw XSECException(XSECException::EncryptionMethodError,
"XENCEncryptionMethod::load - Cannot find text value of xenc:KeySize node");
}
}
c = findNextElementChild(c);
}
}