Arabica::DOM::Document<std::string> Data::toDocument() { Arabica::DOM::DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation(); Arabica::DOM::Document<std::string> document = domFactory.createDocument("http://www.w3.org/2005/07/scxml", "message", 0); Arabica::DOM::Element<std::string> scxmlMsg = document.getDocumentElement(); scxmlMsg.setPrefix("scxml"); scxmlMsg.setAttribute("version", "1.0"); if (compound.size() > 0 || array.size() > 0) { Arabica::DOM::Element<std::string> payloadElem = document.createElementNS("http://www.w3.org/2005/07/scxml", "payload"); payloadElem.setPrefix("scxml"); scxmlMsg.appendChild(payloadElem); // we do not support nested attibutes if (compound.size() > 0) { std::map<std::string, Data>::iterator compoundIter = compound.begin(); while(compoundIter != compound.end()) { if (compoundIter->second.atom.size() > 0) { Arabica::DOM::Element<std::string> propertyElem = document.createElementNS("http://www.w3.org/2005/07/scxml", "property"); propertyElem.setPrefix("scxml"); propertyElem.setAttribute("name", compoundIter->first); Arabica::DOM::Text<std::string> textElem = document.createTextNode(compoundIter->second.atom); propertyElem.appendChild(textElem); payloadElem.appendChild(propertyElem); } compoundIter++; } } } return document; }
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); }
Arabica::DOM::Document<std::string> InvokeRequest::toDocument() { Arabica::DOM::DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation(); Arabica::DOM::Document<std::string> document = Event::toDocument(); Arabica::DOM::Element<std::string> scxmlMsg = document.getDocumentElement(); scxmlMsg.setAttribute("invokeid", invokeid); return document; }
void setUp() { factory_ = Arabica::SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation(); document_ = factory_.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8("root"), 0); root_ = document_.getDocumentElement(); text1_ = document_.createTextNode(SA::construct_from_utf8("one")); text2_ = document_.createTextNode(SA::construct_from_utf8("two")); text3_ = document_.createTextNode(SA::construct_from_utf8("three")); root_.appendChild(text1_); root_.appendChild(text2_); root_.appendChild(text3_); } // setUp