[xsde-users] Cxx-Tree binding the LandXML schema - Help accessint the elements data

Constantin Iacobescu sir.costy at gmail.com
Fri Feb 27 03:25:47 EST 2009


Hello,

I'm a bit beginner with XML parsing and less with XSD, so some help would be
appreciated.

I'm using Windows version of XSD Cxx-Tree for binding the LandXML schema and
so on the binding was without errors. This is the command line used:
xsd cxx-tree --generate-serialization --generate-polymorphic
--generate-doxygen --generate-wildcard --generate-ostream --type-naming java
--function-naming java --file-per-type  --namespace-map
http://www.landxml.org/schema/LandXML-1.0=LandXML_10  LandXML-1.0.xsd

Then I'm parsing some xml file and display the content on the screen.
Striped code should be some like this:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace xercesc;

  XMLPlatformUtils::Initialize ();

  try
  {
    namespace xml = xsd::cxx::xml;

    std::auto_ptr<LandXML_10::LandXML> objLandXML (
LandXML_10::parseLandXML(argv[1], xml_schema::Flags::dont_initialize));

    LandXML_10::LandXML::CgPointsSequence&
cgPoints(objLandXML->getCgPoints());

    for (LandXML_10::LandXML::CgPointsIterator ptsIter(cgPoints.begin());
         ptsIter != cgPoints.end ();
         ++ptsIter)
    {
        LandXML_10::CgPoints::NameOptional& optName(ptsIter->getName());
        if (optName.present())
            cerr <<"name:"<< optName.get() << endl;

        LandXML_10::CgPoints::CgPointSequence
cgPoint(ptsIter->getCgPoint());

        for (LandXML_10::CgPoints::CgPointIterator ptIter(cgPoint.begin());
         ptIter != cgPoint.end ();
         ++ptIter)
        {
            LandXML_10::CgPoint::NameOptional& optCode(ptIter->getCode());
            if (optCode.present())
                cerr <<"code:" << optCode.get() << endl;

            cerr << *ptIter <<endl    ;
          ???????????? How to get the data stored here ?????

        }
    }
    catch (const xml_schema::Exception& e)
    {
      cerr << e << endl;
    }

  XMLPlatformUtils::Terminate ();
  }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

As can be seen I can access the elements and display the attributes of them.
Even more, using the --generate-ostream option I can display all the content
of an element attributes + data.

My question is how I can get the data stored by a element in a std::string
for process it further more.

I've tried to made something like this (like I seen in some example):

DOMElement& e (*ptIter);

But got a compiler error: >>> error C2440: 'initializing' : cannot convert
from 'LandXML_10::CgPoint' to 'xercesc_3_0::DOMElement &'

Please if someone can give me some advices. Thanks

Best Regards,
Constantin Iacobescu


More information about the xsde-users mailing list