[xsd-users] Pointers to references
Mathew Benson
mathew.benson at gmail.com
Fri Feb 28 09:52:01 EST 2014
I'm using the XTCE (XML Telemetry and Command Exchange) v1.1 schema documented by the Consultative Committee for Space Data Systems (CCSDS) at http://public.ccsds.org/publications/archive/660x0g1.pdf. I run xsd cxx-tree on the schema file which generates a bunch of C++ code. I load my XTCE file and can pull out data just fine. The code generated by xsd saved me a massive amount of time and increased the quality of my code. The problem is that many of the XTCE elements have properties that are "references" to other XTCE elements. It refers to these elements by a unique name, I.e.:
<SomeElement name="Object1"/>
<AnotherElement someElementRef="Object1"/>.
I have to search the data structure for the element name. My improved solution is to add pointers to the generated classes for those elements, and do some post processing after unmarshalling the input file. The post processing sets those pointers. So after initialization, I can just follow the pointer, rather than searching the tree for the referenced element every time. The previous example would look like:
AnotherElement.h
class AnotherElement {
...
private:
SomeElement *_ptrSomeElement;
public:
SomeElement *getSomeElement(void);
...
}
AnotherElement.cpp
SomeElement *AnotherElement::getSomeElement(){
return _ptrSomeElement;
}
main.cpp
AnotherElement *objectA;
SomeElement *objectB;
...
objectB = objectA->getSomeElement();
I'm new to xsd and was wondering if it was capable of doing that post processing itself. I thought it would since it correctly self validates the input XML and tells me when mathew XML references an element that does not exist. I also don't know the best way to use xsd. Is it generating skeletal code that I can/should modify, or should I treat it as autocode that can be regenerated and should not be modified directly?
Does that help? I can post a fragment shortly.
Sent from my iPhone
> On Feb 28, 2014, at 7:01 AM, Boris Kolpackov <boris at codesynthesis.com> wrote:
>
> Hi Mathew,
>
> Mathew Benson <mathew.benson at gmail.com> writes:
>
>> I'm using a standard xsd file that includes references to other elements.
>> The auto code returns the name of the referenced element. Is it possible to
>> configure the auto coder or tweak the code to store a pointer to the
>> referenced element? As it is, I have to search the tree for the referenced
>> element.
>
> I have no idea what you are talking about. What is a "standard xsd file",
> "auto code", "auto coder"? Show the corresponding schema fragment and the
> C++ code that you want to write.
>
> Boris
More information about the xsd-users
mailing list