[xml] Re: Schema to C++ classes



Hi Joel,

Joel Young <jdy cs brown edu> writes:

I believe that Dia uses xml for its native format and...  Dia has a
UML mode and...  someone wrote a Dia UML to C++ generator...

I just looked it up; it should come in handy:

<http://dia2code.sourceforge.net/>

Thanks but unfortunately that's not what I'm referring to. The basic
idea is that one could define a schema, say:

// --------------------

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
<xs:element name="Customer" type="PersonType"/>
<xs:complexType name="PersonType"
  <xs:sequence>
    <xs:element name="Name" type="xs:string" />
    <!-- etc -->
  </xs:sequence>
</xs:complexType>
</xs:schema>

And from this a class or series of classes (kind of like dia2code)
would be generated:

class PersonType: public XMLGenerator {
public:
  PersonType(xmlNode* self) {xmlInitialize(self); }

  std::string getName();
  void setName(std::string);
private:
  bool xmlInitialize(xmlNode*) { // initializes name ... }
  std::string _name;
};

PersonType Customer(xmlNode *dom);

// --------------------

Anyway, something a long these lines. I was looking at the schema
support in libxml2 briefly to see how it's implemented to find out if
I could just grab some kind of 'internal schema representation' and
build a classes and/or classes from it and was wondering if there are
any GPL projects that are already doing this before I began to dig too
deeply.

Oh I see what you mean: convert an XMLSchema to a dia diagram XML file
and hand it off to dia2code. That is a possibility. Thank you.

Regards, Elizabeth



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]