本文整理汇总了C++中PendingUpdate::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ PendingUpdate::getValue方法的具体用法?C++ PendingUpdate::getValue怎么用?C++ PendingUpdate::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PendingUpdate
的用法示例。
在下文中一共展示了PendingUpdate::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: numElements
// This method has 2 functions:
// 1. count number of elements in the child list
// 2. ensure that text children are either comments or PI
// or if text that it is all whitespace.
// CDATA cannot be inserted (XQilla will not allow it).
static int numElements(const PendingUpdate &update,
DynamicContext *context)
{
int num = 0;
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const DbXmlNodeImpl *child = (const DbXmlNodeImpl*)item->
getInterface(DbXmlNodeImpl::gDbXml);
if (child) {
switch (child->getNodeType()) {
case nsNodeElement:
++num;
break;
case nsNodeComment:
case nsNodePinst:
break; // OK
case nsNodeText: {
XMLChToUTF8 s(child->getValue());
if (!NsUtil::isWhitespace(s.str())) {
throw XmlException(
XmlException::QUERY_EVALUATION_ERROR,
"Cannot insert non-whitespace text node as a child of the document node");
}
break;
}
default: DBXML_ASSERT(false); break;
}
}
}
return num;
}
示例2: applyPut
void DbXmlUpdateFactory::applyPut(const PendingUpdate &update, DynamicContext *context)
{
DbXmlUri uri(update.getValue().first()->
asString(context), true);
if (uri.isDbXmlScheme()) {
const DbXmlNodeImpl *content =
(const DbXmlNodeImpl*)update.getTarget().get();
string cname = uri.getContainerName();
string docname = uri.getDocumentName();
DbXmlConfiguration *conf = GET_CONFIGURATION(context);
XmlManager &mgr = conf->getManager();
XmlContainer cont = ((Manager&)mgr).getOpenContainer(cname);
if (cont.isNull()) {
string msg = "Target container for fn:put -- ";
msg += cname;
msg += " -- must be open";
throw XmlException(XmlException::INVALID_VALUE,
msg);
}
OperationContext &oc = conf->getOperationContext();
XmlDocument doc = mgr.createDocument();
doc.setName(docname);
XmlEventReader *reader =
(XmlEventReader*)content->getEventReader(context);
DBXML_ASSERT(reader);
doc.setContentAsEventReader(*reader);
XmlUpdateContext uc = mgr.createUpdateContext();
// use internal interface to avoid additional transaction
int err = ((Container &)cont).addDocumentInternal(oc.txn(), doc, uc, 0);
if (err != 0)
throw XmlException(err);
}
}
示例3: applyReplaceElementContent
void XercesUpdateFactory::applyReplaceElementContent(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMElement *domnode = (DOMElement*)nodeImpl->getDOMNode();
// 1. For each node $C that is a child of $target, the parent property of $C is set to empty.
DOMNode *child = domnode->getFirstChild();
while(child != 0) {
forDeletion_.insert(child);
child = child->getNextSibling();
}
const XMLCh *value = update.getValue().first()->asString(context);
if(value != 0 && *value != 0) {
// 2. The parent property of $text is set to $target.
// 3a. children is set to consist exclusively of $text. If $text is an empty sequence, then $target has
// no children.
// 3b. typed-value and string-value are set to the content property of $text. If $text is an empty sequence,
// then typed-value is an empty sequence and string-value is an empty string.
domnode->appendChild(domnode->getOwnerDocument()->createTextNode(value));
}
// 3c. upd:removeType($target) is invoked.
removeType(domnode);
addToPutSet(update.getTarget(), &update, context);
}
示例4: applyReplaceElementContent
void DbXmlUpdateFactory::applyReplaceElementContent(const PendingUpdate &update, DynamicContext *context)
{
const DbXmlNodeImpl *target = (const DbXmlNodeImpl*)update.getTarget().get();
// TBD: this check is commented out... need to re-check why.
// if (!target->isUpdateAble())
// return;
// use child axis to create nodes to mark for delete
DbXmlChildAxis children(0, target, 0);
Item::Ptr item;
while((item = children.next(context)).notNull()) {
const DbXmlNodeImpl *child = (const DbXmlNodeImpl*)item->
getInterface(DbXmlNodeImpl::gDbXml);
forDeletion_.insert(child);
}
// insert new content
const XMLCh *value = update.getValue().first()->asString(context);
if(value != 0 && *value != 0) {
// create text node
DbXmlConfiguration *conf = GET_CONFIGURATION(context);
OperationContext &oc = conf->getOperationContext();
Document *document = const_cast<Document*>(target->getDocument());
Node::Ptr content = ((DbXmlFactoryImpl*)context->getItemFactory())->
createTextNode(nsNodeText, value, context);
update_.insertText(*(const DbXmlNodeImpl*)content->
getInterface(DbXmlNodeImpl::gDbXml),
*target, 0,
*document, oc, context);
}
}
示例5: applyRename
void XercesUpdateFactory::applyRename(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode());
ATQNameOrDerived *qname = (ATQNameOrDerived*)update.getValue().first().get();
if(domnode->getNodeType() == DOMNode::PROCESSING_INSTRUCTION_NODE) {
DOMProcessingInstruction *newPI = domnode->getOwnerDocument()->
createProcessingInstruction(qname->getName(), domnode->getNodeValue());
domnode->getParentNode()->replaceChild(newPI, domnode);
domnode = newPI;
}
else {
// If $newName has an implied namespace binding that conflicts with an existing namespace binding
// in the namespaces property of $target, a dynamic error is raised [err:XUDY0024].
// If $target has a parent, and $newName has an implied namespace binding that conflicts with a
// namespace binding in the namespaces property of parent($target), a dynamic error is raised [err:XUDY0024].
domnode->getOwnerDocument()->renameNode(domnode, qname->getURI(), qname->getName());
if(qname->getURI() != 0 && *qname->getURI() != 0)
domnode->setPrefix(qname->getPrefix());
removeType(domnode);
}
// Deliberately create a new XercesNodeImpl, since the PI is actually
// replaced, not just renamed, meaning it is no longer attached to the tree
addToPutSet(nodeImpl, &update, context);
}
示例6: applyReplaceValue
void DbXmlUpdateFactory::applyReplaceValue(const PendingUpdate &update, DynamicContext *context)
{
const DbXmlNodeImpl *target = (const DbXmlNodeImpl*)update.getTarget().get();
if (!target->isUpdateAble())
return;
// This is slow, but effective...
// Create a new node with the replaced value and
// treat this like replaceNode
// This is ok because text and attribute nodes have no identity
DbXmlFactoryImpl *factory = (DbXmlFactoryImpl*)context->getItemFactory();
Node::Ptr newNode;
const XMLCh *value = update.getValue().first()->asString(context);
switch (target->getNodeType()) {
case nsNodeAttr: {
newNode = factory->
createAttrNode(target->getPrefix(),
target->getUri(),
target->getLocalName(),
value,
0, 0, // type name and URI
0, 0, NsNid(), 0, // cont, doc, nid, index
context);
break;
}
case nsNodeText:
case nsNodeComment:
case nsNodeCDATA: {
newNode = factory->
createTextNode(target->getNodeType(), value, context);
break;
}
case nsNodePinst: {
newNode = factory->
createPINode(target->getPITarget(), value, context);
break;
}
default:
DBXML_ASSERT(false);
break;
}
// now, replace...
Sequence seq(newNode);
PendingUpdate pu(PendingUpdate::REPLACE_NODE,
update.getTarget(),
seq,
&update);
if (target->getNodeType() == nsNodeAttr)
applyReplaceAttribute(pu, context);
else
applyReplaceNode(pu, context);
}
示例7: applyRename
void DbXmlUpdateFactory::applyRename(const PendingUpdate &update, DynamicContext *context)
{
const DbXmlNodeImpl *node = (const DbXmlNodeImpl*)update.getTarget().get();
if (!node->isUpdateAble())
return;
ATQNameOrDerived *qname = (ATQNameOrDerived*)update.getValue().first().get();
// Retrieve fresh node from database using RMW
switch(node->getType()) {
case NodeInfo::ELEMENT: {
DbXmlConfiguration *conf = GET_CONFIGURATION(context);
OperationContext &oc = conf->getOperationContext();
Document *document = const_cast<Document*>(node->getDocument());
DBXML_ASSERT(document);
update_.renameElement(*node, qname, *document, oc, context);
// Remove index entries under old name
// Put prefix and URI in the dictionary
// Update the prefix, URI, and name
// Update NS_NAMEPREFIX, NS_HASURI flags
// Add index entries for new name
break;
}
case NodeInfo::ATTRIBUTE: {
renameAttribute(update, qname, context);
// Remove index entries under old name
// Put prefix and URI in the dictionary
// Update the prefix, URI, and name
// Update NS_ATTR_PREFIX, NS_ATTR_URI flags
// Add index entries for new name
break;
}
case NodeInfo::PI: {
// no indexes on PI
renamePI(update, qname->getName(), context);
break;
}
default: DBXML_ASSERT(false); break;
}
}
示例8: applyReplaceAttribute
void XercesUpdateFactory::applyReplaceAttribute(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMAttr *domnode = (DOMAttr*)nodeImpl->getDOMNode();
Node::Ptr parentNode = nodeImpl->dmParent(context);
DOMElement *element = domnode->getOwnerElement();
DOMDocument *doc = element->getOwnerDocument();
bool untyped = parentNode->dmNodeKind() == Node::element_string &&
XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) &&
XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);
// 1. Error checks:
// a. If the QNames of any two attribute nodes in $replacement have implied namespace bindings that conflict with
// each other, a dynamic error is raised [err:XUDY0024].
// b. If the QName of any attribute node in $replacement has an implied namespace binding that conflicts with a
// namespace binding in the "namespaces" property of parent($target), a dynamic error is raised [err:XUDY0024].
// Checks performed by UpdateFactory
// 2b. If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked
// on each element node in $replacement.
if(!untyped) setTypes(newChild, childImpl->getDOMNode());
// 2a. For each node in $replacement, the parent property is set to parent($target).
// 4a. If $target is an attribute node, the attributes property of parent($target) is modified by removing $target
// and adding the nodes in $replacement (if any).
// 4b. If $target is an attribute node, the namespaces property of parent($target) is modified to include namespace
// bindings for any attribute namespace prefixes in $replacement that did not already have bindings.
element->setAttributeNode((DOMAttr*)newChild);
}
// 3a. $target is marked for deletion.
forDeletion_.insert(domnode);
// 4d. upd:removeType(parent($target)) is invoked.
removeType(element);
// Use parentNode, since the attr replace could have removed the original attr
addToPutSet(parentNode, &update, context);
}
示例9: insertAttributes
// do the work of attribute insertion -- shared by applyInsertAttributes
// and applyReplaceAttributes
void DbXmlUpdateFactory::insertAttributes(const PendingUpdate &update,
const DbXmlNodeImpl *parent,
DynamicContext *context)
{
DbXmlConfiguration *conf = GET_CONFIGURATION(context);
OperationContext &oc = conf->getOperationContext();
Document *document = const_cast<Document*>(parent->getDocument());
vector<const DbXmlNodeImpl *> nodeVec;
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const DbXmlNodeImpl *attr = (const DbXmlNodeImpl*)item->
getInterface(DbXmlNodeImpl::gDbXml);
nodeVec.push_back(attr);
}
update_.insertAttributes(nodeVec, *parent, *document, oc, context);
}
示例10: applyPut
void XercesUpdateFactory::applyPut(const PendingUpdate &update, DynamicContext *context)
{
PutItem item(update.getValue().first()->asString(context), update.getTarget(), &update, context);
std::pair<PutSet::iterator, bool> res = putSet_.insert(item);
if(!res.second) {
if(context->getMessageListener() != 0) {
context->getMessageListener()->warning(X("In the context of this expression"), res.first->location);
}
XMLBuffer buf;
buf.append(X("fn:put() called with the URI \""));
buf.append(item.uri);
buf.append(X("\" twice. [err:XUDY0031]"));
XQThrow3(ASTException, X("XercesUpdateFactory::applyPut"), buf.getRawBuffer(), &update);
}
}
示例11: applyInsertAfter
void XercesUpdateFactory::applyInsertAfter(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode());
DOMNode *before = domnode->getNextSibling();
Node::Ptr parentNode = nodeImpl->dmParent(context);
DOMNode *parent = domnode->getParentNode();
DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(domnode));
bool untyped = parentNode->dmNodeKind() == Node::element_string &&
XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) &&
XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
bool containsElementOrText = false;
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);
if(childImpl->dmNodeKind() == Node::element_string ||
childImpl->dmNodeKind() == Node::text_string) {
containsElementOrText = true;
}
// If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked on each
// element or attribute node in $content.
if(!untyped) setTypes(newChild, childImpl->getDOMNode());
// For each node in $content, the parent property is set to parent($target).
// The children property of parent($target) is modified to add the nodes in $content just before $target,
// preserving their order.
parent->insertBefore(newChild, before);
}
// If at least one of the nodes in $content is an element or text node, upd:removeType(parent($target)) is invoked.
if(containsElementOrText) {
removeType(parent);
}
addToPutSet(update.getTarget(), &update, context);
}
示例12: applyInserts
//
// "next" is NsDomNode * because the navigational methods used
// to calculate it in callers are available via NsDom and not via
// DbXmlNodeImpl, which uses axis iterators. They could be added
// if ever deemed necessary and/or cleaner
//
void DbXmlUpdateFactory::applyInserts(
const PendingUpdate &update,
const DbXmlNodeImpl *parent,
const NsDomNode *next,
DynamicContext *context,
bool firstOrAfter)
{
DbXmlConfiguration *conf = GET_CONFIGURATION(context);
XmlManager &mgr = conf->getManager();
OperationContext &oc = conf->getOperationContext();
Document *document = const_cast<Document*>(parent->getDocument());
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const DbXmlNodeImpl *child = (const DbXmlNodeImpl*)item->
getInterface(DbXmlNodeImpl::gDbXml);
switch(child->getNodeType()) {
case nsNodeElement:
{
update_.insertElement(*child, *parent,
next /* next */,
mgr, *document, oc,
context, firstOrAfter);
break;
}
case nsNodeText:
case nsNodeCDATA:
case nsNodePinst:
case nsNodeComment:
{
update_.insertText(*child, *parent, next,
*document, oc, context);
break;
}
default:
throw XmlException(XmlException::INVALID_VALUE,
"Cannot insert a node that is not element or text");
}
}
}
示例13: applyReplaceValue
void XercesUpdateFactory::applyReplaceValue(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode());
// 2. If $target is a text, comment, or processing instruction node: content of $target is set to $string-value.
domnode->setNodeValue(update.getValue().first()->asString(context));
if(domnode->getNodeType() == DOMNode::ATTRIBUTE_NODE) {
// 1. If $target is an attribute node:
// a. string-value of $target is set to $string-value. (done above)
// b. upd:removeType($target) is invoked.
removeType(domnode);
}
else if(domnode->getNodeType() == DOMNode::TEXT_NODE ||
domnode->getNodeType() == DOMNode::CDATA_SECTION_NODE) {
// 3. If $target is a text node, upd:removeType(parent($target)) is invoked.
if(domnode->getParentNode() != 0)
removeType(domnode->getParentNode());
}
addToPutSet(update.getTarget(), &update, context);
}
示例14: applyReplaceNode
void XercesUpdateFactory::applyReplaceNode(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode());
Node::Ptr parentNode = nodeImpl->dmParent(context);
DOMNode *parent = domnode->getParentNode();
DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(domnode));
bool untyped = parentNode->dmNodeKind() == Node::element_string &&
XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) &&
XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);
// 1b. If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked
// on each element node in $replacement.
if(!untyped) setTypes(newChild, childImpl->getDOMNode());
// 1a. For each node in $replacement, the parent property is set to parent($target).
// 3b. If $target is an element, text, comment, or processing instruction node, the children property
// of parent($target) is modified to add the nodes in $replacement just before $target, preserving
// their order.
parent->insertBefore(newChild, domnode);
}
// 2a. $target is marked for deletion.
forDeletion_.insert(domnode);
// 3c. upd:removeType(parent($target)) is invoked.
removeType(parent);
addToPutSet(update.getTarget(), &update, context);
}
示例15: applyInsertAttributes
void XercesUpdateFactory::applyInsertAttributes(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMElement *element = (DOMElement*)nodeImpl->getDOMNode();
DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(element));
bool untyped = nodeImpl->dmNodeKind() == Node::element_string &&
XPath2Utils::equals(nodeImpl->getTypeName(), DocumentCache::g_szUntyped) &&
XPath2Utils::equals(nodeImpl->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);
// 1. Error checks:
// a. If the QNames of any two attribute nodes in $content have implied namespace bindings that conflict with each other,
// a dynamic error is raised [err:XUDY0024].
// b. If the QName of any attribute node in $content has an implied namespace binding that conflicts with a namespace
// binding in the "namespaces" property of $target, a dynamic error is raised [err:XUDY0024].
// Checks performed by UpdateFactory
// If the type-name property of $target is xs:untyped, then upd:setToUntyped($A) is invoked.
if(!untyped) setTypes(newChild, childImpl->getDOMNode());
// The parent property of $A is set to $target.
// attributes: Modified to include the nodes in $content.
element->setAttributeNode((DOMAttr*)newChild);
}
// upd:removeType($target) is invoked.
removeType(element);
addToPutSet(update.getTarget(), &update, context);
}