本文整理汇总了C++中arabica::xpath::NodeSet类的典型用法代码示例。如果您正苦于以下问题:C++ NodeSet类的具体用法?C++ NodeSet怎么用?C++ NodeSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Arabica::XPath::NodeSet<std::string> InterpreterDraft6::filterPreempted(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
Arabica::XPath::NodeSet<std::string> filteredTransitions;
for (unsigned int i = 0; i < enabledTransitions.size(); i++) {
Node<std::string> t = enabledTransitions[i];
if (!isTargetless(t)) {
for (unsigned int j = 0; j < filteredTransitions.size(); j++) {
if (j == i)
continue;
Node<std::string> t2 = filteredTransitions[j];
if (isPreemptingTransition(t2, t)) {
#if 0
std::cout << "#####" << std::endl << "Transition " << std::endl
<< t2 << std::endl << " preempts " << std::endl << t << std::endl << "#####" << std::endl;
#endif
goto LOOP;
}
}
}
#if 0
std::cout << "----" << "Enabling Transition " << std::endl << t << std::endl;
#endif
filteredTransitions.push_back(t);
LOOP:
;
}
return filteredTransitions;
}
示例2: doEvaluate
virtual Arabica::XPath::NodeSet<std::string> doEvaluate(const DOM::Node<std::string>& /* context */,
const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
{
Arabica::XPath::NodeSet<std::string> set;
set.push_back(executionContext.currentNode());
return set;
} // doEvaluate
示例3: execute
virtual void execute(const DOM::Node<string_type, string_adaptor>& node,
ExecutionContext<string_type, string_adaptor>& context) const
{
ParamPasser<string_type, string_adaptor> passer(*this, node, context);
if(!SortableT::has_sort() && select_ == 0)
{
if(node.hasChildNodes())
context.stylesheet().applyTemplates(node.getChildNodes(), context, mode_);
return;
}
Arabica::XPath::NodeSet<string_type, string_adaptor> nodes;
if(select_ == 0)
for(DOM::Node<string_type, string_adaptor> n = node.getFirstChild(); n != 0; n = n.getNextSibling())
nodes.push_back(n);
else
{
Arabica::XPath::XPathValue<string_type, string_adaptor> value = select_->evaluate(node, context.xpathContext());
if(value.type() != Arabica::XPath::NODE_SET)
throw std::runtime_error("apply-templates select expression is not a node-set");
nodes = value.asNodeSet();
}
this->sort(node, nodes, context);
context.stylesheet().applyTemplates(nodes, context, mode_);
} // execute
示例4: getTargetStates
void InterpreterDraft6::microstep(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
#if VERBOSE
std::cout << "Transitions: ";
for (int i = 0; i < enabledTransitions.size(); i++) {
std::cout << ((Element<std::string>)getSourceState(enabledTransitions[i])).getAttribute("id") << " -> " << std::endl;
NodeSet<std::string> targetSet = getTargetStates(enabledTransitions[i]);
for (int j = 0; j < targetSet.size(); j++) {
std::cout << " " << ((Element<std::string>)targetSet[j]).getAttribute("id") << std::endl;
}
}
std::cout << std::endl;
#endif
// --- MONITOR: beforeMicroStep ------------------------------
for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
try {
(*monIter)->beforeMicroStep(shared_from_this());
}
USCXML_MONITOR_CATCH_BLOCK(beforeMicroStep)
}
exitStates(enabledTransitions);
monIter_t monIter;
for (int i = 0; i < enabledTransitions.size(); i++) {
Element<std::string> transition(enabledTransitions[i]);
// --- MONITOR: beforeTakingTransitions ------------------------------
for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
try {
(*monIter)->beforeTakingTransition(shared_from_this(), transition, (i + 1 < enabledTransitions.size()));
}
USCXML_MONITOR_CATCH_BLOCK(beforeTakingTransitions)
}
executeContent(transition);
// --- MONITOR: afterTakingTransitions ------------------------------
for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
try {
(*monIter)->afterTakingTransition(shared_from_this(), transition, (i + 1 < enabledTransitions.size()));
}
USCXML_MONITOR_CATCH_BLOCK(afterTakingTransitions)
}
}
enterStates(enabledTransitions);
// --- MONITOR: afterMicroStep ------------------------------
for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
try {
(*monIter)->afterMicroStep(shared_from_this());
}
USCXML_MONITOR_CATCH_BLOCK(afterMicroStep)
}
}
示例5: beforeCompletion
void beforeCompletion(uscxml::Interpreter interpreter) {
Arabica::XPath::NodeSet<std::string> config = interpreter.getConfiguration();
if (config.size() == 1 && boost::iequals(ATTR(config[0], "id"), "pass")) {
std::cout << "TEST SUCCEEDED" << std::endl;
exit(EXIT_SUCCESS);
}
std::cout << "TEST FAILED" << std::endl;
exit(EXIT_FAILURE);
}
示例6: ATTR
// setup / fetch the documents initial transitions
NodeSet<std::string> InterpreterDraft6::getDocumentInitialTransitions() {
NodeSet<std::string> initialTransitions;
if (_userDefinedStartConfiguration.size() > 0) {
// we emulate entering a given configuration by creating a pseudo deep history
Element<std::string> initHistory = _document.createElementNS(_nsInfo.nsURL, "history");
_nsInfo.setPrefix(initHistory);
initHistory.setAttribute("id", UUID::getUUID());
initHistory.setAttribute("type", "deep");
_scxml.insertBefore(initHistory, _scxml.getFirstChild());
std::string histId = ATTR(initHistory, "id");
NodeSet<std::string> histStates;
for (int i = 0; i < _userDefinedStartConfiguration.size(); i++) {
histStates.push_back(getState(_userDefinedStartConfiguration[i]));
}
_historyValue[histId] = histStates;
Element<std::string> initialElem = _document.createElementNS(_nsInfo.nsURL, "initial");
_nsInfo.setPrefix(initialElem);
initialElem.setAttribute("generated", "true");
Element<std::string> transitionElem = _document.createElementNS(_nsInfo.nsURL, "transition");
_nsInfo.setPrefix(transitionElem);
transitionElem.setAttribute("target", histId);
initialElem.appendChild(transitionElem);
_scxml.appendChild(initialElem);
initialTransitions.push_back(transitionElem);
} else {
// try to get initial transition from initial element
initialTransitions = _xpath.evaluate("/" + _nsInfo.xpathPrefix + "initial/" + _nsInfo.xpathPrefix + "transition", _scxml).asNodeSet();
if (initialTransitions.size() == 0) {
Arabica::XPath::NodeSet<std::string> initialStates;
// fetch per draft
initialStates = getInitialStates();
assert(initialStates.size() > 0);
for (int i = 0; i < initialStates.size(); i++) {
Element<std::string> initialElem = _document.createElementNS(_nsInfo.nsURL, "initial");
_nsInfo.setPrefix(initialElem);
initialElem.setAttribute("generated", "true");
Element<std::string> transitionElem = _document.createElementNS(_nsInfo.nsURL, "transition");
_nsInfo.setPrefix(transitionElem);
transitionElem.setAttribute("target", ATTR(initialStates[i], "id"));
initialElem.appendChild(transitionElem);
_scxml.appendChild(initialElem);
initialTransitions.push_back(transitionElem);
}
}
}
return initialTransitions;
}
示例7: sort
void sort(const DOM::Node<std::string>& node, Arabica::XPath::NodeSet<std::string>& nodes, ExecutionContext& context) const
{
if(!sort_)
{
if(!nodes.forward())
nodes.to_document_order();
return;
}
sort_->set_context(node, context);
std::stable_sort(nodes.begin(), nodes.end(), SortP(*sort_));
} // sort
示例8: execute
virtual void execute(const DOM::Node<std::string>& node, ExecutionContext& context) const
{
Arabica::XPath::XPathValue<std::string> value = select_->evaluate(node, context.xpathContext());
if(value.type() != Arabica::XPath::NODE_SET)
{
context.sink().characters(value.asString());
return;
}
Arabica::XPath::NodeSet<std::string> nodes = value.asNodeSet();
for(Arabica::XPath::NodeSet<std::string>::const_iterator n = nodes.begin(), e = nodes.end(); n != e; ++n)
copy(*n, context);
} // execute
示例9: nodeSetUnion
Arabica::XPath::NodeSet<std::string> nodeSetUnion(const std::string& keyClarkName,
const Arabica::XPath::NodeSet<std::string> nodes,
const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
{
Arabica::XPath::NodeSet<std::string> results;
for(Arabica::XPath::NodeSet<std::string>::const_iterator n = nodes.begin(), ne = nodes.end(); n != ne; ++n)
{
std::string id = Arabica::XPath::impl::nodeStringValue<std::string, Arabica::default_string_adaptor<std::string> >(*n);
results.push_back(keys_.lookup(keyClarkName, id, executionContext));
} // for ...
results.to_document_order();
return results;
} // nodeSetUnion
示例10: filterChildElements
Arabica::XPath::NodeSet<std::string> InterpreterDraft6::selectTransitions(const std::string& event) {
Arabica::XPath::NodeSet<std::string> enabledTransitions;
NodeSet<std::string> states;
for (unsigned int i = 0; i < _configuration.size(); i++) {
if (isAtomic(_configuration[i]))
states.push_back(_configuration[i]);
}
states.to_document_order();
#if 0
std::cout << "Atomic states: " << std::endl;
for (int i = 0; i < states.size(); i++) {
std::cout << states[i] << std::endl << "----" << std::endl;
}
std::cout << std::endl;
#endif
unsigned int index = 0;
while(states.size() > index) {
bool foundTransition = false;
NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", states[index]);
for (unsigned int k = 0; k < transitions.size(); k++) {
if (isEnabledTransition(transitions[k], event)) {
enabledTransitions.push_back(transitions[k]);
foundTransition = true;
goto LOOP;
}
}
if (!foundTransition) {
Node<std::string> parent = states[index].getParentNode();
if (parent) {
states.push_back(parent);
}
}
LOOP:
index++;
}
enabledTransitions = filterPreempted(enabledTransitions);
#if 0
std::cout << "Enabled transitions: " << std::endl;
for (int i = 0; i < enabledTransitions.size(); i++) {
std::cout << DOMUtils::xPathForNode(enabledTransitions[i]) << std::endl;
}
std::cout << std::endl;
#endif
return enabledTransitions;
}
示例11: is
NistXmlTestset::NistXmlTestset(const std::string &file)
: logger_(logkw::channel = "NistXmlTestset") {
Arabica::SAX2DOM::Parser<std::string> domParser;
Arabica::SAX::InputSource<std::string> is(file);
Arabica::SAX::CatchErrorHandler<std::string> errh;
domParser.setErrorHandler(errh);
domParser.parse(is);
if(errh.errorsReported())
BOOST_LOG_SEV(logger_, error) << errh.errors();
Arabica::DOM::Document<std::string> doc = domParser.getDocument();
if(doc == 0) {
BOOST_LOG_SEV(logger_, error) << "Error parsing input file: " << file;
exit(1);
}
doc.getDocumentElement().normalize();
Arabica::XPath::XPath<std::string> xp;
Arabica::XPath::NodeSet<std::string> docnodes =
xp.compile("/mteval/srcset/doc").evaluateAsNodeSet(doc.getDocumentElement());
docnodes.to_document_order();
BOOST_FOREACH(Arabica::DOM::Node<std::string> n, docnodes)
documents_.push_back(boost::make_shared<NistXmlDocument>(n));
outdoc_ = static_cast<Arabica::DOM::Document<std::string> >(doc.cloneNode(true));
Arabica::DOM::Element<std::string> srcset =
static_cast<Arabica::DOM::Element<std::string> >(
xp.compile("/mteval/srcset").evaluateAsNodeSet(outdoc_.getDocumentElement())[0]);
Arabica::DOM::Element<std::string> tstset = outdoc_.createElement("tstset");
int docno = 0;
while(srcset.hasChildNodes()) {
Arabica::DOM::Node<std::string> n = srcset.removeChild(srcset.getFirstChild());
tstset.appendChild(n);
if(n.getNodeType() == Arabica::DOM::Node<std::string>::ELEMENT_NODE &&
n.getNodeName() == "doc")
documents_[docno++]->setOutputNode(n);
}
tstset.setAttribute("setid", srcset.getAttribute("setid"));
tstset.setAttribute("srclang", srcset.getAttribute("srclang"));
tstset.setAttribute("trglang", "TRGLANG");
tstset.setAttribute("sysid", "SYSID");
srcset.getParentNode().replaceChild(tstset, srcset);
}
示例12: getProperAncestors
Node<std::string> InterpreterDraft6::findLCPA(const Arabica::XPath::NodeSet<std::string>& states) {
Arabica::XPath::NodeSet<std::string> ancestors = getProperAncestors(states[0], Node<std::string>());
Node<std::string> ancestor;
for (int i = 0; i < ancestors.size(); i++) {
if (!isParallel(ancestors[i]))
continue;
for (int j = 0; j < states.size(); j++) {
if (!isDescendant(states[j], ancestors[i]) && (states[j] != ancestors[i]))
goto NEXT_ANCESTOR;
}
ancestor = ancestors[i];
break;
NEXT_ANCESTOR:
;
}
return ancestor;
}
示例13: printConfig
void printConfig(const Arabica::XPath::NodeSet<std::string>& config) {
std::string seperator;
std::cerr << "Config: {";
for (int i = 0; i < config.size(); i++) {
std::cerr << seperator << ATTR_CAST(config[i], "id");
seperator = ", ";
}
std::cerr << "}" << std::endl;
}
示例14: getQualifiedTransBreakpoints
std::list<Breakpoint> getQualifiedTransBreakpoints(Interpreter interpreter, const Arabica::DOM::Element<std::string>& transition, Breakpoint breakpointTemplate) {
std::list<Breakpoint> breakpoints;
Arabica::DOM::Element<std::string> source(interpreter.getImpl()->getSourceState(transition));
Arabica::XPath::NodeSet<std::string> targets = interpreter.getImpl()->getTargetStates(transition);
for (size_t j = 0; j < targets.size(); j++) {
Arabica::DOM::Element<std::string> target(targets[j]);
Breakpoint bp = breakpointTemplate; // copy base as template
bp.element = transition;
bp.transSourceId = ATTR(source, "id");
bp.transTargetId = ATTR(target, "id");
bp.subject = Breakpoint::TRANSITION;
breakpoints.push_back(bp);
}
return breakpoints;
}
示例15: load_document
void load_document(const std::string& location,
Arabica::XPath::NodeSet<std::string>& nodes) const
{
SAX2DOM::Parser<std::string> domParser;
SAX::CatchErrorHandler<std::string> eh;
domParser.setErrorHandler(eh);
Arabica::io::URI base(baseURI_);
Arabica::io::URI absolute(base, location);
SAX::InputSource<std::string> is(absolute.as_string());
domParser.parse(is);
if(!eh.errorsReported())
nodes.push_back(domParser.getDocument());
else
std::cerr << eh.errors() << std::endl;
} // load_document