[xsd-users] Newbie question -- confused on simple point -- how to
get the value of an item from my parsed document?
Cook, Rich
cook47 at llnl.gov
Tue Feb 28 16:21:29 EST 2012
Hello,
I have scoured the documentation and probably the answer is right there in front of me, but I hope someone on this list will be kind enough to answer for me.
I have a .xsd file that defines a schema that is like this:
<?xml version="1.0" encoding="UTF-8"?>
<DCData xmlns="http://www.example.org/DCDataSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/DCDataSchema DCDataSchema.xsd ">
<FlightData>
some stuff...
</FlightData>
<Frame>
<imuLatitude>39.7987679545233</imuLatitude>
<imuLongitude>-84.134795903862</imuLongitude>
lots of other things...
</Frame>
<Frame>
<imuLatitude>40.7987679545233</imuLatitude>
<imuLongitude>-85.134795903862</imuLongitude>
lots of other things...
</Frame>
</DCData>
I have been able to create a parser for this using xsd like this:
xsd-3.3.0/bin/xsd cxx-tree --generate-serialization PursuerDCDataSchema.xsd
This results of course in two files: PursuerDCDataSchema.{c,h}xx
What I'd like to do is assign the value of imuLatitude to a float in my code. Something like this:
float latitude = some_sort_of_xsd_magic();
What I'm doing right now is:
mDCDataDoc = DCData(mCameraFilePath); // works fine
dch->numframes=mDCDataDoc->Frame().size(); // works fine
FrameDataType frame = mDCDataDoc->Frame()[frameNum]; // works fine
string valuestr;
frame.imuLatitude(valuestr); // compiles, but does not change valuestr
valuestr = frame.imuLatitude(); // compile time errors
What am I not getting right here?
I see I have a choice here:
// imuLatitude
//
typedef ::xml_schema::string imuLatitude_type;
typedef ::xsd::cxx::tree::optional< imuLatitude_type > imuLatitude_optional;
typedef ::xsd::cxx::tree::traits< imuLatitude_type, char > imuLatitude_traits;
const imuLatitude_optional&
imuLatitude () const;
imuLatitude_optional&
imuLatitude ();
void
imuLatitude (const imuLatitude_type& x);
void
imuLatitude (const imuLatitude_optional& x);
void
imuLatitude (::std::auto_ptr< imuLatitude_type > p);
How do I go from these member functions to a value I can use from the file?
Thanks for any help!
--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue, Livermore, CA, 94550, USA
☎ (office) (925) 423-9605
☎ (fax) (925) 423-6961
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)
More information about the xsd-users
mailing list