[xsd-users] XML data binding
tsroynciitraoln
tsroynciitraoln at gmail.com
Mon Feb 16 11:26:59 EST 2015
Hi,
I'm currently using CodeSynthesis for XML data binding. I generated files
C++ files using the following comman line : ./xsd cxx-tree --std c++11
--file-per-type --generate-serialization --generate-wildcard
--generate-ostream --output-dir ./generated espiDerived.xsd
espiDerived is using atom.xsd, atom.xsd is using xml.xsd. Two main
namespaces are created: Atom and espi.
I'm able to navigate in the atom tree, using feed or entry root.
When arriving in a contentType node, I'm able to detect the kind of child
elements or attributs using this kind of code:
for (auto jtContent = itEntry->content().begin(); jtContent !=
itEntry->content().end(); ++jtContent)
{
::xercesc::DOMNode const* usagePointNode(0);
for (::xercesc::DOMNode const* n(jtContent->_node()->getFirstChild()); n !=
0; n = n->getNextSibling())
{
if (n->getNodeType() == ::xercesc::DOMNode::ELEMENT_NODE &&
xsd::cxx::xml::transcode<char>(n->getLocalName()) == "usahePoint")
{
usagePointNode = n;
std::cout << "UsagePoint node detected" << std::endl;
xml_schema::type& t(*reinterpret_cast<xml_schema::type*>
(usagePointNode->getUserData(xml_schema::dom::tree_node_key)));
espi::UsagePoint& a(dynamic_cast<espi::UsagePoint&> (t));
}
}
}
My current problem is for cast the underlying dom element to a C++
generated object. Using the two last line of code result in nothing inside
t and a. (empty struct). How can I solve my problem ?
I'm using the last version of CodeSynthesis, and Visual Studio 2013 on
Windows 8.1.
Best regards
More information about the xsd-users
mailing list