本文整理汇总了C++中XMLBuffer::getRawBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLBuffer::getRawBuffer方法的具体用法?C++ XMLBuffer::getRawBuffer怎么用?C++ XMLBuffer::getRawBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLBuffer
的用法示例。
在下文中一共展示了XMLBuffer::getRawBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: textEvent
void XercesSequenceBuilder::textEvent(const XMLCh *chars, unsigned int length)
{
if(document_ == 0) {
document_ = new (context_->getMemoryManager()) XPathDocumentImpl(XQillaImplementation::getDOMImplementationImpl(), context_->getMemoryManager());
}
if(currentNode_->getNodeType() == DOMNode::TEXT_NODE) {
// Combine adjacent text nodes
XMLBuffer buf;
buf.append(chars, length);
((DOMText *)currentNode_)->appendData(buf.getRawBuffer());
}
else if(currentParent_ == 0 || length != 0) {
// Text nodes with a zero length value can only exist
// when they have no parent
XMLBuffer buf;
buf.append(chars, length);
DOMText *node = document_->createTextNode(buf.getRawBuffer());
if(currentParent_ != 0)
currentParent_->appendChild(node);
currentNode_ = node;
}
if(currentParent_ == 0) {
seq_.addItem(new XercesNodeImpl(currentNode_, (XercesURIResolver*)context_->getDefaultURIResolver()));
document_ = 0;
currentNode_ = 0;
}
}
示例2: generateEvents
EventGenerator::Ptr XQNamespaceConstructor::generateEvents(EventHandler *events, DynamicContext *context,
bool preserveNS, bool preserveType) const
{
const XMLCh *nodeName = m_name->createResult(context)->next(context)->asString(context);
if(*nodeName && !XMLChar1_0::isValidNCName(nodeName, XMLString::stringLen(nodeName)))
XQThrow(ASTException,X("XQNamespaceConstructor::generateEvents"),
X("The name for the namespace node must be either a zero-length string or a valid xs:NCName [err:XTDE0920]"));
if(XPath2Utils::equals(nodeName, XMLUni::fgXMLNSString))
XQThrow(ASTException,X("XQNamespaceConstructor::generateEvents"),
X("The name for the namespace node must not be \"xmlns\" [err:XTDE0920]"));
XMLBuffer value;
getStringValue(m_children, value, context);
if(value.getLen() == 0)
XQThrow(ASTException,X("XQNamespaceConstructor::generateEvents"),
X("The value for the namespace node must not be empty [err:XTDE0930]"));
if(XPath2Utils::equals(nodeName, XMLUni::fgXMLString) &&
!XPath2Utils::equals(value.getRawBuffer(), XMLUni::fgXMLURIName))
XQThrow(ASTException,X("XQNamespaceConstructor::generateEvents"),
X("The name for the namespace node must not be \"xml\" when the value is not \"http://www.w3.org/XML/1998/namespace\" [err:XTDE0925]"));
if(XPath2Utils::equals(value.getRawBuffer(), XMLUni::fgXMLURIName) &&
!XPath2Utils::equals(nodeName, XMLUni::fgXMLString))
XQThrow(ASTException,X("XQNamespaceConstructor::generateEvents"),
X("The value for the namespace node must not be \"http://www.w3.org/XML/1998/namespace\" when the name is not \"xml\" [err:XTDE0925]"));
events->namespaceEvent(nodeName, value.getRawBuffer());
return 0;
}
示例3: generateEvents
EventGenerator::Ptr XQAttributeConstructor::generateEvents(EventHandler *events, DynamicContext *context,
bool preserveNS, bool preserveType) const
{
AnyAtomicType::Ptr itemName = m_name->createResult(context)->next(context);
const ATQNameOrDerived* pQName = (const ATQNameOrDerived*)itemName.get();
const XMLCh *prefix = pQName->getPrefix();
const XMLCh *uri = pQName->getURI();
const XMLCh *name = pQName->getName();
if((uri==NULL && XPath2Utils::equals(name, XMLUni::fgXMLNSString)) ||
XPath2Utils::equals(uri, XMLUni::fgXMLNSURIName))
XQThrow(ASTException,X("DOM Constructor"),X("A computed attribute constructor cannot create a namespace declaration [err:XQDY0044]"));
XMLBuffer value;
getStringValue(m_children, value, context);
const XMLCh *typeURI = SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
const XMLCh *typeName = ATUntypedAtomic::fgDT_UNTYPEDATOMIC;
// check if it's xml:id
static const XMLCh id[] = { 'i', 'd', 0 };
if(XPath2Utils::equals(name, id) && XPath2Utils::equals(uri, XMLUni::fgXMLURIName)) {
// If the attribute name is xml:id, the string value and typed value of the attribute are further normalized by
// discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters
// by a single space (#x20) character.
XMLString::collapseWS(value.getRawBuffer(), context->getMemoryManager());
typeURI = SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
typeName = XMLUni::fgIDString;
}
events->attributeEvent(emptyToNull(prefix), emptyToNull(uri), name, value.getRawBuffer(), typeURI, typeName);
return 0;
}
示例4: createUpdateList
PendingUpdateList UReplaceValueOf::createUpdateList(DynamicContext *context) const
{
Node::Ptr node = (Node*)target_->createResult(context)->next(context).get();
if(node->dmNodeKind() == Node::document_string)
XQThrow(XPath2TypeMatchException,X("UReplaceValueOf::createUpdateList"),
X("The target expression of a replace expression does not return a single "
"node that is not a document node [err:XUTY0008]"));
XMLBuffer buf;
XQDOMConstructor::getStringValue(expr_, buf, context);
// If $target is a comment node, and $string contains two adjacent hyphens or ends with a hyphen, a dynamic error is raised [err:XQDY0072].
if(node->dmNodeKind() == Node::comment_string) {
bool foundOne = false;
for(const XMLCh *str = buf.getRawBuffer(); *str; ++str) {
if(*str == '-') {
if(foundOne) {
XQThrow(DynamicErrorException,X("UReplaceValueOf::createUpdateList"),
X("The replace value of expression would result in a comment node whose content contains two adjacent hyphens [err:XQDY0072]"));
}
else foundOne = true;
}
else {
foundOne = false;
}
}
if(foundOne) {
XQThrow(DynamicErrorException,X("UReplaceValueOf::createUpdateList"),
X("The replace value of expression would result in a comment node whose content ends with a hyphen [err:XQDY0072]"));
}
}
// If $target is a processing instruction node, and $string contains the substring "?>", a dynamic error is raised [err:XQDY0026].
else if(node->dmNodeKind() == Node::processing_instruction_string) {
bool foundQuestion = false;
for(const XMLCh *str = buf.getRawBuffer(); *str; ++str) {
if(*str == '?') {
foundQuestion = true;
}
else {
if(foundQuestion && *str == '>') {
XQThrow(DynamicErrorException,X("UReplaceValueOf::createUpdateList"),
X("The replace value of expression would result in a processing instruction node whose content includes the string \"?>\" [err:XQDY0026]"));
}
foundQuestion = false;
}
}
}
Item::Ptr value = context->getItemFactory()->createString(buf.getRawBuffer(), context);
if(node->dmNodeKind() == Node::element_string) {
return PendingUpdate(PendingUpdate::REPLACE_ELEMENT_CONTENT, node, value, this);
}
else {
return PendingUpdate(PendingUpdate::REPLACE_VALUE, node, value, this);
}
}
示例5: createUpdateList
PendingUpdateList URename::createUpdateList(DynamicContext *context) const
{
Node::Ptr node = (Node*)target_->createResult(context)->next(context).get();
if(node->dmNodeKind() != Node::element_string &&
node->dmNodeKind() != Node::attribute_string &&
node->dmNodeKind() != Node::processing_instruction_string)
XQThrow(XPath2TypeMatchException,X("URename::createUpdateList"),
X("It is a type error for the target expression of a rename expression not to be a single element, "
"attribute or processing instruction [err:XUTY0012]"));
ATQNameOrDerived::Ptr qname = (ATQNameOrDerived*)name_->createResult(context)->next(context).get();
// 3. The following checks are performed for error conditions:
// a. If $target is an element node, the "namespaces" property of $target must not include any namespace binding that conflicts
// with the implied namespace binding of $QName [err:XUDY0023].
if(node->dmNodeKind() == Node::element_string) {
ATAnyURIOrDerived::Ptr uri = FunctionNamespaceURIForPrefix::uriForPrefix(qname->getPrefix(), node, context, this);
if(uri.notNull() && !XPath2Utils::equals(uri->asString(context), qname->getURI())) {
XMLBuffer buf;
buf.append(X("Implied namespace binding for the rename expression (\""));
buf.append(qname->getPrefix());
buf.append(X("\" -> \""));
buf.append(qname->getURI());
buf.append(X("\") conflicts with those already existing on the target element [err:XUDY0023]"));
XQThrow3(DynamicErrorException, X("URename::createUpdateList"), buf.getRawBuffer(), this);
}
}
// b. If $target is an attribute node that has a parent, the "namespaces" property of parent($target) must not include any
// namespace binding that conflicts with the implied namespace binding of $QName [err:XUDY0023].
else if(node->dmNodeKind() == Node::attribute_string) {
Node::Ptr parentNode = node->dmParent(context);
if(parentNode.notNull() && qname->getURI() != 0 && *(qname->getURI()) != 0) {
ATAnyURIOrDerived::Ptr uri = FunctionNamespaceURIForPrefix::uriForPrefix(qname->getPrefix(), parentNode, context, this);
if(uri.notNull() && !XPath2Utils::equals(uri->asString(context), qname->getURI())) {
XMLBuffer buf;
buf.append(X("Implied namespace binding for the rename expression (\""));
buf.append(qname->getPrefix());
buf.append(X("\" -> \""));
buf.append(qname->getURI());
buf.append(X("\") conflicts with those already existing on the parent element of the target attribute [err:XUDY0023]"));
XQThrow3(DynamicErrorException, X("URename::createUpdateList"), buf.getRawBuffer(), this);
}
}
}
// c. If $target is processing instruction node, $QName must not include a non-empty namespace prefix. [err:XUDY0025].
else if(node->dmNodeKind() == Node::processing_instruction_string && !XPath2Utils::equals(qname->getPrefix(), XMLUni::fgZeroLenString))
XQThrow(XPath2TypeMatchException,X("URename::createUpdateList"),
X("The target of a rename expression is a processing instruction node, and the new name "
"expression returned a QName with a non-empty namespace prefix [err:XUDY0025]"));
return PendingUpdate(PendingUpdate::RENAME, node, qname, this);
}
示例6: resolveDocument
bool XercesURIResolver::resolveDocument(Sequence &result, const XMLCh* uri, DynamicContext* context, const QueryPathNode *projection)
{
Node::Ptr doc;
// Resolve the uri against the base uri
const XMLCh *systemId = uri;
XMLURL urlTmp(context->getMemoryManager());
if(urlTmp.setURL(context->getBaseURI(), uri, urlTmp)) {
systemId = context->getMemoryManager()->getPooledString(urlTmp.getURLText());
} else {
systemId = context->getMemoryManager()->getPooledString(uri);
}
// Check in the cache
DOMDocument *found = _documentMap.get((void*)systemId);
// Check to see if we can locate and parse the document
if(found == 0) {
try {
doc = const_cast<DocumentCache*>(context->getDocumentCache())->loadDocument(uri, context, projection);
found = (DOMDocument*)((DOMNode*)doc->getInterface(XercesConfiguration::gXerces));
_documentMap.put((void*)systemId, found);
_uriMap.put((void*)found, const_cast<XMLCh*>(systemId));
}
catch(const XMLParseException& e) {
XMLBuffer errMsg;
errMsg.set(X("Error parsing resource: "));
errMsg.append(uri);
errMsg.append(X(". Error message: "));
errMsg.append(e.getError());
errMsg.append(X(" [err:FODC0002]"));
XQThrow2(XMLParseException,X("XercesContextImpl::resolveDocument"), errMsg.getRawBuffer());
}
}
else {
doc = new XercesNodeImpl(found, (XercesURIResolver*)context->getDefaultURIResolver());
}
if(doc.notNull()) {
result.addItem(doc);
return true;
}
XMLBuffer errMsg;
errMsg.set(X("Error retrieving resource: "));
errMsg.append(uri);
errMsg.append(X(" [err:FODC0002]"));
XQThrow2(XMLParseException,X("XercesContextImpl::resolveDocument"), errMsg.getRawBuffer());
return false;
}
示例7: generateEvents
EventGenerator::Ptr XQCommentConstructor::generateEvents(EventHandler *events, DynamicContext *context,
bool preserveNS, bool preserveType) const
{
XMLBuffer value;
getStringValue(m_value, value, context);
// Check for two dashes in a row, or a dash at the end
if(xslt_) {
XMLBuffer buf(value.getLen());
bool foundDash = false;
const XMLCh *ptr = value.getRawBuffer();
const XMLCh *end = ptr + value.getLen();
while(ptr != end) {
if(*ptr == chDash) {
if(foundDash) {
buf.append(' ');
}
foundDash = true;
}
else foundDash = false;
buf.append(*ptr);
++ptr;
}
if(foundDash) {
buf.append(' ');
}
value.set(buf.getRawBuffer());
}
else {
bool foundDash = false;
const XMLCh *ptr = value.getRawBuffer();
const XMLCh *end = ptr + value.getLen();
while(ptr != end) {
if(*ptr == chDash) {
if(foundDash) break;
foundDash = true;
}
else foundDash = false;
++ptr;
}
if(foundDash)
XQThrow(ASTException,X("DOM Constructor"),X("It is a dynamic error if the result of the content expression of "
"a computed comment constructor contains two adjacent hyphens or "
"ends with a hyphen. [err:XQDY0072]"));
}
events->commentEvent(value.getRawBuffer());
return 0;
}
示例8: insertFunction
void FunctionLookup::insertFunction(FuncFactory *func)
{
// Use similar algorithm to lookup in order to detect overlaps
// in argument numbers
RefHash2KeysTableOfEnumerator<FuncFactory> iterator(const_cast<RefHash2KeysTableOf< FuncFactory >* >(&_funcTable));
//
// Walk the matches for the primary key (name) looking for overlaps:
// ensure func->max < min OR func->min > max
//
iterator.setPrimaryKey(func->getURINameHash());
while(iterator.hasMoreElements())
{
FuncFactory *entry= &(iterator.nextElement());
if ((func->getMaxArgs() < entry->getMinArgs()) ||
(func->getMinArgs() > entry->getMaxArgs()))
continue;
// overlap -- throw exception
XMLBuffer buf;
buf.set(X("Multiple functions have the same expanded QName and number of arguments {"));
buf.append(func->getURI());
buf.append(X("}"));
buf.append(func->getName());
buf.append(X("#"));
if(func->getMinArgs() >= entry->getMinArgs() &&
func->getMinArgs() <= entry->getMaxArgs())
XPath2Utils::numToBuf((unsigned int)func->getMinArgs(), buf);
else
XPath2Utils::numToBuf((unsigned int)entry->getMinArgs(), buf);
buf.append(X(" [err:XQST0034]."));
XQThrow2(StaticErrorException,X("FunctionLookup::insertFunction"), buf.getRawBuffer());
}
// Ok to add function
size_t secondaryKey = SECONDARY_KEY(func);
_funcTable.put((void*)func->getURINameHash(), (int)secondaryKey, func);
}
示例9: addToPutSet
void XercesUpdateFactory::addToPutSet(const Node::Ptr &node, const LocationInfo *location, DynamicContext *context)
{
Node::Ptr root = node->root(context);
Sequence docURISeq = root->dmDocumentURI(context);
const XMLCh *docuri = 0;
if(!docURISeq.isEmpty()) {
docuri = docURISeq.first()->asString(context);
}
PutItem item(docuri, root, location, context);
std::pair<PutSet::iterator, bool> res = putSet_.insert(item);
if(!res.second && !res.first->node->equals(item.node)) {
if(context->getMessageListener() != 0) {
context->getMessageListener()->warning(X("In the context of this expression"), res.first->location);
}
XMLBuffer buf;
buf.append(X("Document writing conflict for URI \""));
buf.append(item.uri);
buf.append(X("\""));
XQThrow3(ASTException, X("XercesUpdateFactory::addToPutSet"), buf.getRawBuffer(), location);
}
}
示例10: createResult
Result XQSimpleContent::createResult(DynamicContext* context, int flags) const
{
// TBD separator - jpcs
XMLBuffer value;
XQDOMConstructor::getStringValue(getChildren(), value, context);
return (Item::Ptr)context->getItemFactory()->createString(value.getRawBuffer(), context);
}
示例11: XQThrow
TupleNode *ForTuple::staticResolution(StaticContext *context)
{
parent_ = parent_->staticResolution(context);
varURI_ = context->getUriBoundToPrefix(XPath2NSUtils::getPrefix(varQName_, context->getMemoryManager()), this);
varName_ = XPath2NSUtils::getLocalName(varQName_);
if(posQName_ && *posQName_) {
posURI_ = context->getUriBoundToPrefix(XPath2NSUtils::getPrefix(posQName_, context->getMemoryManager()), this);
posName_ = XPath2NSUtils::getLocalName(posQName_);
if(XPath2Utils::equals(posName_, varName_) && XPath2Utils::equals(posURI_, varURI_)) {
XMLBuffer errMsg;
errMsg.set(X("The positional variable with name {"));
errMsg.append(posURI_);
errMsg.append(X("}"));
errMsg.append(posName_);
errMsg.append(X(" conflicts with the iteration variable [err:XQST0089]"));
XQThrow(StaticErrorException,X("ForTuple::staticResolution"), errMsg.getRawBuffer());
}
}
expr_ = expr_->staticResolution(context);
return this;
}
示例12: lookUpFunction
ASTNode* FunctionLookup::lookUpFunction(const XMLCh* URI, const XMLCh* fname,
const VectorOfASTNodes &args, XPath2MemoryManager* memMgr) const
{
if (this != g_globalFunctionTable) {
ASTNode *ret = g_globalFunctionTable->lookUpFunction(
URI, fname, args, memMgr);
if (ret)
return ret;
}
RefHash2KeysTableOfEnumerator<FuncFactory> iterator(const_cast<RefHash2KeysTableOf< FuncFactory >* >(&_funcTable));
//
// Walk the matches for the primary key (name) looking for matches
// based on allowable parameters
//
XMLBuffer key;
key.set(fname);
key.append(':');
key.append(URI);
iterator.setPrimaryKey(key.getRawBuffer());
size_t nargs = args.size();
while(iterator.hasMoreElements()) {
FuncFactory *entry= &(iterator.nextElement());
if (entry->getMinArgs() <= nargs &&
entry->getMaxArgs() >= nargs)
return entry->createInstance(args, memMgr);
}
return NULL;
}
示例13: staticResolution
ASTNode* XQFunctionCall::staticResolution(StaticContext *context)
{
if(uri_ == 0) {
if(prefix_ == 0 || *prefix_ == 0) {
uri_ = context->getDefaultFuncNS();
}
else {
uri_ = context->getUriBoundToPrefix(prefix_, this);
}
}
ASTNode *result = context->lookUpFunction(uri_, name_, *args_, this);
if(result == 0) {
XMLBuffer buf;
buf.set(X("A function called {"));
buf.append(uri_);
buf.append(X("}"));
buf.append(name_);
buf.append(X(" with "));
XPath2Utils::numToBuf(args_ ? (unsigned int)args_->size() : 0, buf);
buf.append(X(" arguments is not defined [err:XPST0017]"));
XQThrow(StaticErrorException, X("XQFunctionCall::staticResolution"), buf.getRawBuffer());
}
// Our arguments don't belong to us anymore
for(VectorOfASTNodes::iterator i = args_->begin(); i != args_->end(); ++i) {
*i = 0;
}
// Release this object
this->release();
return result->staticResolution(context);
}
示例14: completeUpdate
void XercesUpdateFactory::completeUpdate(DynamicContext *context)
{
completeDeletions(context);
completeRevalidation(context);
// Call the URIResolvers to handle the PutSet
for(PutSet::iterator i = putSet_.begin(); i != putSet_.end(); ++i) {
try {
if(!context->putDocument(i->node, i->uri)) {
XMLBuffer buf;
buf.append(X("Writing of updated document failed for URI \""));
buf.append(i->uri);
buf.append(X("\""));
XQThrow3(ASTException, X("XercesUpdateFactory::completeUpdate"), buf.getRawBuffer(), i->location);
}
}
catch(XQException& e) {
if(e.getXQueryLine() == 0) {
e.setXQueryPosition(i->location);
}
throw e;
}
}
}
示例15: next
Item::Ptr AtomizeResult::next(DynamicContext *context)
{
// for $item in (Expr) return
// typeswitch ($item)
// case $value as atomic value return $value
// default $node return fn:data($node)
Item::Ptr result = _sub->next(context);
while(result.isNull()) {
_sub = 0;
result = _parent->next(context);
if(result.isNull()) {
_parent = 0;
return 0;
}
if(result->isNode()) {
_sub = ((Node*)result.get())->dmTypedValue(context);
result = _sub->next(context);
}
else if(result->isFunction()) {
XMLBuffer buf;
buf.set(X("Sequence does not match type (xs:anyAtomicType | node())*"));
buf.append(X(" - found item of type "));
result->typeToBuffer(context, buf);
buf.append(X(" [err:XPTY0004]"));
XQThrow(XPath2TypeMatchException, X("AtomizeResult::next"), buf.getRawBuffer());
}
}
return result;
}