[xsd-users] Re: 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 19:29:23 EST 2012
Answered my own question.
The answer is
valuestr = *frame.imuLatitude();
On Feb 28, 2012, at 1:42 PM, Cook, Rich wrote:
> I tried xsd cxx-parser and it just left me with lots more questions, like there does not seem to be any way to open my input file that I can see. Bleh! Can someone please help me parse this thing?
> I swear I've read the docs, but somehow I still don't know:
> How should I generate the parser using xsd?
> How do I extract a value using C++?
> Maybe because I don't know much about XML I'm missing something very obvious.
> Thanks!
> :-)
> -- Rich
>
> On Feb 28, 2012, at 1:33 PM, Cook, Rich wrote:
>
>> Oops, I guess "xsd cxx-parser" would be a better command to create a parser than "xsd cxx-tree". I think that will unstick me for now.
>>
>>
>> On Feb 28, 2012, at 1:21 PM, Cook, Rich wrote:
>>
>>> 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)
>>>
>>>
>>>
>>
>> --
>> ✐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)
>>
>>
>>
>
> --
> ✐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)
>
>
>
--
✐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